providers library

Third-party and local model providers behind the same LanguageModel interface as the on-device model.

Importing this library lets an app send prompts off the device, to the provider the user configured. Everything from system_llm.dart is re-exported, so one import is enough.

Classes

AiArraySchema
AiBooleanSchema
AiIntegerSchema
AiMessage
One turn of a conversation sent to a LanguageModel.
AiObjectSchema
AiSchema
Describes the JSON shape a model must answer with.
AiStringSchema
AnthropicModel
Speaks Anthropic's Messages API (POST /messages).
ApiKeyStore
Where API keys live, keyed by ProviderConfig.id. Apps back this with the platform's secure storage (Keychain, Keystore); keys never go into ModelSettings or ProviderConfig.
DeviceEnvironment
Facts about the device that matter when deciding whether a larger model can be downloaded and run.
InMemoryApiKeyStore
Keeps keys in memory only; for tests and previews.
LanguageModel
A model that features (a chat, an extractor, ...) run on, so the model behind them can be swapped: the operating system's built-in model, a local server such as Ollama, or a cloud provider.
ModelResolver
Turns the user's ModelSettings into the LanguageModel features run on.
ModelSettings
The user's model choice: the on-device model, or one of their providers.
OnDeviceModel
The operating system's built-in model behind the LanguageModel interface.
OpenAiCompatibleModel
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.
ProviderConfig
One provider entry the user configured: where to send requests and which model to use. The API key is not part of it; it lives in an ApiKeyStore.
ProviderPreset
A provider the package knows how to reach: endpoint, protocol and a few suggested models. Users still bring their own API key.
ProviderPresets
Built-in presets. Base URLs were checked against each provider's documentation on 2026-11-11; suggested model IDs are the provider's stable aliases where one exists, and may still go stale.
RemoteLanguageModel
A LanguageModel served over HTTP by a third-party provider or a local server. Prompts leave the device: show the user config's host.
SystemLlm
Entry point of the plugin.
SystemLlmPlatform
Native operations. All errors surface as PlatformException; the public SystemLlm class converts them to SystemLlmException.

Enums

AiAvailability
Whether a language model can answer now.
AiRole
Who wrote a message in a conversation.
MaxTokensField
The request field that carries the token limit.
ProviderConfigError
Why a ProviderConfig cannot be used.
ProviderProtocol
The HTTP API a provider speaks.
StructuredOutputMode
How an OpenAI-compatible provider is asked for JSON. Anthropic always uses JSON outputs (output_config.format). Every answer is validated against the schema anyway.

Exceptions / Errors

SystemLlmException
Thrown when a model call fails, on-device or remote.