Claude Agent SDK
PackageClaude Code's agent loop and built-in tools as a Python and TypeScript library
- Access
- Anthropic API key
About
The Claude Agent SDK packages Claude Code as a library: an agent loop with file, shell and web tools, hooks, subagents, MCP and sessions. It runs in a process you operate and works only with Claude models, billed as Claude API usage.
What you can do with it
- Build a coding agent that reads, edits and fixes files in a repo
- Automate tasks with shell commands, web search and MCP tools
- Run subagents with hooks and permission controls in your own app
Get started
- Install @anthropic-ai/claude-agent-sdk or pip install claude-agent-sdk
- Set ANTHROPIC_API_KEY in your environment
Example
import { query } from "@anthropic-ai/claude-agent-sdk";
for await (const message of query({
prompt: "Review utils.py for bugs that would cause crashes. Fix any issues you find.",
options: { allowedTools: ["Read", "Edit", "Glob"], permissionMode: "acceptEdits" },
})) {
if (message.type === "result") console.log(`Done: ${message.subtype}`);
}Details
- Hosting
- Runs locally
- Available in
- Worldwide
- Official SDKs
- Python, JavaScript/TypeScript
- MCP server
- None
- Works with
- Claude