Skip to main content

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.
You can mix and match custom providers, the provider registry, and middleware in your application.

Custom Providers

You can create a custom provider using customProvider.

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 using createProviderRegistry.

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 the languageModel 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 the imageModel 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 the transcriptionModel method on the registry:

Example: Use Speech Models

You can access speech models by using the speechModel method on the registry:

Example: Use Reranking Models

You can access reranking models by using the rerankingModel method on the registry:

Global Provider Configuration

The AI SDK includes a global provider feature that allows you to specify a model using just a plain model ID string:
By default, the global provider is set to the Vercel AI Gateway.

Customizing the Global Provider

You can set your own preferred global provider:
This simplifies provider usage and makes it easier to switch between providers without changing your model references throughout your codebase.