Provider<TChatOptions extends ChatModelOptions, TEmbeddingsOptions extends EmbeddingsModelOptions, TMediaOptions extends MediaGenerationModelOptions> class abstract

Provides a unified interface for accessing all major LLM, chat, and embedding providers in dartantic_ai.

The interface ensures all providers are accessible without importing provider-specific packages. All configuration (API keys, base URLs, models) is handled via the provider interface.

This interface is used to create a provider instance, which can be used to create a chat model or an embeddings model.

The provider interface is used to create a provider instance, which can be used to create a chat model or an embeddings model.

Constructors

Provider({required String name, required String displayName, required Map<ModelKind, String> defaultModelNames, String? apiKey, Uri? baseUrl, String? apiKeyName, List<String> aliases = const [], Map<String, String> headers = const {}})
Creates a new provider instance.
const

Properties

aliases List<String>
Alternative names for lookup (e.g., 'claude' => 'anthropic').
final
apiKey String?
The API key for this provider.
final
apiKeyName String?
The environment variable for the API key (if any).
final
baseUrl Uri?
The default API endpoint for this provider.
final
defaultModelNames Map<ModelKind, String>
The default model for this provider.
final
displayName String
Human-readable name for display.
final
hashCode int
The hash code for this object.
no setterinherited
headers Map<String, String>
Custom HTTP headers to include with all API requests.
final
name String
The canonical provider name (e.g., 'openai', 'ollama').
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

createChatModel({String? name, List<Tool<Object>>? tools, double? temperature, bool enableThinking = false, TChatOptions? options}) ChatModel<TChatOptions>
Creates a chat model instance for this provider.
createEmbeddingsModel({String? name, TEmbeddingsOptions? options}) EmbeddingsModel<TEmbeddingsOptions>
Creates an embeddings model instance for this provider.
createMediaModel({String? name, List<Tool<Object>>? tools, TMediaOptions? options}) MediaGenerationModel<TMediaOptions>
Creates a media generation model instance for this provider.
listModels() Stream<ModelInfo>
Returns all available models for this provider.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited