Provider & Model Management
When you work with multiple providers and models, it is often desirable to manage them in a central place and access the models through simple string ids. The AI SDK offers custom providers and a provider registry for this purpose:- With custom providers, you can pre-configure model settings, provide model name aliases, and limit the available models.
- The provider registry lets you mix multiple providers and access them through simple string ids.
Custom Providers
You can create a custom provider usingcustomProvider.
Example: Custom Model Settings
You might want to override the default model settings for a provider or provide model name aliases with pre-configured settings.Example: Model Name Alias
You can also provide model name aliases, so you can update the model version in one place in the future:Example: Limit Available Models
You can limit the available models in the system, even if you have multiple providers.Provider Registry
You can create a provider registry with multiple providers and models usingcreateProviderRegistry.
Setup
Setup with Custom Separator
By default, the registry uses: as the separator between provider and model IDs. You can customize this separator:
Example: Use Language Models
You can access language models by using thelanguageModel method on the registry.
The provider id will become the prefix of the model id: providerId:modelId.
Example: Use Text Embedding Models
You can access text embedding models by using the.embeddingModel method on the registry.
The provider id will become the prefix of the model id: providerId:modelId.
Example: Use Image Models
You can access image models by using theimageModel method on the registry.
The provider id will become the prefix of the model id: providerId:modelId.
Example: Use Transcription Models
You can access transcription models by using thetranscriptionModel method on the registry:
Example: Use Speech Models
You can access speech models by using thespeechModel method on the registry:
Example: Use Reranking Models
You can access reranking models by using thererankingModel method on the registry: