Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

AI Tools · Function

createAnthropic

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.

How it works

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.

Syntax

createAnthropic(options?)

Returns

A configured Anthropic provider instance that can be called with a model identifier to obtain a language model.

Key points

  • Import createAnthropic from the @ai-sdk/anthropic package.
  • Use this factory when the default anthropic instance does not meet your configuration needs.
  • A custom URL prefix lets the provider send requests through a proxy or alternate endpoint.
  • Without a custom base URL, requests use Anthropic's v1 API endpoint.

Common mistakes

  • If baseUrl is changed, ensure it includes the correct API path for the target proxy or endpoint.

Example: Create a configured Anthropic provider

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.

When to use it

Custom provider setup

Applications that need explicit Anthropic credentials or provider configuration.

Alternate API endpoint

Deployments that route Anthropic requests through an HTTP proxy or gateway.

Model selection

Codebases that select different Claude models from one configured provider.

Interview questions

QWhen would you use createAnthropic instead of the default anthropic 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.

QWhat does the provider instance returned by createAnthropic do?

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.

QWhich package supplies createAnthropic and what API does the provider target?

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/anthropic
  • Anthropic provider
  • Messages API

Source: Anthropic - AI SDK. Checked 2026-10-15.