OpenAiCompatibleModel class final

Speaks POST /chat/completions, the API most providers and local servers copy: OpenAI, Ollama (/v1), LM Studio, Gemini's OpenAI endpoint, Qwen (DashScope compatible mode), OpenRouter, Groq, DeepSeek, Mistral.

Inheritance

Constructors

OpenAiCompatibleModel({required ProviderConfig config, String? apiKey, Client? client, Duration timeout = const Duration(seconds: 90)})

Properties

config → ProviderConfig
finalinherited
displayName → String
Name to show to the user.
no setterinherited
hashCode → int
The hash code for this object.
no setterinherited
id → String
Stable identifier, for example on-device or a provider config id.
no setterinherited
isOnDevice → bool
Whether prompts stay on this device.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

availability({String locale = 'en'}) → Future<AiAvailability>
Checks the key and that the provider serves ProviderConfig.model, by listing models. A server without a model listing counts as available.
inherited
cancel() → Future<void>
Stops any running generation of this model.
inherited
close() → void
Stops running requests and releases the HTTP client if this model created it.
inherited
generateObject({required String instructions, required List<AiMessage> messages, required AiSchema schema, String locale = 'en', int maxTokens = 512}) → Future<Map<String, Object?>>
Asks for one JSON object shaped like schema, whose root must be AiSchema.object (otherwise throws ArgumentError).
inherited
listModels({Duration? timeout}) → Future<List<String>>
Model identifiers the provider serves, sorted.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
streamText({required String instructions, required List<AiMessage> messages, String locale = 'en', int maxTokens = 512}) → Stream<String>
Streams a free-text answer to messages, chunk by chunk. Cancelling the subscription, or calling cancel, stops the generation.
override
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited