SDKs & Developer Experience

TypeScript and JavaScript SDK Quickstart

If your product teams live in Node.js, the official TypeScript SDK gives them a typed Claude client that also runs on Deno, Bun, and the major edge runtimes.

Claude 3P 101 · Updated July 2026 · Unofficial guide

Anthropic's official TypeScript SDK is published on npm as @anthropic-ai/sdk. It covers plain JavaScript too — the types are there when you want them and invisible when you don't. For enterprises whose web and backend stacks are already Node-based, this is usually the second SDK evaluated after Python, and often the one that ships to production first because it sits closest to the customer-facing application.

Install

npm install @anthropic-ai/sdk

Supported runtimes are broad: Node.js 20 LTS and newer, Deno 1.28.0+, Bun 1.0+, Cloudflare Workers, Vercel Edge Runtime, Jest 28+ (in the node environment), and Nitro 2.6+. One deliberate limitation to know before your frontend team asks: browser usage is disabled by default. That is the safe default — calling Claude directly from a browser would expose your API key to anyone who opens developer tools. Keep Claude calls behind your own server or edge function.

Create a client and make the first call

Authentication follows the same pattern as every official Anthropic SDK: an API key, ideally supplied through the ANTHROPIC_API_KEY environment variable rather than hard-coded. Keys are created in the Claude Console under Settings → API keys and have no expiry, so store them in a secrets manager and rotate periodically.

import Anthropic from '@anthropic-ai/sdk';

const client = new Anthropic({ apiKey: process.env['ANTHROPIC_API_KEY'] });

const message = await client.messages.create({
  model: 'claude-sonnet-5',
  max_tokens: 1024,
  messages: [{ role: 'user', content: 'Hello, Claude' }],
});

The shape mirrors the underlying Messages API. model picks the Claude model (here claude-sonnet-5, the balanced mid-tier option; claude-opus-4-8 for complex agentic work, claude-haiku-4-5 for fast and cheap). max_tokens caps the length of the reply, and messages carries the conversation as an array of role/content pairs. The call is asynchronous — await it, and the resolved object contains the reply content plus token-usage numbers worth logging from day one.

TypeScript payoff: the request and response objects are fully typed. Misspell a parameter or read a field that does not exist and the compiler catches it before code review does — a small thing that matters a lot once several teams are building on the same client.

What about the third-party platforms?

The core @anthropic-ai/sdk package targets Anthropic's first-party Claude API. For Claude Platform on AWS — the Anthropic-operated service that runs inside AWS — there is a dedicated companion package, @anthropic-ai/aws-sdk, which handles AWS SigV4 request signing and workspace configuration for you and is currently in beta. For Amazon Bedrock, Google Vertex AI, and Microsoft Foundry from TypeScript, check the official SDK repository and each platform's documentation for current client options rather than assuming the Python client names carry over; the Python setup guides (Bedrock, Vertex AI, Foundry) explain what changes conceptually on each platform, and those concepts — credentials, region, model ID format — apply regardless of language.

Practical notes for a first production deployment

Pick your runtime deliberately. Edge runtimes (Cloudflare Workers, Vercel Edge) are attractive for latency, but long Claude responses are better served with streaming — see streaming basics and streaming in TypeScript before you commit to request/response.

Keep secrets out of the bundle. process.env works on servers; on edge platforms use the platform's secret bindings. Never ship the key in client-side JavaScript — the browser-disabled default exists precisely to make that mistake hard. CI/CD secrets handling covers the pipeline side.

Version-pin like any dependency. Lock the SDK version in your lockfile and upgrade on your own schedule; version pinning explains why "latest" is not a deployment strategy for model IDs either.

Where to go next

Compare languages in the SDK language overview, set up API key authentication properly, or jump to the platform quickstart to make this call on the cloud you already run.

Sources