Anthropic Python SDK
Official Python SDK for the Anthropic API providing access to Claude models. Current version is 0.84.0 (Feb 2026). Releases approximately weekly. Two separate packages exist: anthropic (core SDK) and claude-agent-sdk-python (agent workflows).
Warnings
- breaking anthropic.Client() is removed. Use anthropic.Anthropic() instead.
- gotcha SDK releases weekly. Pin your version in production or expect frequent behaviour changes.
- gotcha message.content is a list, not a string. Access text via message.content[0].text.
- gotcha max_tokens is required. No default value. Omitting raises a validation error.
- deprecated claude-agent-sdk-python no longer requires Claude Code to be installed separately. It is bundled.
- gotcha Model IDs are frequently hallucinated by LLMs. Observed wrong values: claude-opus-4-20250514, claude-3-opus-20240229, claude-opus-4-0. Wrong model ID gives a 404 at runtime with no helpful error message.
Install
-
pip install anthropic -
pip install claude-agent-sdk -
npm install @anthropic-ai/sdk
Imports
- Anthropic
from anthropic import Anthropic
- AsyncAnthropic
from anthropic import AsyncAnthropic
Quickstart
from anthropic import Anthropic
client = Anthropic() # reads ANTHROPIC_API_KEY from env
message = client.messages.create(
model='claude-opus-4-6',
max_tokens=1024,
messages=[
{"role": "user", "content": "Hello, Claude"}
]
)
print(message.content[0].text)