anthropic-sdk-typescript  by anthropics

TypeScript SDK for Anthropic Claude models

Created 2 years ago
1,213 stars

Top 32.3% 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

1 day ago

Responsiveness

1 day

Pull Requests (30d)
6
Issues (30d)
5
Star History
49 stars in the last 30 days

Explore Similar Projects

Feedback? Help us improve.