Anthropic TypeScript SDK

The official TypeScript and JavaScript SDK for building on Anthropic's Claude API.

SDK
npm
v1.3.0
2,149 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
94 /100 Excellent
Development Activity 100
Maintenance 100
Community 84
Maturity 52
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
91 /100 Excellent
Architecture 92
Code Quality 90
Innovation 93
Learning Curve 88

The Anthropic TypeScript SDK is the official client library for the Claude API, giving server-side TypeScript and JavaScript applications a fully typed interface to Anthropic’s language models. It wraps the REST API with ergonomic resource methods for messages, streaming, token counting, batches, and model metadata, so you can go from an API key to a working request in a handful of lines.

Beyond the raw endpoints, the SDK ships higher-level helpers for streaming events, tool use, and structured outputs backed by Zod or JSON Schema, plus automatic retries, configurable timeouts, and pluggable middleware. It runs across Node.js, Deno, Bun, Cloudflare Workers, and Vercel Edge, and serves as the foundation for the Bedrock, Vertex, AWS, Google Cloud, and Foundry adapter packages in the same repository.

What You Get

  • A fully typed client covering the Messages, Models, Completions, and Batches endpoints of the Claude API.
  • Streaming helpers that surface incremental message, text, and thinking events with typed accessors.
  • Tool-use and structured-output helpers backed by Zod or JSON Schema for validated, typed responses.
  • Built-in resilience: automatic retries with backoff, configurable timeouts, and request middleware hooks.
  • Broad runtime support across Node.js, Deno, Bun, Cloudflare Workers, and Vercel Edge.

Common Use Cases

  • Calling Claude for chat, summarization, extraction, or classification from a Node.js backend.
  • Streaming model responses token-by-token into a web app or terminal UI.
  • Building tool-using agents that validate model output against Zod or JSON Schema.
  • Running high-volume asynchronous jobs through the Message Batches API.

Under The Hood

Architecture

The library is generated from Anthropic’s OpenAPI specification by Stainless and then extended with hand-written helpers. The entry point src/client.ts defines the Anthropic client, which composes a request pipeline (src/internal/request-options.ts, src/core/api-promise.ts), a credentials chain (src/lib/credentials/), platform detection (src/internal/detect-platform.ts), retry/backoff logic, and pluggable middleware (src/core/middleware.ts). Endpoints are modeled as resource classes under src/resources/ (for example messages/, models.ts, completions.ts, and the beta/ namespace), while streaming, pagination, and uploads live in dedicated modules (src/lib/MessageStream.ts, src/core/pagination.ts, src/core/uploads.ts). Higher-level ergonomics — tool toolsets, memory, and structured outputs — sit in src/helpers/ and src/tools/.

Tech Stack

Written almost entirely in TypeScript (~99% of the codebase), the runtime footprint is deliberately small: only standardwebhooks and json-schema-to-ts are hard dependencies, with zod as an optional peer dependency for schema-validated helpers. The build uses tsc-multi to emit CommonJS and ESM outputs plus Deno-compatible builds, and the project targets TypeScript 4.9+ and Node.js 20+. Tooling includes Jest with SWC for tests, ESLint 9, and Prettier.

Code Quality

The repository carries a substantial test suite — roughly 83 test files under tests/ covering client behavior, streaming, pagination, and helpers, exercised with nock for HTTP mocking. Generated code keeps naming and typing consistent across every endpoint, and hand-written helper modules follow the same conventions. Error handling is centralized through a typed error hierarchy (src/core/error.ts) that maps HTTP failures to specific exception classes, and releases are automated via release-please with a detailed changelog.

API Design

The public API is intentionally minimal and discoverable: instantiate new Anthropic({ apiKey }) and call resource methods like client.messages.create(...). Streaming is a first-class .stream() variant with typed event handlers, and tool use plus structured outputs are wrapped in Zod/JSON-Schema helpers that eliminate manual parsing boilerplate. Documentation is thorough — a README quickstart, a large api.md reference, a helpers.md guide, a MIGRATION.md, and 30-plus runnable examples — making the getting-started path short despite the breadth of capabilities.

Used by 63 apps in this directory

TypeScript
85%
Apache 2.0

superset

AI Code Assistants · AI Development

15,503

Orchestrate an army of AI coding agents—Claude Code, Codex, Gemini CLI, and more—running simultaneously in isolated git worktrees from a single Electron desktop app.

View details
86
Repo Health
80
Technical
64
Dependency
Built with
TypeScript 85%
Updated 6 days ago
Rust
66%
Apache 2.0

Temps

Analytics · Devops · Monitoring

865

A self-hosted Rust PaaS that replaces Vercel, Sentry, PostHog, Pingdom, Resend, and E2B with one binary — plus 440+ CLI operations agents like Claude Code can drive directly.

View details
81
Repo Health
86
Technical
66
Dependency
Built with
Rust 66%
TypeScript 33%
Updated 1 weeks ago
TypeScript
68%
AGPL 3.0

Tolaria

Note Taking

20,161

A free, open-source, local-first desktop app for managing markdown knowledge bases on macOS, Windows, and Linux — for second brains, company docs, or AI assistant memory and procedures.

View details
84
Repo Health
71
Technical
68
Dependency
Built with
TypeScript 68%
HTML 15%
Updated 6 days ago
HTML
68%
AGPL 3.0

ToolJet

AI Agents · Low Code Platforms · No Code Platforms

41,123

Open-source AI-native platform to build and deploy internal tools, workflows, and AI agents with a visual drag-and-drop builder and 80+ data source integrations.

View details
94
Repo Health
81
Technical
63
Dependency
Built with
HTML 68%
JavaScript 20%
Updated 6 days ago
TypeScript
84%
Other

twenty

CRM

59,615

The open-source CRM you build, ship, and version like the rest of your stack — with customizable objects, AI agents, and a TypeScript SDK.

View details
92
Repo Health
82
Technical
64
Dependency
Built with
TypeScript 84%
MDX 14%
Updated 1 weeks ago
TypeScript
95%
Apache 2.0

Void

AI Code Assistants · Automation · Code Editors

28,733

Open-source AI code editor with direct LLM integration and data privacy

View details
44
Repo Health
84
Technical
68
Dependency
Built with
TypeScript 95%
Updated 5 months ago
Svelte
45%
Apache 2.0

WebVM

Developer Tools

17,442

Run a full Linux virtual machine entirely in your browser using WebAssembly — no server required.

View details
69
Repo Health
67
Technical
0
Dependency
Built with
Svelte 45%
JavaScript 43%
Updated 3 weeks ago
Rust
33%
Other

Windmill

Automation · Developer Tools

18,257

Turn scripts into webhooks, workflows, and auto-generated UIs — the fastest self-hostable workflow engine, 13x faster than Airflow.

View details
91
Repo Health
82
Technical
64
Dependency
Built with
Rust 33%
TypeScript 24%
Svelte 22%
Updated 6 days ago
TypeScript
50%
Other

World Monitor

Analytics · Monitoring

89,376

Real-time global intelligence dashboard that fuses AI-synthesized news, geopolitical risk scoring, and infrastructure tracking into one open-source situational awareness platform.

View details
87
Repo Health
89
Technical
68
Dependency
Built with
TypeScript 50%
JavaScript 48%
Updated 6 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers