customProvider
With a custom provider, you can map ids to any model. This allows you to set up custom model configurations, alias names, and more. The custom provider also supports a fallback provider, which is useful for wrapping existing providers and adding additional functionality. Custom providers can expose language, embedding, image, transcription, speech, reranking, video, files, and skills capabilities.
Example: custom model settings
You can create a custom provider using customProvider.
Import
import { customProvider } from "ai"
API Signature
Parameters
Returns
The customProvider function returns a Provider instance. It has the following methods:
Experimental decision models
Pass decisionModels: Record<string, Experimental_DecisionModel> to define
aliases for decision model instances or string IDs. The returned provider adds
decisionModel(alias): Experimental_DecisionModelV4. String aliases resolve
through Gateway by default, or an explicitly configured default provider with
a decisionModel method. Unknown aliases use the fallback provider's decision
factory when available; model failures and unsupported questions do not trigger
substitution.
Unavailable decision capabilities or models throw NoSuchModelError with
modelType: 'decisionModel'; unknown registry providers throw
NoSuchProviderError. These capabilities are structural extensions and are not
added to the stable ProviderV4 contract. Direct decision string IDs default
to Gateway when no default provider is configured.
See Decisions
for runnable usage patterns.