Claude SDK
January 30, 2026
The Claude SDK is Anthropic's official client library for building applications with Claude models. Available in Python and TypeScript, it provides direct access to Claude's capabilities including tool use, streaming, and agent workflows.
Core Features
Simple API Access
from anthropic import Anthropic
client = Anthropic()
message = client.messages.create(
model="claude-sonnet-4-5-20250929",
max_tokens=1024,
messages=[
{"role": "user", "content": "Hello, Claude"}
]
)
print(message.content[0].text)
Streaming Responses
with client.messages.stream(
model="claude-sonnet-4-5-20250929",
max_tokens=1024,
messages=[{"role": "user", "content": "Write a story"}]
) as stream:
for text in stream.text_stream:
print(text, end="", flush=True)
Tool Use
Claude can call functions you define:
tools = [
{
"name": "get_weather",
"description": "Get the current weather in a location",
"input_schema": {
"type": "object",
"properties": {
"location": {"type": "string"}
},
"required": ["location"]
}
}
]
response = client.messages.create(
model="claude-sonnet-4-5-20250929",
max_tokens=1024,
tools=tools,
messages=[{"role": "user", "content": "What's the weather in Tokyo?"}]
)
Claude Agent SDK
Beyond the base API, Anthropic offers agent-focused tooling. As noted on Twitter:
We have open-sourced our Claude Agents SDK Container repo which allows you to deploy the new Claude Agents SDK in a container that uses your Anthropic Max plan. Serve agents from anywhere.
Container Deployment
The Claude Agent SDK can be packaged into containers for deployment anywhere:
FROM python:3.11-slim
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY agent.py .
CMD ["python", "agent.py"]
This enables:
- Running agents on your infrastructure
- Integration with event triggers
- Connection to MCP servers
- Scaling based on demand
Integration with MCP
Claude SDK integrates natively with MCP servers:
from anthropic import Anthropic
client = Anthropic()
# Connect to MCP servers for extended capabilities
response = client.messages.create(
model="claude-sonnet-4-5-20250929",
max_tokens=1024,
mcp_servers=["file://./my-mcp-server"],
messages=[{"role": "user", "content": "Search my files for..."}]
)
Prompt Caching
Reduce costs and latency by caching common prompt prefixes:
response = client.messages.create(
model="claude-sonnet-4-5-20250929",
max_tokens=1024,
system=[
{
"type": "text",
"text": "You are a helpful assistant...",
"cache_control": {"type": "ephemeral"}
}
],
messages=[{"role": "user", "content": "..."}]
)
Computer Use (Beta)
Claude can interact with computer interfaces:
tools = [
{
"type": "computer_20241022",
"name": "computer",
"display_width_px": 1024,
"display_height_px": 768,
}
]
response = client.messages.create(
model="claude-sonnet-4-5-20250929",
max_tokens=1024,
tools=tools,
messages=[{"role": "user", "content": "Open the browser and go to..."}]
)
TypeScript SDK
Same capabilities in TypeScript:
import Anthropic from '@anthropic-ai/sdk';
const anthropic = new Anthropic();
const message = await anthropic.messages.create({
model: "claude-sonnet-4-5-20250929",
max_tokens: 1024,
messages: [
{ role: "user", content: "Hello, Claude" }
],
});
When to Use the Claude SDK
Good fit:
- Building Claude-specific applications
- Need direct API access without abstractions
- Using Claude-specific features (prompt caching, computer use)
- Deploying containerized agents
Consider alternatives when:
- Need multi-provider flexibility (use Vercel AI SDK)
- Building complex orchestration (use LangGraph)
- Want higher-level abstractions
Claude Code Integration
The SDK powers Claude Code, Anthropic's coding assistant. Features like:
- File system access
- Tool execution
- Multi-turn conversations
- Context management
Are all built on the Claude SDK primitives.
Sources
- Anthropic API Documentation — Official docs
- GitHub: anthropics/anthropic-sdk-python — Python SDK
- GitHub: anthropics/anthropic-sdk-typescript — TypeScript SDK
See also: MCP Servers · OpenAI Agents SDK · Tools & Function Calling