claude-code-sdk
Python SDK for Claude Code
What it is and what it does
Claude Code SDK is a Python wrapper for querying Claude Code, an AI agent that can read, write, and execute code. It provides both a simple async query interface and a more advanced client for bidirectional conversations with custom tools and lifecycle hooks. The package depends on anyio for async I/O, mcp for Model Context Protocol support, and typing-extensions for type hints.
The SDK is officially deprecated and no longer maintained; Anthropic recommends migrating to claude-agent-sdk. It supports Python 3.10 through 3.13 and is distributed as a pure wheel with low install friction. While the repository remains active and has accumulated significant GitHub stars, new projects should use the successor package.
Use it for:
- Query Claude Code for code generation or analysis tasks via a simple async interface.
- Build interactive agents that maintain bidirectional conversation state with Claude Code.
- Define custom tools as Python functions and expose them to Claude via in-process MCP servers.
- Implement hooks to intercept and validate tool use (e.g., blocking unsafe bash commands before execution).
- Migrate from external MCP server processes to in-process tool definitions for simpler deployment.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Python SDK for querying Claude Code and building interactive agents with custom tools and hooks, now deprecated in favor of claude-agent-sdk.
No—the package is officially deprecated and no longer maintained. Install claude-agent-sdk instead. If you have an existing codebase using claude-code-sdk, plan a migration to the successor package rather than starting new projects with this one.
Install
claude-code-sdk on PyPI
pip
pip install claude-code-sdkuv
uv add claude-code-sdkpoetry
poetry add claude-code-sdkInstalling claude-code-sdk
Before you install
Low install friction with a pure-wheel distribution. Active maintenance as of the latest release, though the package is officially deprecated and no longer maintained—users should migrate to claude-agent-sdk.
License in practice
MIT license permits unrestricted use, modification, and distribution with minimal obligations, making it suitable for both open-source and commercial projects.
Quickstart
pip install claude-code-sdk
import anyio
from claude_code_sdk import query
async def main():
async for message in query(prompt="What is 2 + 2?"):
print(message)
anyio.run(main())
Requires Python 3.10+, Node.js, and Claude Code installed via npm (npm install -g @anthropic-ai/claude-code).
Verify before relying
- Whether claude-agent-sdk is a direct drop-in replacement or requires code changes.
- Current status of the Claude Code CLI and whether it remains actively maintained.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 3 — anyio, mcp, typing-extensions |
| Maintenance | actively maintained — 319 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 624,903/month — #5,698 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: claude_code_sdk-0.0.25-py3-none-any.whl
Keywords: ai, anthropic, claude, sdk
Tags
More Artificial Intelligence packages
LiteLLM provides a unified Python interface to…
permissive · top 100 on PyPI
huggingface-hubClient library and CLI tool for downloading,…
permissive · top 100 on PyPI
langchainLangChain provides a framework for building…
permissive · top 1,000 on PyPI
hf-xethf-xet provides chunk-based deduplication and…
permissive · top 1,000 on PyPI
tokenizersTokenizers converts raw text into token…
permissive · top 1,000 on PyPI
transformersTransformers provides a unified framework for…
permissive · top 1,000 on PyPI
claude-agent-sdkPython SDK for building and interacting with…
permissive · top 1,000 on PyPI
anthropicProvides Python bindings to the Claude API,…
permissive · top 1,000 on PyPI
openinference-instrumentation-claude-agent-sdkAuto-instruments Claude Agent SDK calls to emit…
permissive · top 15,000 on PyPI
llm-anthropicA plugin for the LLM command-line tool that…
permissive · top 15,000 on PyPI
claude-tapclaude-tap is a local proxy and trace viewer…
permissive · top 15,000 on PyPI
pydantic-deepA Python framework and terminal assistant for…
permissive · top 15,000 on PyPI
livekit-plugins-anthropicIntegrates Anthropic's Claude models into…
permissive · top 5,000 on PyPI
langchain-anthropicProvides LangChain integration for Anthropic's…
permissive · top 1,000 on PyPI
agent-framework-claudeIntegrates Claude with Microsoft Agent…
permissive · top 15,000 on PyPI
trinity-agentTrinity orchestrates multiple AI coding agents…
permissive · top 15,000 on PyPI