The official TypeScript and Node.js SDK for the Anthropic API, providing seamless access to the Claude model family, including Claude 3.5 Sonnet, Haiku, and the Claude Opus 4.6 series. The SDK features a unified architecture, native streaming, structured data handling, and full support for advanced features like Prompt Caching, Tool Use (Function Calling), Computer Use, and the Model Context Protocol (MCP). It is optimized for server-side JavaScript runtimes (Node.js, Deno, Bun, Cloudflare Workers). It acts as the standard method for interacting with Anthropic's APIs, abstracting raw HTTP calls while providing robust type definitions and automatic retries.
npm install @anthropic-ai/sdkNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
A basic Messages API request using the claude-opus-4-6 model, illustrating the required max_tokens parameter and the correct placement of the system prompt.
Update model strings in your code to explicitly point to supported versioned model strings (e.g., `claude-opus-4-6`).
Extract the system instructions and assign them directly to the `system` property at the root of the `create()` method configuration object.
Pass `dangerouslyAllowBrowser: true` to the constructor ONLY if you are absolutely sure about the security implications or are securely proxying requests.
Add the `max_tokens` parameter to your request body, ensuring it is an integer up to the model's maximum output limit (e.g., `max_tokens: 4096`).
Combine sequential 'user' messages into a single message object, or ensure your messages array strictly alternates the sequence: `user -> assistant -> user`.
Move the API call to a backend Node.js server or a serverless API route. If you must run it in the client for testing, instantiate the client with `new Anthropic({ dangerouslyAllowBrowser: true })`.No dependency data recorded yet.
No traffic data recorded yet.