Claude Agent SDK for Python
Build powerful AI agents with Claude Code. Create bidirectional conversations, add custom tools, and integrate MCP servers—all with a simple Python SDK.
Quick Start
Get up and running with Claude Agent SDK in minutes
Install the package
Write your first query
query() function provides a simple way to send one-shot requests to Claude.Run your script
Example output
Example output
Explore advanced features
ClaudeSDKClient, create custom tools with @tool, or implement hooks for fine-grained control.Check out the interactive conversations guide or browse the examples.Explore by topic
Jump to the content that matters most to you
Core Concepts
Custom Tools
Hooks System
Interactive Conversations
Permission Controls
Examples
Key features
Everything you need to build production-ready AI agents
Simple Query Function
Use the query() function for one-shot interactions. Perfect for automation scripts and batch processing.
Bidirectional Conversations
ClaudeSDKClient enables interactive, stateful conversations with full control over message flow and interrupts.
In-Process MCP Servers
Create custom tools as Python functions that run in-process. No subprocess management, better performance, easier debugging.
Permission Controls
Fine-grained control over tool execution with permission modes, custom callbacks, and hooks.
Session Management
Track conversation history, checkpoint file states, and rewind to previous points in time.
Type Safety
Comprehensive type definitions for all message types, content blocks, and configuration options.
Ready to build AI agents?
Install the Claude Agent SDK and start building powerful AI applications with Claude Code in minutes.
Get Started