Why it matters
- 10M+ monthly PyPI downloads — the standard SDK for Claude integration in Python applications.
- Claude Sonnet 4.6's leading performance on coding, reasoning, and instruction-following benchmarks makes the Anthropic SDK a top choice for AI applications.
- 200K-token context window (Claude 3) enables processing of very long documents, codebases, and conversation histories.
- Tool use (function calling) enables agentic applications where Claude takes actions, retrieves data, and completes multi-step tasks.
Key capabilities
- Chat completions:
client.messages.create() for all Claude models (Sonnet, Haiku, Opus).
- Streaming:
client.messages.stream() for token-by-token streaming responses.
- Vision: Pass images (base64 or URL) for Claude to analyze alongside text.
- Tool use: Define and call functions; Claude decides when and how to use them.
- System prompts: Set behavior, persona, and constraints via system parameter.
- Async support:
AsyncAnthropic client for async/await usage in FastAPI or asyncio.
- Batches API: Submit large batches for 50% cost reduction with async processing.
- Message counting: Count tokens before sending to manage context windows.
Technical notes
- Install:
pip install anthropic
- License: MIT (open source)
- GitHub: github.com/anthropics/anthropic-sdk-python
- Models: claude-sonnet-4-6, claude-haiku-4-5, claude-opus-4-6
- Context: Up to 200K tokens (Claude 3 models)
- Pricing: Sonnet $3/$15 per M tokens; Haiku $0.25/$1.25; Opus $15/$75
- Python: 3.7+
Usage example
import anthropic
client = anthropic.Anthropic()
message = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=1024,
messages=[{"role": "user", "content": "Explain quantum entanglement simply."}]
)
print(message.content[0].text)
Ideal for
- Python developers building applications that use Claude for reasoning, coding, writing, analysis, or agent tasks.
- Teams evaluating Claude vs. GPT-4 who want to test the official API with minimal setup.
- Applications requiring large context windows (legal docs, long codebases, lengthy conversations).
Not ideal for
- JavaScript/TypeScript applications — use
@anthropic-ai/sdk npm package instead.
- Multi-provider applications — use Vercel AI SDK, LangChain, or Portkey for provider-agnostic access.
- Teams who need Claude in a managed workflow (Workbench, Claude.ai) rather than API access.
See also
- OpenAI Python SDK — Equivalent SDK for OpenAI's GPT-4o; similar interface.
- Vercel AI SDK — TypeScript multi-provider SDK for web applications.
- LangChain — Orchestration framework that wraps the Anthropic SDK with chains and agent abstractions.