![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
@ai-sdk/anthropic
Advanced tools
The [Anthropic](https://www.anthropic.com/) provider for the [Vercel AI SDK](https://sdk.vercel.ai/docs) contains language model support for the [Anthropic Messages API](https://docs.anthropic.com/claude/reference/messages_post). It creates language model
The Anthropic provider for the Vercel AI SDK contains language model support for the Anthropic Messages API.
It creates language model objects that can be used with the generateText
, streamText
and generateObject
AI functions.
Note: The Anthropic API does not support streaming tool calls.
The Anthropic provider is available in the @ai-sdk/anthropic
module. You can install it with
npm i @ai-sdk/anthropic
You can import the default provider instance anthropic
from @ai-sdk/anthropic
:
import { anthropic } from '@ai-sdk/anthropic';
If you need a customized setup, you can import createAnthropic
from @ai-sdk/anthropic
and create a provider instance with your settings:
import { createAnthropic } from '@ai-sdk/anthropic';
const anthropic = createAnthropic({
// custom settings
});
You can use the following optional settings to customize the Google Generative AI provider instance:
baseURL string
Use a different URL prefix for API calls, e.g. to use proxy servers.
The default prefix is https://api.anthropic.com/v1
.
apiKey string
API key that is being send using the x-api-key
header.
It defaults to the ANTHROPIC_API_KEY
environment variable.
headers Record<string,string>
Custom headers to include in the requests.
You can create models that call the Anthropic Messages API using the provider instance.
The first argument is the model id, e.g. claude-3-haiku-20240307
.
Some models have multi-modal capabilities.
const model = anthropic('claude-3-haiku-20240307');
Anthropic Messages` models support also some model specific settings that are not part of the standard call settings. You can pass them as an options argument:
const model = anthropic('claude-3-haiku-20240307', {
topK: 0.2,
});
The following optional settings are available for Anthropic models:
topK number
Only sample from the top K options for each subsequent token.
Used to remove "long tail" low probability responses. Recommended for advanced use cases only. You usually only need to use temperature.
FAQs
The **[Anthropic provider](https://sdk.vercel.ai/providers/ai-sdk-providers/anthropic)** for the [AI SDK](https://sdk.vercel.ai/docs) contains language model support for the [Anthropic Messages API](https://docs.anthropic.com/claude/reference/messages_pos
The npm package @ai-sdk/anthropic receives a total of 137,033 weekly downloads. As such, @ai-sdk/anthropic popularity was classified as popular.
We found that @ai-sdk/anthropic demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.