Claude Agent SDK
Build production AI agents with Claude Code as a library, programmable in Python and TypeScript with built-in tools, hooks, subagents, MCP, and sessions.
At a Glance
About Claude Agent SDK
Claude Agent SDK
The Claude Agent SDK is Anthropic's official library for building production AI agents using the same agent loop, built-in tools, and context management that power Claude Code. It is available for Python and TypeScript, and was renamed from the Claude Code SDK to reflect its broader use beyond coding tasks.
What it does
The SDK lets developers create autonomous agents that can read files, run shell commands, search and edit code, browse the web, and call external systems. Instead of implementing a tool execution loop manually, the SDK runs the loop for you while Claude decides which tools to invoke. A simple query() call streams messages back as the agent works, and ClaudeAgentOptions controls which tools are allowed, how permissions are handled, and how sessions persist.
Built-in tools
Out of the box the agent has access to Read, Write, Edit, Bash, Monitor, Glob, Grep, WebSearch, WebFetch, and AskUserQuestion. These cover most file, shell, and web tasks without any extra setup, so an agent can start working on a real codebase immediately.
Extensibility
The SDK supports the Model Context Protocol so agents can connect to external services like Playwright, databases, and APIs. Developers can also define custom tools as in-process Python or TypeScript functions, configure subagents with their own prompts and tool sets, and load filesystem-based configuration from .claude/ directories including Skills, slash commands, memory files, and plugins.
Control and observability
Hooks let you run custom code at lifecycle events such as PreToolUse, PostToolUse, Stop, SessionStart, SessionEnd, and UserPromptSubmit, which is useful for validation, logging, or blocking actions. Permissions control which tools can run automatically and which require approval. Sessions can be resumed or forked to continue work or explore alternative paths, and OpenTelemetry-based observability and cost tracking are supported.
Authentication
The SDK authenticates with an Anthropic API key. It also supports Amazon Bedrock, Google Vertex AI, and Microsoft Azure AI Foundry through environment variable flags, so the same agent code can run against any of these providers.
How it fits in
The Agent SDK runs in your own process and works on files in your infrastructure, which makes it a good fit for local prototyping, CI/CD pipelines, and production automation. Anthropic's separate Managed Agents product handles the sandbox and session storage for you, so a common path is to prototype with the Agent SDK and graduate to Managed Agents for hosted, long-running production workloads.
Who it's for
It's aimed at developers building business agents, specialized coding agents, or domain-specific assistants who want Claude Code's underlying engine without the CLI wrapper.
Community Discussions
Be the first to start a conversation about Claude Agent SDK
Share your experience with Claude Agent SDK, ask questions, or help others learn from your insights.
Pricing
Open SDK
The Claude Agent SDK package is free to install and use. Running an agent consumes Anthropic API credits, billed separately by the underlying provider.
- Free Python (pip) and TypeScript (npm) packages
- All built-in tools, hooks, subagents, MCP, and sessions included
- Authenticate via Anthropic API, Amazon Bedrock, Google Vertex AI, or Microsoft Azure AI Foundry
- API or third-party provider usage billed separately
Capabilities
Key Features
- Agent loop with built-in tool execution (Read, Write, Edit, Bash, Glob, Grep, WebSearch, WebFetch, Monitor, AskUserQuestion)
- Python and TypeScript libraries with the same capabilities
- Hooks for PreToolUse, PostToolUse, Stop, SessionStart, SessionEnd, and UserPromptSubmit lifecycle events
- Subagent support with custom prompts and scoped tool sets
- Model Context Protocol (MCP) integration for external tools and services
- Custom tools defined as in-process Python or TypeScript functions
- Permission controls for tool allow/deny and approval prompts
- Sessions with resume and fork for multi-turn context
- Filesystem configuration via .claude/ for Skills, slash commands, memory, and plugins
- Streaming and single-mode input, plus structured output support
- File checkpointing to rewind agent edits
- OpenTelemetry observability and cost and usage tracking
- Authentication via Anthropic API, Amazon Bedrock, Google Vertex AI, or Microsoft Azure AI Foundry
