A model that answers a conversation.
Implementations must:
- translate framework errors onto the core hierarchy, so callers never see a
raw
SocketExceptionor a provider's own error class; - honour
AgenticContext.cancellation, closing the connection when it fires; - declare capabilities honestly in info;
- be safe to share — a single instance serves concurrent requests.
final model = OpenAiCompatibleChatModel.openAi(apiKey: key, model: 'gpt-5.6');
final answer = await model.prompt('Explain Dart records in one sentence.');
- Implementers
- Available extensions
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.
inherited
-
generate(
ChatRequest request, {AgenticContext? context}) → Future< ChatResponse> - Generates a complete answer.
-
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. -
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.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited