Claude Agent SDK for Python
Call Claude Code from Python to build asynchronous and interactive agent workflows with extensible tools.
- Source repo
- anthropics/claude-agent-sdk-python
- Stars
- ★ 8.7k
- Last updated
- 1d ago v0.2.189
- FARS reviewed
- Nov 08, 2026 +10 new
- License
- MIT
- Primary language
- Python
- FA score
- 61/100 · Some gaps
At a glance
- How it runs
- Works with
- Platform-specificClaude CodeClaude API (Partial support)
- Setup effort
- Low · running in minutes
- You'll need
- Typical use
- Python application developers adding Claude Code queries to an existing application.
- Not a fit if
- Teams needing a provider-agnostic SDK
- Teams that cannot run the Claude Code CLI
- Maintenance
- Commits in the last 30 dayslast commit 2026-12-03latest release v0.2.189 (2026-11-25)+7.3 ★/day over 7 days
- Source review
- 61/100 · Some gaps
What does this agent do, and when should you use it?
This SDK provides an async Python interface for calling Claude Code and requires Python 3.10 or later. query() returns an asynchronous iterator of response messages for one-off requests, while ClaudeSDKClient supports bidirectional conversations and Python-defined custom tools and hooks. The package bundles the Claude Code CLI by default, with options to use a system installation or set a custom path. Claude can use the Claude Code toolset, and applications process the resulting messages and content blocks. The SDK is tied to the Claude Code ecosystem; the README does not state model usage prices or credential requirements.
After installing claude-agent-sdk, a Python program can send a prompt to Claude Code with query(prompt=...) and asynchronously read response messages. ClaudeAgentOptions configures the working directory, system prompt, turn limit, tool approvals, and permission mode. For interactive sessions, ClaudeSDKClient sends queries and receives responses; @tool and create_sdk_mcp_server register in-process Python tools, while hooks run deterministic logic at specific points in the agent loop. Applications can inspect types such as AssistantMessage and TextBlock, and catch CLI connection, process, result, or JSON decoding errors.
- Python application developers adding Claude Code queries to an existing application.
- Teams processing response messages in interactive Claude Code sessions.
- Teams exposing existing Python functions as in-process MCP tools for Claude to call.
- Engineering teams applying deterministic checks or blocking logic before tools such as Bash run.
Key setup facts
Pulled from the install and usage notes below. The project README has the current values.
- Install / run
pip install claude-agent-sdk
- Runtime
- Python 3.10+
How do you install or deploy this agent?
Requires Python 3.10+. The package bundles the Claude Code CLI automatically. If you prefer a system installation or a specific version, install the CLI separately or set its path with ClaudeAgentOptions(cli_path=...).
How do you use this agent?
Minimal async invocation:
pip install claude-agent-sdkimport 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)Safety boundaries, hardening & integrations
Operational blast radius, source-verified safety controls, and first-run hardening steps before connecting this agent to real workspaces.
Declared capability surface (blast radius)
Can run terminal commands; pair with approval gates or container/OS sandboxing.
Modifies local files; work on a clean Git branch or dedicated worktree.
Makes outbound requests; verify telemetry settings and model data routing on private repos.
Inherits capabilities of connected MCP servers; audit third-party servers before enabling.
What are this agent's strengths and limitations?
query()provides a straightforward async message stream for embedding in Python programs.ClaudeSDKClientsupports bidirectional conversations, Python-defined custom tools, and hooks.- The Claude Code CLI is bundled by default, and a custom CLI path can be configured.
- Core calls depend on the Claude Code CLI and ecosystem, limiting provider portability.
- Requires Python 3.10 or later.
- The README does not specify model usage costs, credentials, or offline operation, so adopters need to verify those conditions.
How does this agent compare with similar options?
Key facts side by side with the most closely related agents.
| Agent | Source review | Form / cost | Stars | Updated | Language | Full support on |
|---|---|---|---|---|---|---|
| Claude Agent SDK for Python This agent | 61 · Some gaps | Library / SDK | ★ 8.7k | 1d ago | Python | Claude Code |
| Agno Agent Platform | 55 · Major gaps | FrameworkFree + model costs | ★ 43k | today | Python | — |
| Promptise Foundry | 81 · Good | Library / SDKFree + model costs | ★ 898 | 1d ago | Python | Claude.ai · OpenAI API · Claude API |
| OpenAI Agents SDK | 76 · Good | Library / SDKFree + model costs | ★ 31k | today | Python | OpenAI API |
How does FollowAgents rate this agent?
Why each dimension lost points
The README explains that allowed_tools auto-approves listed tools, while unlisted tools are decided by permission_mode and can_use_tool, and notes that the default toolset includes Bash and Write. This makes permissions and data flow more transparent, but the example enables acceptEdits and does not demonstrate default human confirmation or recovery, so least privilege, confirmation, external effects, and rollback are only partially addressed. The visible workflow guidance describes credential isolation, minimal permissions, and avoiding token output, but the packet lacks enough runtime product code to assess sensitive-data handling. Dependencies have version ranges; workflow build dependencies are hash-locked, but the material does not establish a complete dependency-security review. The README and project metadata clearly attribute the SDK and point to Anthropic documentation and issue tracking.
The README gives concrete descriptions of query, the client, error types, and CLI version requirements. pyproject lists runtime dependencies and Python versions, and the test samples cover build-script version pinning and platform tags, offering some corroboration. Scores are limited because the supplied source and tests are samples and cannot establish all implementation details or runtime outcomes; error types are described, but not every failure path is shown.
The SDK targets Python developers and documents one-shot queries, interactive clients, custom tools, hooks, working directories, and custom prompts. It clarifies that allowed_tools is an auto-approval list rather than a way to remove tools, identifies disallowed_tools for blocking tools, and documents prompt snapshot behavior and CLI version requirements. The packet does not include enough product code to assess all capability boundaries, and environment support is mainly evidenced through Python versions, platform builds, and some CLI configuration.
The README is organized around installation, quick start, tools, hooks, types, error handling, and development, with examples, migration notes, and prompt snapshot guidance. pyproject and LICENSE explicitly provide MIT terms, earning full marks for license. The package and CLI versions, release steps, and some build conventions are documented and sampled tests cover parts of them. The packet does not show a complete FAQ, limitations list, or full changelog; Anthropic authorship, the official repository, and the release workflow indicate maintenance responsibility, but no specific maintenance commitment is shown.
The SDK provides asynchronous message streaming, interactive sessions, hooks, and in-process custom tools. Its examples show usable interfaces and a clear role for integrating Claude Code into Python applications. The packet provides no quantitative cost, performance, or suitability comparisons, and the practical value and risk of its broad default tool capabilities depend on application configuration.
The README links major interfaces to source files and documentation; pyproject supplies dependency, version, and project metadata; and the test samples contain readable assertions for some build behavior. This provides limited cross-file support. The evidence packet is a sample, this review did not execute code, and not every documented feature can be cross-checked against the supplied source or tests.
- The default toolset includes capabilities such as Bash, Write, and Edit, and allowed_tools auto-approves listed tools. Integrators should carefully configure the approval list, permission_mode, can_use_tool, and disallowed_tools.
- The evidence packet is a repository sample and this is a static review; runtime behavior and the complete dependency-security state were not established.
Recent releases
Latest entries from the project's GitHub Releases. Notes are quoted from upstream as written, not rewritten or tested by FollowAgents.
-
Release notes excerpt
--- PyPI: https://pypi.org/project/claude-agent-sdk/0.2.189/ ```bash pip install claude-agent-sdk==0.2.189 ```View on GitHub ↗ -
Release notes excerpt
--- PyPI: https://pypi.org/project/claude-agent-sdk/0.2.188/ ```bash pip install claude-agent-sdk==0.2.188 ```View on GitHub ↗ -
Release notes excerpt
--- PyPI: https://pypi.org/project/claude-agent-sdk/0.2.187/ ```bash pip install claude-agent-sdk==0.2.187 ```View on GitHub ↗
FAQ
Do I need to install the Claude Code CLI separately?
ClaudeAgentOptions(cli_path=...).How do query() and ClaudeSDKClient differ?
query() returns an async iterator of response messages. ClaudeSDKClient supports bidirectional conversations and adds custom tools and hooks.How can I control which tools Claude uses?
allowed_tools auto-approves listed tools; it does not remove other tools from the toolset. Unlisted tools are handled by permission_mode and can_use_tool. Use disallowed_tools to block specific tools.Which errors can the SDK report?
CLINotFoundError, CLIConnectionError, ProcessError, ResultError, and CLIJSONDecodeError.Thanks — we use this to improve the page.
Subscribe to the FollowAgents RSS feed, or save this agent to your browser shortlist to compare on your next visit.