Anthropic SDK
Official TypeScript SDK for calling Claude API and building agent applications.
Model SDKsNPM
3. Used by agents' projects
Dependency in 238 public GitHub projects set up for AI coding agents that we scanned (3.8%).
4. Agent access
Agent skills for this library in the skills catalog; community skills are written by others, read them before you install.
docs.anthropic.com/llms.txtFrom the package registry and GitHub, checked daily. Tap a verdict to see its source.How we checkedReport an error
What Anthropic SDK does
This is Anthropic's own TypeScript client for the Claude API. It is built for server-side code across many JavaScript runtimes, and it refuses to run in a browser unless you set a flag literally named <code>dangerouslyAllowBrowser</code>.
Anthropic SDK popularity
Gid Score measures public popularity and activity, not quality. How the Gid Score is calculated
How Anthropic SDK is used
- Anthropic SDK is a dependency in 238 of the 6,258 public GitHub projects set up for AI coding agents that we scanned (4.9% of the 4,867 JavaScript/TypeScript ones), #4 of 92 in model sdks.
- Counting the projects our scan samples by dependency (Solana 3,067, Ethereum and EVM 1,774, 3D and games 3,130, agent frameworks and SDKs 13,750), it appears in 1,035; those are left out of every share on this page.
- The most used alternative in our scan is OpenAI (286 projects).
- Projects that use it most often also use OpenAI (37.0%), Zod (60.1%), Express (33.6%).
- It is more common in projects set up for OpenClaw (9.0%) than for GitHub Copilot (2.6%).
By coding agent
Often used with
Anthropic SDK in practice
Strengths
The README lists Node.js 20 LTS or later, Deno v1.28.0 or higher, Bun 1.0 or later, Cloudflare Workers, Vercel Edge Runtime and Nitro v2.6 or greater as supported.
The platform docs describe SDK middleware that runs your code before each request and after each response. They also describe a client-side fallback middleware that retries refused requests on other models you name.
The docs say the Claude SDK emits OpenTelemetry spans in your application for each request and for each tool its tool runner runs.
According to the docs, the TypeScript SDK includes classes that connect Claude's browser use or computer use tool to a browser or desktop you provide.
Watch out for
The SDK will not run in a web browser unless you set <code>dangerouslyAllowBrowser</code> to <code>true</code>. The README says this default exists to avoid exposing secret API credentials. React Native is not supported.
The README says Jest 28 or greater is supported only with the <code>"node"</code> environment. <code>"jsdom"</code> is not supported.
On Google Cloud, <code>AnthropicGoogleCloud</code> targets the Anthropic-managed offering and <code>AnthropicVertex</code> targets the Google-managed one. Calling api.anthropic.com with an API key uses neither offering.
Send a first message
import Anthropic from '@anthropic-ai/sdk';
const client = new Anthropic({
apiKey: process.env['ANTHROPIC_API_KEY'], // This is the default and can be omitted
});
const message = await client.messages.create({
max_tokens: 1024,
messages: [{ role: 'user', content: 'Hello, Claude' }],
model: 'claude-opus-5-5',
});
console.log(message.content);More about Anthropic SDK
Head to head
- OpenAI vs Anthropic SDK used together in 88 projects
- Anthropic SDK vs Google Generative AI used together in 42 projects
Packages around it
- @anthropic-ai/claude-agent-sdk: Claude Agent SDK
- @anthropic-ai/sandbox-runtime: Sandbox runtime
- @anthropic-ai/mcpb: MCP bundles
- @anthropic-ai/vertex-sdk: Vertex AI client
- @anthropic-ai/claude-code: Claude Code CLI
- @anthropic-ai/bedrock-sdk: Bedrock client
Alternatives
Anthropic SDK This page
Official TypeScript SDK for accessing OpenAI APIs including GPT and embeddings.
Official SDK for Google Gemini API to build AI-powered applications.
Official JavaScript client library for Ollama to run and interact with local language models.
Official TypeScript SDK for calling Groq's fast language models API.
Official TypeScript SDK for calling Mistral's language models and APIs.
JavaScript client library for calling Replicate's AI model API.
Get started
Install it.
npm install @anthropic-ai/sdkRules for your agent
## Anthropic SDK
- Keep the client on the server. Read the key from `process.env['ANTHROPIC_API_KEY']`, which the client uses by default.
- Do not set `dangerouslyAllowBrowser: true` unless the user explicitly accepts exposing the API key in a browser. Do not target React Native.
- Assume TypeScript >= 5.0 and Node.js 20 LTS or later. Deno, Bun, Cloudflare Workers, Vercel Edge Runtime and Nitro are also supported.
- Run Jest tests that touch the SDK in the `"node"` environment, not `"jsdom"`.
- On Google Cloud, use `AnthropicGoogleCloud` for the Anthropic-managed offering and `AnthropicVertex` for the Google-managed one. Do not mix them.
- Treat refusals as normal responses. Check `stop_reason` for `"refusal"` instead of relying only on caught errors.
- Check current SDK versions at https://platform.claude.com/docs/sdk-versions.json, and query the docs MCP server at https://platform.claude.com/docs/mcp when unsure of an API.