ai_sdk_openai_compatible

Shared base for AI SDK Dart providers that speak the OpenAI Chat Completions wire format over SSE — ai_sdk_openai, ai_sdk_azure, ai_sdk_groq, and ai_sdk_mistral.

This is infrastructure, not a vendor provider: it has no callable factory of its own. It implements tool calling, multimodal content, structured output, and streaming once so the four providers above inherit them. See ADR 0004.

Usage (provider authors)

import 'package:ai_sdk_openai_compatible/ai_sdk_openai_compatible.dart';
import 'package:dio/dio.dart';

LanguageModelV3 myModel(String modelId) => OpenAICompatibleChatLanguageModel(
  config: OpenAICompatibleConfig(
    provider: 'groq',
    baseUrl: 'https://api.groq.com/openai/v1',
    headers: () => {'Authorization': 'Bearer $apiKey'},
  ),
  modelId: modelId,
);

The OpenAICompatibleConfig parameterizes per-provider quirks (auth scheme, base URL, query params like Azure's api-version, seed vs random_seed, max_tokens vs max_completion_tokens, capability flags, and an extraBody hook). Everything else — request building, SSE parsing, tool serialization, multimodal mapping, finish-reason mapping — is shared.

License

MIT

Libraries

ai_sdk_openai_compatible
Shared OpenAI Chat Completions base for AI SDK Dart providers.