Custom provider setup
Applications that need explicit Anthropic credentials or provider configuration.
AI Tools · Function
createAnthropic creates a customized Anthropic provider for the Vercel AI SDK. Configure the provider, then call it with a Claude model identifier to obtain a language model.
createAnthropic builds a customized Anthropic provider instance from configuration such as an API key. The returned provider is callable with a model identifier, producing a language model that can be passed to AI SDK functions.
createAnthropic(options?)A configured Anthropic provider instance that can be called with a model identifier to obtain a language model.
import { createAnthropic } from '@ai-sdk/anthropic';
const anthropic = createAnthropic({
apiKey: process.env.ANTHROPIC_API_KEY,
});
const model = anthropic('claude-sonnet-4-5');Creates a configured Anthropic provider and then selects a Claude model from it.
Applications that need explicit Anthropic credentials or provider configuration.
Deployments that route Anthropic requests through an HTTP proxy or gateway.
Codebases that select different Claude models from one configured provider.
Use createAnthropic when the default provider instance is not sufficient and you need custom settings. Import it from @ai-sdk/anthropic, call it with configuration, and use the resulting provider to select a model.
Follow-up: How can a deployment route requests through a proxy? Pass a custom baseUrl when creating the provider, while preserving the endpoint path required by that proxy.
The function returns a configured provider instance. Calling that instance with a model identifier, such as a Claude model name, creates the language model used by the AI SDK.
Follow-up: How would you choose among Claude models? Invoke the provider with the exact model identifier supported by the Anthropic API and appropriate for the workload.
The Anthropic provider is installed from the @ai-sdk/anthropic module. The provider supports language models through Anthropic's Messages API, and custom instances can be created with createAnthropic.
Follow-up: What configuration is commonly customized? API credentials, the request URL prefix, and request headers are typical provider-level settings.
anthropic@ai-sdk/anthropicAnthropic providerMessages API