RemoteLanguageModel class sealed
A LanguageModel served over HTTP by a third-party provider or a local server. Prompts leave the device: show the user config's host.
Remote providers ignore the locale argument; ask for a language in the
instructions if it matters. Construct one with RemoteLanguageModel.create
or a concrete class, and call close when done.
- Implemented types
- Implementers
Constructors
- RemoteLanguageModel.create(ProviderConfig config, {String? apiKey, Client? client, Duration timeout = const Duration(seconds: 90)})
-
The adapter for
config's protocol.apiKeymay be null for servers that need none (a local Ollama). Pass a sharedclientto reuse connections; otherwise one is created and released by close.factory
Properties
- config → ProviderConfig
-
final
- displayName → String
-
Name to show to the user.
no setteroverride
- hashCode → int
-
The hash code for this object.
no setterinherited
- id → String
-
Stable identifier, for example
on-deviceor a provider config id.no setteroverride - isOnDevice → bool
-
Whether prompts stay on this device.
no setteroverride
- 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.
override
-
cancel(
) → Future< void> -
Stops any running generation of this model.
override
-
close(
) → void - Stops running requests and releases the HTTP client if this model created it.
-
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).override -
listModels(
{Duration? timeout}) → Future< List< String> > - Model identifiers the provider serves, sorted.
-
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.inherited -
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
- availabilityTimeout → const Duration
- Bounds the model listing used by availability.