anthropic-sdk-typescript  by anthropics

TypeScript SDK for Anthropic Claude models

created 2 years ago
1,132 stars

Top 34.6% on sourcepulse

GitHubView on GitHub
Project Summary

This TypeScript SDK provides a convenient interface for interacting with Anthropic's language model APIs, targeting developers building server-side applications. It simplifies API calls, handles streaming responses, and offers robust error management, enabling seamless integration of Anthropic's AI capabilities.

How It Works

The SDK leverages a modern, type-safe approach to interact with Anthropic's REST API. It utilizes fetch for network requests and provides comprehensive TypeScript definitions for all API parameters and responses, ensuring type safety and aiding development. Features like streaming support via Server-Sent Events (SSE) and automatic retry logic for transient errors enhance reliability and user experience.

Quick Start & Requirements

  • Install via npm: npm install @anthropic-ai/sdk
  • Requires Node.js 18+, Deno v1.28.0+, Bun 1.0+, Cloudflare Workers, or Vercel Edge Runtime.
  • TypeScript >= 4.5.
  • Browser support requires explicit dangerouslyAllowBrowser: true configuration.
  • See API Documentation for full details.

Highlighted Details

  • Supports streaming responses with convenient event handlers and accumulation.
  • Beta support for Message Batches API for processing multiple requests efficiently.
  • Beta support for tool use (function calling).
  • Automatic retries for connection errors, timeouts, and rate limits.
  • Configurable timeouts and request retries.

Maintenance & Community

  • Actively maintained by Anthropic.
  • Open to feedback and issues via GitHub.

Licensing & Compatibility

  • MIT License.
  • Compatible with server-side TypeScript/JavaScript, Node.js, Deno, Bun, Cloudflare Workers, and Vercel Edge Runtime. Browser support requires careful credential management.

Limitations & Caveats

  • Browser support requires explicit dangerouslyAllowBrowser: true, which exposes API keys client-side and is not recommended for production.
  • React Native is not supported.
  • Jest testing with "jsdom" environment is not supported.
Health Check
Last commit

22 hours ago

Responsiveness

1 day

Pull Requests (30d)
5
Issues (30d)
11
Star History
178 stars in the last 90 days

Explore Similar Projects

Starred by Adam Wolff Adam Wolff(Claude Code Core; MTS at Anthropic), Samuel Colvin Samuel Colvin(Author of Pydantic, Pydantic Logfire, PydanticAI), and
3 more.

anthropic-sdk-python by anthropics

0.7%
2k
Python SDK for Anthropic's REST API
created 2 years ago
updated 22 hours ago
Feedback? Help us improve.