OpenaiClient
Category: LLM Providers
Source: openai_client.dart
Classes
OpenAiClient
LLM client for OpenAI Chat Completions API with streaming.
Compatibility quirks of OpenAI-shaped endpoints (Groq, Ollama, OpenRouter, vLLM, Mistral) are handled by the injected [CompatibilityProfile] — this client stays protocol-shaped and does not branch on vendor id.
Constructor
dart
OpenAiClient({
required this.apiKey,
required this.model,
required this.systemPrompt,
required this.baseUrl,
this.profile = CompatibilityProfile.openai,
this.extraHeaders = const {},
http.Client Function()? requestClientFactory,
})Properties
| Property | Type | Description |
|---|---|---|
apiKey | String | |
model | String | |
systemPrompt | String | |
baseUrl | String | |
profile | CompatibilityProfile | |
extraHeaders | Map<String, String> |
Methods
Stream<LlmChunk> stream(List<Message> messages, {List<Tool>? tools})
`static Stream<LlmChunk> parseStreamEvents(
Stream<Map<String, dynamic>> events,
)`
Parse OpenAI streaming chunks into [LlmChunk]s.
Exposed as static for testability.