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 63 apps in this directory
Promptfoo
AI Development
An open-source CLI and library for evaluating and red-teaming LLM applications — replace trial-and-error prompt engineering with systematic evals, vulnerability scanning, and CI/CD integration.
Puter
Developer Tools · File Storage
A self-hostable, web-based internet OS with desktop GUI, cloud storage, AI drivers, and a developer SDK — all running in your browser.
reader
Data Engineering · Developer Tools
Production-grade open source web scraping engine that turns any URL into clean markdown for AI agents — with built-in anti-bot bypass, proxy rotation, and browser session management.
Sanity
CMS
Open-source headless CMS with a fully customizable React Studio, real-time collaborative editing, structured content modeling, and GROQ query language
Skrun
AI Agents
An open, self-hostable, multi-model agent runtime that deploys any agent skill as an API via POST /run — an open-source alternative to Claude Managed Agents and Google's Gemini Enterprise Agent Platform.
Sourcebot
AI Code Assistants · Developer Tools · Search
A self-hosted, AI-powered code search engine that indexes every repo across GitHub, GitLab, Bitbucket, Gitea, Gerrit, and Azure DevOps, so both engineers and coding agents can search, browse, and ask questions about your codebase from one place.
superglue
AI Agents · Data Engineering · Developer Tools
superglue is an AI-agent-driven integration engine that turns plain-English descriptions of enterprise systems into production-grade API tools, ERP/CRM connectors, and data pipelines — self-hosted or cloud, Y Combinator-backed (W25).
superlog
AI Agents · Monitoring
Open-source agentic observability that ingests OpenTelemetry signals, groups them into incidents, and deploys AI agents to investigate and fix your production bugs automatically.
supermemory
AI Development · AI Memory · Note Taking
The state-of-the-art memory and context engine for AI agents — ranked #1 on all three major AI memory benchmarks.