AnthropicModel class final
Speaks Anthropic's Messages API (POST /messages).
Structured output uses output_config.format (JSON outputs), because the
current Claude models reject a forced tool choice. Array length limits are
not supported there, so they are moved into the field description.
Sampling settings (temperature and the like) are never sent: API version
2026-10-21 rejects them.
- Inheritance
-
- Object
- RemoteLanguageModel
- AnthropicModel
Constructors
- AnthropicModel({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-deviceor 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
Constants
- apiVersion → const String
-
The
anthropic-versionheader sent with every request.