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 with max_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 use betaZodTool() (Tool runner). See Tool Use.
  • Structured outputs. Pydantic models with client.messages.parse() in Python, Zod with zodOutputFormat() 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-sdk and Python's anthropic[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_p and top_k are 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: Bearer instead of X-Api-Key; the API accepts both, but proxies that read X-Api-Key must 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

See also

About this page

Last updated Nov 6, 2026 by the Vi.ki team. Page text CC BY-SA 4.0.

Edit History

Hotkeys

/
Jump to the search box
? or Ctrl + /
Open this list
Esc
Close this list, the photo viewer, or the account menu

Photo viewer

← → or A D
Previous or next photo
↑ ↓ or W S
Previous or next photo
Home End
First or last photo
I
Show or hide the photo's info
Z
Clickless on or off: a pointer over a thumbnail shows it
N
Compare with the last photo: back to the one shown before this, and N again comes back
Q
Move the thumbnails to the next edge: top, bottom, left and round
, or Ctrl + ,
Open or close the viewer's settings
V
Clickless pan: a zoomed photo follows the pointer, rather than being dragged
Shift
Browse on or off
B
Show or hide the button bar
T
Show or hide the thumbnails
1
100% zoom on or off
0
Rate the photo as no opinion; again takes the answer back
+ -
Rate the photo a step higher or lower
F
Full screen: the photo alone. F again puts everything back.
Back to top