Claude Agent SDK Python
ActiveDescription
Official Python SDK from Anthropic for building Claude-powered AI agents with tool use, multi-turn conversations, and agent orchestration.
Key Features
- Bundled Claude Code CLI — no separate installation required; SDK uses the bundled CLI by default
- In-Process MCP Tools — define custom tools as Python functions running as in-process MCP servers, eliminating subprocess overhead
- Hooks System — intercept and control agent behavior at specific loop points with deterministic processing and automated feedback
- Permission Control — allowed_tools, disallowed_tools, and permission_mode for fine-grained tool access management
- Bidirectional Conversations — ClaudeSDKClient supports interactive multi-turn conversations with tool use and streaming
- Error Hierarchy — structured error types for CLI not found, connection issues, process failures, and JSON decode errors
Use Cases
Categories
Quick Start
Install with pip install claude-agent-sdk (Python 3.10+). Quick start: import anyio and query from claude_agent_sdk, then run async for message in query(prompt='What is 2 + 2?'): print(message). The CLI is bundled — no separate install needed.