Anthropic TypeScript SDK
The official TypeScript and JavaScript SDK for building on Anthropic's Claude API.
Repository Health
Technical Analysis
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 54 apps in this directory
Activepieces
Automation · AI Assistants
Open-source AI automation platform that converts 280+ workflow integrations into MCP servers for LLMs, with no-code builders and TypeScript extensibility.
agenta
Developer Tools · Devops · AI Development
The open-source LLMOps platform unifying prompt engineering, evaluation, and observability for teams building reliable LLM applications.
agentmemory
AI Agents
Persistent memory for AI coding agents — built on the iii engine, it works across Claude Code, GitHub Copilot CLI, Cursor, Gemini CLI, Codex CLI, and any MCP client, so agents stop needing everything re-explained every session.
AionUi
AI Agents · Productivity
Free, open-source Cowork desktop app that unifies Claude Code, Codex, Gemini CLI, and 20+ AI agents into a single platform with multi-agent teams, 24/7 cron automation, and zero-config built-in agent.
AnythingLLM
Developer Tools · Automation · AI Assistants
The all-in-one AI platform for private document chat, no-code agents, and local LLMs with zero setup friction.
Botpress
AI Assistants · AI Development · Customer Support
The open-source hub for building and deploying LLM-powered AI agents with TypeScript-first tooling, 40+ integrations, and a revolutionary code-execution agent framework.
Bramble
Password Manager · Security · Authentication
Local-first, end-to-end encrypted password manager that syncs your vault directly between your own devices over a private peer-to-peer mesh — no server, no account, no cloud in the middle.
byterover-cli
AI Agents · AI Code Assistants
A portable memory layer for AI coding agents — curate structured project knowledge into a version-controlled context tree that syncs across tools, machines, and teammates.
Cherry Studio
AI Assistants
All-in-one AI desktop client with 300+ assistants and multi-model support