Anthropic SDK TypeScript
ActiveDescription
Anthropic's official TypeScript SDK offering type-safe, Promise-based access to the Claude API with streaming responses and tool-use support.
Key Features
- Type-safe API client — Full TypeScript types aligned with the Claude API for end-to-end type inference on requests and responses
- Streaming response support — Built-in SSE streaming parser for real-time chat and incremental token rendering in agents
- Tool-use primitives — Wraps the tool_use / tool_result protocol to simplify agent function calling
- Prompt caching — Honors Anthropic's prompt cache headers to reduce repeated prompt cost
- Cross-runtime compatibility — Works across Node.js, browser, Deno, edge runtime, and Bun
- Automatic retries and timeouts — Built-in exponential backoff and timeout controls for production-grade agent calls
Use Cases
Categories
Quick Start
npm install @anthropic-ai/sdk
import Anthropic from '@anthropic-ai/sdk';
const client = new Anthropic();
const msg = await client.messages.create({
model: 'claude-sonnet-4-6',
max_tokens: 1024,
messages: [{ role: 'user', content: 'Hello, Claude' }],
});
console.log(msg.content[0].text);