Claude API SDKs
Anthropic publishes official Claude API SDKs in seven languages (Python, TypeScript, Java, Go, Ruby, C# and PHP) plus the ant command-line tool; the Python SDK installs with pip install anthropic and the TypeScript SDK with npm install @anthropic-ai/sdk. Since Oct 21, 2026 the new major versions are Apache 2.0 licensed.
Anthropic maintains official Claude API client libraries in seven languages: Python (pip install anthropic), TypeScript (npm install @anthropic-ai/sdk), Java, Go, Ruby, C# and PHP, plus a command-line tool called ant. Each wraps the REST API at https://api.anthropic.com with typed requests, streaming helpers, automatic retries and the right anthropic-version header, and most also cover the Admin API. The current major versions, released with API version 2026-10-21 on Oct 21, 2026, are licensed under Apache 2.0; earlier versions stay MIT.
Quick facts
| SDK | Package | Latest (Nov 6, 2026) | Requires |
|---|---|---|---|
| Python | anthropic on PyPI |
2.6.0 | Python 3.10+ |
| TypeScript | @anthropic-ai/sdk on npm |
1.6.0 | Node.js 20 LTS+, Deno 1.28+, Bun 1.0+ |
| Java | com.anthropic:anthropic-java |
3.6.0 | Java 8+ |
| Go | github.com/anthropics/anthropic-sdk-go/v2 |
2.7.0 | Go 1.25+ |
| C# | Anthropic on NuGet |
13.6.0 | .NET Standard 2.0+ |
| PHP | anthropic-ai/sdk on Packagist |
1.6.0 | PHP 8.1+ |
| Ruby | anthropic gem |
2.6.0 | Ruby 3.2+ |
| CLI | ant |
2.7.1 |
Sources: SDK versions JSON and the SDK pages, Anthropic, read Nov 6, 2026.
How do you install the Claude SDK?
The install commands from Anthropic's quickstart:
pip install anthropic # Python
npm install @anthropic-ai/sdk # TypeScript / JavaScript
go get github.com/anthropics/anthropic-sdk-go/v2 # Go
dotnet add package Anthropic # C#
bundle add anthropic # Ruby
composer require "anthropic-ai/sdk" "guzzlehttp/guzzle:^7" # PHP
Java uses Gradle (implementation("com.anthropic:anthropic-java:3.6.0")) or the matching Maven dependency. Then set your key from the Claude Console as ANTHROPIC_API_KEY, or sign in with ant auth login, which the SDKs also pick up.
A first request
Python:
import anthropic
client = anthropic.Anthropic() # reads ANTHROPIC_API_KEY
message = client.messages.create(
model="claude-opus-5-5",
max_tokens=1024,
messages=[{"role": "user", "content": "Hello, Claude"}],
)
print(message.content[0].text)
TypeScript:
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic();
const message = await client.messages.create({
model: "claude-opus-5-5",
max_tokens: 1024,
messages: [{ role: "user", content: "Hello, Claude" }],
});
console.log(message.content);
Both call the Messages API. The SDKs can also stream internally and hand back the finished message (stream.get_final_message() in Python, stream.finalMessage() in TypeScript), which the docs recommend for large max_tokens; a non-streaming request expected to run past 10 minutes is refused (Streaming Messages; Claude API errors).
What the SDKs do for you
- Retries. Connection errors, 429s and 5xx errors are retried twice by default with exponential backoff, honoring
retry-after; change it withmax_retries(Claude API errors). See Claude API Rate Limits. - Tool runner (beta, all seven SDKs). Runs the tool-calling loop for you: in Python you decorate functions with
@beta_tool, in TypeScript you usebetaZodTool()(Tool runner). See Tool Use. - Structured outputs. Pydantic models with
client.messages.parse()in Python, Zod withzodOutputFormat()in TypeScript (Structured outputs); see Structured Outputs. - Computer and browser use helpers. Since Oct 7, 2026, beta classes in Python and TypeScript where you write one method per action (Release notes); see Computer Use.
- Admin API under
client.organization, out of beta since Sep 30, 2026, and OpenTelemetry spans for tracing. - Cloud platforms. Add-on clients for Amazon Bedrock, Claude Platform on AWS, Google Cloud and Microsoft Foundry, such as TypeScript's
@anthropic-ai/bedrock-sdkand Python'santhropic[google_cloud]extra (Migrating to API version 2026-10-21); see Claude on Cloud Platforms.
The ant CLI
ant, launched Apr 8, 2026, calls any API endpoint from the terminal. It builds request bodies from flags or YAML, inlines files with @path, filters output with --transform (no jq needed) and pages through lists automatically (CLI quickstart). ant apply manages agents, environments and skills as files, and ant beta:sessions connect attaches to a Managed Agents session.
brew install anthropics/tap/ant # macOS; Linux uses the release binary or go install
ant auth login
ant messages create --model claude-opus-5-5 --max-tokens 1024 \
--message '{role: user, content: Hello, Claude}'
Versions and the 2026-10-21 upgrade
Each SDK major version sends one API version by default, and a new API version brings a new major version (SDKs, CLI, and libraries). The versions that first send 2026-10-21 are Python 2.0.0, TypeScript 1.0.0, Java 3.0.0, Go 2.0.0, Ruby 2.0.0, C# 13.0.0, PHP 1.0.0 and ant 2.0.0 (Migrating to API version 2026-10-21). The changes that break old code:
temperature,top_pandtop_kare removed and return a 400 error on every model, even at default values. Code that relied on a low temperature (for example on Sonnet 4.6) loses that effect, and can stay on the older API version.- The key is sent as
Authorization: Bearerinstead ofX-Api-Key; the API accepts both, but proxies that readX-Api-Keymust change. - Text Completions is gone from the TypeScript, Go, Java and Ruby SDKs and the CLI, and the Go module path gained
/v2. - On Amazon Bedrock, models older than Claude Opus 4.7 must stay on the older SDK.
The migration guide suggests running /claude-api api-version in Claude Code to update code automatically. Earlier, the Python SDK's own 1.0 release on Aug 20, 2026 had already moved it to Python 3.10 or later.
Other libraries
Anthropic also lists an OpenAI SDK compatibility layer, which its docs say is not a long-term or production-ready solution for most uses, only for testing and comparing (OpenAI SDK compatibility), and a Swift package for Apple's Foundation Models. For a ready agent loop rather than a client library, see the Claude Agent SDK; for comparing with OpenAI's API, see Claude API vs OpenAI API.
Frequently asked questions
How do I install the Anthropic Python SDK? Run pip install anthropic with Python 3.10 or later; the Claude Python SDK reads your key from the ANTHROPIC_API_KEY environment variable.
What is the package name of the Claude TypeScript SDK? The Claude TypeScript SDK is @anthropic-ai/sdk on npm, installed with npm install @anthropic-ai/sdk; it runs on Node.js 20 or later, Deno, Bun and edge runtimes.
Can I use the Claude SDK in a web browser? The Claude TypeScript SDK refuses to run in a browser unless you set dangerouslyAllowBrowser: true, because that exposes your API key to every visitor (TypeScript SDK).
Why does my Claude API call fail with temperature after upgrading? The Claude SDK versions released on Oct 21, 2026 send API version 2026-10-21, which rejects temperature, top_p and top_k; remove them or pin the older API version.
Is the Claude Agent SDK the same as the Claude API SDK? No. The Claude API SDKs are client libraries for sending requests, while the Claude Agent SDK is a framework that runs a full agent loop with tools.
Sources
- SDKs, CLI, and libraries, Anthropic docs, read Nov 6, 2026
- SDK versions JSON, Anthropic, read Nov 6, 2026
- TypeScript SDK, Anthropic docs, read Nov 6, 2026
- CLI quickstart, Anthropic docs, read Nov 6, 2026
- Get started with Claude Managed Agents, Anthropic docs, read Nov 6, 2026
- Migrating to API version 2026-10-21, Anthropic docs, read Nov 6, 2026
- Claude API errors, Anthropic docs, read Nov 6, 2026
- Streaming Messages, Anthropic docs, read Nov 6, 2026
- Tool runner, Anthropic docs, read Nov 6, 2026
- Structured outputs, Anthropic docs, read Nov 6, 2026
- OpenAI SDK compatibility, Anthropic docs, read Nov 6, 2026
- Release notes, Anthropic docs, read Nov 6, 2026
See also
-
Claude APIThe Claude API is Anthropic's REST API at api.anthropic.com for building with Claude models: create an API key in the Claude Console at platform.claude.com, then send requests to the Messages API, paying per token.
-
Claude ConsoleThe Claude Console at platform.claude.com is Anthropic's web dashboard for the Claude API, where developers create API keys, test prompts in the playground, organize workspaces, watch usage and rate limits, and buy credits. It was called the Anthropic Console until Sep 2025, and its Workbench became the playground in Aug 2026.
-
Messages APIThe Messages API is the Claude API's main endpoint, POST /v1/messages: you send a model, max_tokens and a list of user and assistant messages, and Claude returns a message with content blocks, a stop_reason and token usage, whole or streamed.
- Claude API Rate LimitsClaude API rate limits are set per organization by usage tier (Start, Build, Scale, Custom) as requests, input tokens and output tokens per minute; on the Start tier Claude Opus 5.5 allows 4,000 requests, 2,000,000 input tokens and 400,000 output tokens a minute. Going over returns a 429 error, while a 529 error means the API itself is overloaded.
-
Tool UseTool use (function calling) lets Claude call functions through the Claude API: you describe tools with a JSON Schema, Claude replies with a tool_use block, your code runs it and sends back a tool_result. Anthropic also runs server tools such as web search itself.
- Structured OutputsStructured outputs make the Claude API return JSON that always matches a JSON Schema you supply, through output_config.format, or tool inputs that match exactly, through strict tool use. It is Claude's answer to a JSON mode, generally available since Jan 29, 2026.