claude-agent-sdk
Python SDK for Claude Code
Decision gist · record as of 2026-08-14
Yes, if you need programmatic control over Claude Code from Python. The SDK is actively maintained (release 1 day old), has no known vulnerabilities, and offers both simple query and advanced multi-turn/custom-tool patterns. Medium install friction is acceptable for a modern async library. MIT license imposes no restrictions. Start with the simple `query()` function; graduate to `ClaudeSDKClient` and custom tools if you need stateful conversations or tool integration.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.10 or later.
- Claude Code CLI is bundled automatically, but you can optionally specify a custom path via ClaudeAgentOptions.
- Medium install friction due to platform-specific wheels (macOS arm64/x86_64, Linux aarch64/x86_64, Windows amd64) and four runtime dependencies.
License · maintenance · safety
MIT (permissive) — MIT license is permissive; you can use, modify, and distribute this package freely with minimal restrictions.
last release 2026-08-13 (1 days) · last repo commit 2026-08-13 · 7,882 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 30,203,813 downloads/mo, #804 on PyPI
Alternatives
Verify before relying
pip install claude-agent-sdk
import anyio
from claude_agent_sdk import query
async def main():
async for message in query(prompt="What is 2 + 2?"):
print(message)
anyio.run(main)- Whether the bundled Claude Code CLI requires additional system dependencies or environment setup beyond Python 3.10+
- Performance characteristics and latency of in-process MCP servers versus external subprocess servers
- Compatibility with async frameworks other than anyio
What it is and what it does
Claude Agent SDK is a Python library for programmatic interaction with Claude Code, Anthropic's AI coding assistant. It exposes two main interfaces: a simple `query()` function for one-off prompts and a stateful `ClaudeSDKClient` for multi-turn conversations. The SDK runs on top of four runtime dependencies (anyio, mcp, sniffio, typing-extensions) and requires Python 3.10+.
The package's distinguishing feature is support for in-process MCP (Model Context Protocol) servers—custom tools defined as Python functions that Claude can invoke directly within your application, without spawning separate processes. You can also define hooks to intercept and control Claude's behavior at specific points in the agent loop (e.g., blocking unsafe bash commands). The SDK handles tool permission management, working directory context, and message streaming natively.
Use it for
- Build a chatbot or code-generation tool that delegates file operations and bash execution to Claude with fine-grained permission controls.
- Define custom Python functions as tools and let Claude call them autonomously during multi-turn problem-solving conversations.
- Intercept tool use requests via hooks to enforce security policies (e.g., block certain bash patterns or file paths) before Claude executes them.
- Integrate Claude Code into an existing Python application without managing separate MCP server processes.
- Stream Claude's responses and tool invocations in real time to a user interface or logging system.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, if you need programmatic control over Claude Code from Python.
The SDK is actively maintained (release 1 day old), has no known vulnerabilities, and offers both simple query and advanced multi-turn/custom-tool patterns. Medium install friction is acceptable for a modern async library. MIT license imposes no restrictions. Start with the simple `query()` function; graduate to `ClaudeSDKClient` and custom tools if you need stateful conversations or tool integration.
Install
claude-agent-sdk on PyPI
Before you install
Medium install friction due to platform-specific wheels (macOS arm64/x86_64, Linux aarch64/x86_64, Windows amd64) and four runtime dependencies. Active maintenance with release 1 day old and 7882 repository stars suggest solid ongoing support.
Requires Python 3.10 or later. Claude Code CLI is bundled automatically, but you can optionally specify a custom path via ClaudeAgentOptions.
License in practice
MIT license is permissive; you can use, modify, and distribute this package freely with minimal restrictions.
Quickstart
pip install claude-agent-sdk
import anyio
from claude_agent_sdk import query
async def main():
async for message in query(prompt="What is 2 + 2?"):
print(message)
anyio.run(main)
Verify before relying
- Whether the bundled Claude Code CLI requires additional system dependencies or environment setup beyond Python 3.10+
- Performance characteristics and latency of in-process MCP servers versus external subprocess servers
- Compatibility with async frameworks other than anyio
Package facts
| License | MIT permissive |
| Python support | Supports the current Python release >=3.10 |
| Install friction | Medium. Platform-specific wheel |
| Runtime dependencies | 4 packagesanyiomcpsniffiotyping-extensions |
| Maintenance | Actively maintained 1 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 30,203,813 / month, #804 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 3 - AlphaIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Typing :: Typed |
Evidence: claude_agent_sdk-0.2.138-py3-none-macosx_11_0_arm64.whl; claude_agent_sdk-0.2.138-py3-none-macosx_11_0_x86_64.whl; claude_agent_sdk-0.2.138-py3-none-manylinux_2_17_aarch64.whl; claude_agent_sdk-0.2.138-py3-none-manylinux_2_17_x86_64.whl; claude_agent_sdk-0.2.138-py3-none-win_amd64.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
An agent finds packages by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language. Give your agent the search over MCP.
More Artificial Intelligence packages
LiteLLM provides a unified Python interface to call 100+ LLM providers (OpenAI, Anthropic, Gemini, Bedrock, Azure, and others) using OpenAI-compatible API format, available as both a Python SDK and a self-hosted AI Gateway proxy server.
Install it if you need to work with multiple LLM providers or want to centralize LLM routing in your organization.
Client library and CLI tool for downloading, uploading, and managing models, datasets, and repositories on the Hugging Face Hub platform.
Install it if you work with Hugging Face Hub models or datasets.
LangChain provides a framework for building agents and LLM-powered applications by composing language models, tools, and memory through a unified API that abstracts over multiple model providers.
hf-xet provides chunk-based deduplication and efficient file transfer for the Hugging Face Hub, enabling faster uploads and downloads of large files with local disk caching.
Tokenizers converts raw text into token sequences for NLP models, with support for training custom vocabularies and using pre-built tokenizers (BPE, WordPiece) optimized for speed via Rust.
Transformers provides a unified framework for loading, fine-tuning, and running state-of-the-art pretrained models across text, vision, audio, video, and multimodal tasks using PyTorch, JAX, or TensorFlow.
Install it if you need to run or train any transformer-based model for NLP, vision, audio, or multimodal tasks.
See also claude-code-sdk · openinference-instrumentation-claude-agent-sdk · anthropic · pydantic-deep · llm-anthropic · pysae-ai-tools · mcp-server-odoo · blender-mcp · pagerduty-mcp · livekit-plugins-anthropic