AI.ProviderRegistry (AI SDK v0.0.1-rc.0)
View SourceA registry for AI providers and their language models.
This module provides a central registry for managing different AI providers and their associated language models, enabling dynamic registration and lookup.
Summary
Functions
Returns a specification to start this module under a supervisor.
Gets a language model by its model ID string.
Retrieves a provider by its ID.
Registers a provider module with the given ID.
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
Gets a language model by its model ID string.
Model IDs can be in the format "provider:model" to specify which provider should handle the model, e.g., "openai:gpt-4" or "anthropic:claude-3-sonnet".
Parameters
model_id- A string identifying the model, in format "provider:model_name"opts- Optional configuration for the model
Returns
{:ok, language_model}- The initialized language model{:error, reason}- If the model or provider could not be found
Retrieves a provider by its ID.
Parameters
provider_id- The string ID of the provider to get
Returns
{:ok, provider}- The provider with its module and options{:error, :not_found}- If no provider with that ID is registered
Registers a provider module with the given ID.
Parameters
provider_id- A string ID for the providerprovider_module- The module that implements the provideropts- Optional configuration for the provider
Returns
:ok- If registration was successful{:error, reason}- If registration failed