OpenAiCompatibleChatModel class final
A chat model speaking the OpenAI /chat/completions format.
- Implemented types
- Available extensions
Constructors
-
OpenAiCompatibleChatModel.custom({required Uri baseUrl, required String model, required String provider, String? apiKey, Set<
ModelCapability> capabilities = ModelCapabilities.standard, int? contextWindow, int? maxOutputTokens, ModelPricing? pricing, bool isLocal = false, Map<String, String> headers = const <String, String>{}, Client? client, Duration timeout = const Duration(seconds: 120), String chatPath = '/chat/completions'}) - Creates an adapter against an arbitrary OpenAI-compatible endpoint.
- OpenAiCompatibleChatModel.deepSeek({required String apiKey, required String model, Client? client})
-
Creates an adapter for DeepSeek.
factory
- OpenAiCompatibleChatModel.grok({required String apiKey, String model = 'grok-4.6', Client? client})
-
Creates an adapter for xAI's Grok.
factory
-
OpenAiCompatibleChatModel.llamaCpp({String model = 'local', Uri? baseUrl, Set<
ModelCapability> capabilities = ModelCapabilities.localMinimal, Client? client}) -
Creates an adapter for a llama.cpp server.
factory
- OpenAiCompatibleChatModel.mistral({required String apiKey, required String model, Client? client})
-
Creates an adapter for Mistral.
factory
-
OpenAiCompatibleChatModel.ollama({required String model, Uri? baseUrl, Set<
ModelCapability> capabilities = ModelCapabilities.localMinimal, Client? client}) -
Creates an adapter for a local Ollama server.
factory
-
OpenAiCompatibleChatModel.openAi({required String apiKey, String model = 'gpt-5.6', Uri? baseUrl, String? organization, ModelPricing? pricing, Client? client, Set<
ModelCapability> capabilities = ModelCapabilities.frontier}) -
Creates an adapter for OpenAI itself.
factory
Properties
Methods
-
checkSupports(
ChatRequest request) → void -
Available on ChatModel, provided by the ChatModelOperations extension
Verifies this model can satisfyrequest. -
dispose(
) → Future< void> - Releases every resource held by this object.
-
generate(
ChatRequest request, {AgenticContext? context}) → Future< ChatResponse> -
Generates a complete answer.
override
-
generateStructured<
T> (ChatRequest request, {required String name, required JsonSchema schema, required T fromJson(JsonMap json), AgenticContext? context}) → Future< T> -
Available on ChatModel, provided by the ChatModelOperations extension
Answers with a value conforming toschema. -
listModels(
{AgenticContext? context}) → Future< List< ModelDescriptor> > -
Lists the models this endpoint serves, from
GET /models.override -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
prompt(
String prompt, {String? system, double? temperature, int? maxOutputTokens, AgenticContext? context}) → Future< String> -
Available on ChatModel, provided by the ChatModelOperations extension
Answers a single prompt and returns the text. -
stream(
ChatRequest request, {AgenticContext? context}) → Stream< ChatChunk> -
Generates an answer incrementally.
override
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited