Claude Agent SDK

Anthropic's own agent-building library — the same agent loop, tools and context management that power Claude Code, for Python and TypeScript. Claude-only, with no multi-provider escape hatch.

Best forDevelopers already building on Claude (or Claude Code) who want its exact agent loop, tools and context management as a callable library, and are comfortable being single-vendor on Anthropic in exchange for the tightest possible integration with Claude Code's own capabilities.

Visit Claude Agent SDK Compare

Our verdict

The Claude Agent SDK is Anthropic's answer to the same question Microsoft, Google and OpenAI have already answered with their own official SDKs — but it takes the most tightly-integrated, least model-agnostic approach of the four.

Anthropic's own agent-building library — the literal Claude Code harness exposed as code, with the tightest single-vendor integration in this category's four major-lab SDKs, and the only one of the four with no supported path to another model provider.

The Agents Index digest

New agents, fresh verdicts, and who's earning the top spots. One short email.

Screenshot of Claude Agent SDK
Claude Agent SDK, captured at verification, . Click to enlarge.

What's great

  • Built on the exact agent harness, tool loop and context management that power Claude Code itself, not a reimplementation — every capability documented for Claude Code (file edits, bash, web search/fetch, memory) is available as a library call.
  • A genuine self-host-or-managed choice: self-host the subprocess with a documented hosting cookbook for Docker, Kubernetes and sandbox providers (Modal, E2B, Fly Machines, Cloudflare Sandboxes), or hand the same workload to Claude Managed Agents, Anthropic's own hosted REST API, with no infrastructure to operate.
  • Actively developed with a public changelog on both language SDKs and features still shipping — Agent Skills extend Claude's capabilities and load automatically from .claude/, the same way Claude Code loads them.
  • In-process custom tools (the @tool decorator plus an SDK MCP server) avoid the subprocess-management overhead of running a separate external MCP server for simple custom tools.

Watch-outs

  • Claude models only, with no supported multi-provider escape hatch — unlike this category's other three major-lab SDKs (OpenAI Agents SDK, Google ADK, Microsoft Agent Framework), all of which reach other vendors' models through a LiteLLM-style integration. A GitHub issue asking Anthropic to support non-Anthropic models was closed "not planned."
  • Not fully open source despite the MIT license on the two wrapper packages: Anthropic's own docs state overall SDK use is governed by its Commercial Terms of Service, and the compiled Claude Code CLI binary the wrapper bundles and spawns as a subprocess isn't published as source — the same "client is open, the engine underneath isn't" shape as Warp's terminal client versus its closed Oz cloud-agent platform.
  • Anthropic changed programmatic-usage billing twice within about six weeks in 2026 and reversed a planned split onto a separate "Agent SDK credit" on the day it was due to take effect (June 15) after user backlash — a real signal the pricing terms for SDK usage aren't fully settled yet.
  • Every running agent is a long-lived subprocess tied to local disk state by default (session transcripts, CLAUDE.md memory) — none of it survives a container restart without wiring up a separate SessionStore adapter yourself, real production plumbing a hosted-first competitor may not require for a basic deployment.

Also note: No supported path to run non-Anthropic models through the SDK's own agent loop — teams that need genuine multi-provider flexibility need a different framework. · No top-level session timeout and no per-subagent wall-clock deadline by default — Anthropic's own hosting docs flag both as known limitations to plan around with maxTurns and a stall watchdog.

How Claude Agent SDK compares

The other agents buyers weigh against Claude Agent SDK, and when to pick each.

AgentBest when you want…
Claude Agent SDKThis pageDevelopers already building on Claude (or Claude Code) who want its exact agent loop, tools and context management as a callable library, and are comfortable being single-vendor on Anthropic in exchange for the tightest possible integration with Claude Code's own capabilities.
OpenAI Agents SDKA lighter-weight official SDK from another major lab that IS genuinely multi-provider through LiteLLM — for teams that don't want to be single-vendor on Anthropic.
Google Agent Development KitGoogle's own official SDK, spanning four languages and genuinely model-agnostic (Gemini, Claude, GPT and more via LiteLLM) — for teams that want a major-lab SDK without the single-vendor lock-in.
LangChainThe largest, most battle-tested third-party ecosystem (142k+ GitHub stars), fully model-agnostic by design — for teams not specifically committed to building on Claude.

What is Claude Agent SDK?

The Claude Agent SDK is Anthropic's own library for building custom, production-grade AI agents in Python or TypeScript — built on top of the same agent harness, tool loop and context management that power Claude Code, exposed as code you call directly rather than a CLI you type into. It ships two APIs (a one-shot query() function and a stateful ClaudeSDKClient for multi-turn sessions), the full Claude Code toolset (file read/write/edit, bash execution, web search and fetch), hooks that intercept agent behavior at each step, subagents for delegating focused subtasks, and native Model Context Protocol (MCP) support for both in-process and external tool servers. Unlike this category's other major-lab SDKs — OpenAI Agents SDK, Google ADK and Microsoft Agent Framework all reach other model providers through a LiteLLM-style integration — the Claude Agent SDK runs Claude models only; a GitHub issue asking Anthropic to support other providers was closed as "not planned." The Python and TypeScript wrapper packages themselves carry an MIT license, but Anthropic's own docs state that use of the SDK as a whole is governed by its Commercial Terms of Service, and the compiled Claude Code CLI binary the wrapper bundles and spawns as a subprocess isn't published as source — so it doesn't clear this index's bar for a genuinely, fully self-hostable open-source tool.

What does Claude Agent SDK do?

Calling query() spawns a claude CLI subprocess over stdio and streams back an async iterator of messages for a one-off task; ClaudeSDKClient holds that subprocess open across turns for an interactive, stateful conversation. The agent gets Claude Code's full built-in toolset by default — file read/write/edit, bash execution, web search and fetch — gated per-call by allowed_tools/disallowed_tools allowlists or a broader permission_mode. You can define your own tools as plain Python or TypeScript functions with the @tool decorator and mount them as an in-process MCP server (no subprocess management), or connect external MCP servers the same way Claude Code does. Hooks let you intercept and approve or block specific tool calls (e.g. every Bash command) before they run, and subagents let one session spawn focused specialist agents for a subtask. For production you either self-host the subprocess yourself — Anthropic's hosting docs cover session persistence, scaling and multi-tenant isolation across Docker/Kubernetes/sandbox providers like Modal, E2B and Fly Machines — or hand the whole thing to Claude Managed Agents, a separate Anthropic-hosted REST API where Anthropic runs the agent and the sandbox and your app just sends events and streams results back, with no infrastructure of your own to operate.

How Claude Agent SDK works

  1. Install the SDK (pip install claude-agent-sdk or npm install @anthropic-ai/claude-agent-sdk) and set ANTHROPIC_API_KEY — the package bundles a matching Claude Code CLI binary, no separate install.
  2. Call query() for a one-shot task, or open a ClaudeSDKClient session for a multi-turn, stateful conversation — either spawns a claude CLI subprocess and streams back messages.
  3. Grant the built-in Claude Code toolset (files, bash, web search/fetch) via allowed_tools, or define custom tools with the @tool decorator and mount them as an in-process MCP server; add hooks to approve or block specific tool calls.
  4. Deploy by self-hosting the subprocess on your own infrastructure (Docker, Kubernetes, or a sandbox provider like Modal or E2B), or route the same workload to Claude Managed Agents, a separate Anthropic-hosted REST API, for zero infrastructure to operate.

Who is Claude Agent SDK for?

  • Developers who already use Claude Code and want the same agent loop, tools and context management as a library inside their own application, not just a terminal tool
  • Teams building a single-vendor Claude-based agent who don't need multi-provider flexibility — the tradeoff for the SDK's tight integration with Claude Code's own toolset
  • Teams that want to skip building the agent loop, tool execution and context management themselves and are comfortable running a subprocess-based architecture (or handing that off entirely to Claude Managed Agents)

Key features

  • Two APIs: query() and ClaudeSDKClient: A simple async query() function for one-off tasks, and a stateful ClaudeSDKClient for interactive, multi-turn sessions that hold the same subprocess open across exchanges.
  • Full Claude Code toolset by default: File read/write/edit, bash execution, and web search/fetch are available out of the box, gated per-call by allow/deny lists or a broader permission mode.
  • In-process custom tools (SDK MCP servers): Define Python or TypeScript functions as tools with the @tool decorator and mount them as an in-process MCP server — no subprocess management, faster and easier to debug than an external MCP server.
  • Hooks: Intercept agent behavior at specific lifecycle points — e.g. approve or block a specific Bash command before it runs — for custom guardrails the built-in permission system alone doesn't cover.
  • Subagents: Spawn specialized agents for focused subtasks from within a session, rather than hand-rolling task delegation yourself.
  • Claude Managed Agents (optional hosted layer): A separate Anthropic-hosted REST API — Anthropic runs the agent and the sandbox, your app sends events and streams results, for teams that don't want to operate subprocess hosting infrastructure themselves.

What are Claude Agent SDK's use cases?

  • Bug-fixing agent embedded in an internal tool: A team wires query() into an internal dashboard so an engineer can describe a bug and the agent reads the repo, proposes a fix and opens a draft PR — the same quickstart Anthropic's own docs walk through.
  • Long-running triage agent: An email or support-ticket triage agent runs as a long-lived ClaudeSDKClient session per user, held open across many turns, deployed as a persistent container per Anthropic's own 'long-running sessions' hosting pattern.
  • Skip self-hosting entirely: A team that doesn't want to operate subprocess infrastructure, session persistence or multi-tenant isolation routes the same agent code to Claude Managed Agents instead, trading some infrastructure control for zero hosting to operate.

What does Claude Agent SDK integrate with?

  • Model Context Protocol (MCP) — both in-process SDK servers and external MCP servers
  • Claude Managed Agents (Anthropic-hosted REST API deployment target)
  • Sandbox/hosting providers: Modal, Cloudflare Sandboxes, Daytona, E2B, Fly Machines, Vercel Sandbox
  • OpenTelemetry (OTLP traces, metrics and logs export)
  • Amazon Bedrock and Google Cloud regional endpoints (via ANTHROPIC_BASE_URL routing)

Why use Claude Agent SDK?

  • Anthropic's own official library, built on the same agent harness that powers Claude Code itself — not a third-party wrapper reverse-engineering Claude's tool-calling behavior.
  • The full built-in Claude Code toolset (files, bash, web search/fetch) plus native MCP support ships by default — you're not rebuilding a tool loop or a permissions layer from scratch.
  • A genuine choice between self-hosting the subprocess yourself (with a documented cookbook for Docker/Kubernetes/sandbox providers) or handing the whole thing to Claude Managed Agents, Anthropic's own hosted REST API — the same 'self-host or managed' shape this category's other major-lab SDKs offer.
  • Actively developed and dated: Agent Skills shipped as a new capability, and Anthropic reversed a controversial June 2026 billing change (a separate 'Agent SDK credit') within a day of it taking effect after user backlash — a vendor that responds fast, if also one that changes billing terms with real turbulence.

Pros & cons

Pros

  • Built on the exact agent harness, tool loop and context management that power Claude Code itself, not a reimplementation — every capability documented for Claude Code (file edits, bash, web search/fetch, memory) is available as a library call.
  • A genuine self-host-or-managed choice: self-host the subprocess with a documented hosting cookbook for Docker, Kubernetes and sandbox providers (Modal, E2B, Fly Machines, Cloudflare Sandboxes), or hand the same workload to Claude Managed Agents, Anthropic's own hosted REST API, with no infrastructure to operate.
  • Actively developed with a public changelog on both language SDKs and features still shipping — Agent Skills extend Claude's capabilities and load automatically from .claude/, the same way Claude Code loads them.
  • In-process custom tools (the @tool decorator plus an SDK MCP server) avoid the subprocess-management overhead of running a separate external MCP server for simple custom tools.

Cons

  • Claude models only, with no supported multi-provider escape hatch — unlike this category's other three major-lab SDKs (OpenAI Agents SDK, Google ADK, Microsoft Agent Framework), all of which reach other vendors' models through a LiteLLM-style integration. A GitHub issue asking Anthropic to support non-Anthropic models was closed "not planned."
  • Not fully open source despite the MIT license on the two wrapper packages: Anthropic's own docs state overall SDK use is governed by its Commercial Terms of Service, and the compiled Claude Code CLI binary the wrapper bundles and spawns as a subprocess isn't published as source — the same "client is open, the engine underneath isn't" shape as Warp's terminal client versus its closed Oz cloud-agent platform.
  • Anthropic changed programmatic-usage billing twice within about six weeks in 2026 and reversed a planned split onto a separate "Agent SDK credit" on the day it was due to take effect (June 15) after user backlash — a real signal the pricing terms for SDK usage aren't fully settled yet.
  • Every running agent is a long-lived subprocess tied to local disk state by default (session transcripts, CLAUDE.md memory) — none of it survives a container restart without wiring up a separate SessionStore adapter yourself, real production plumbing a hosted-first competitor may not require for a basic deployment.

Limitations

  • No supported path to run non-Anthropic models through the SDK's own agent loop — teams that need genuine multi-provider flexibility need a different framework.
  • No top-level session timeout and no per-subagent wall-clock deadline by default — Anthropic's own hosting docs flag both as known limitations to plan around with maxTurns and a stall watchdog.

Claude Agent SDK pricing

  • SDK (self-hosted)Free
  • Claude API usage (pay-as-you-go)$1–$10 / MTok input, $5–$50 / MTok output / by model
  • Claude Managed Agents (hosted)Token rates + $0.08/session-hour / usage-based

See current pricing on code.claude.com ↗Compare Claude Agent SDK alternatives →

Claude Agent SDK specs

Pricing

Pricing model
freemium
Free tier
✓ Yes

Capabilities

Model / LLM
Claude only (Opus 5, Sonnet 5, Haiku 4.5 — no third-party model support)
Interface
Library
Public API
✓ Yes
Open source
✗ No

Deployment

Deployment
Both

Claude Agent SDK review

The Claude Agent SDK is Anthropic's answer to the same question Microsoft, Google and OpenAI have already answered with their own official SDKs — but it takes the most tightly-integrated, least model-agnostic approach of the four. Instead of a general-purpose agent framework that happens to support Claude, it's the literal agent harness behind Claude Code, exposed as a library: the same tools, the same agent loop, the same context management, callable from your own Python or TypeScript code, with a genuine choice between self-hosting the subprocess yourself or handing it to Claude Managed Agents, Anthropic's own hosted REST API. The tradeoff for that tight integration is real: it runs Claude models only (a GitHub issue asking for other providers was closed "not planned"), the MIT license on the wrapper packages doesn't extend to the closed-source CLI binary they bundle and spawn, and Anthropic changed how programmatic usage is billed twice in six weeks in mid-2026, reversing a planned split onto a separate credit pool on the day it was due to take effect. Pick it if you're already committed to Claude and want its exact production harness as a library rather than reimplementing a tool loop yourself; pick one of its three multi-provider siblings if vendor flexibility matters more than the depth of that integration.

Anthropic's own agent-building library — the literal Claude Code harness exposed as code, with the tightest single-vendor integration in this category's four major-lab SDKs, and the only one of the four with no supported path to another model provider.

Frequently asked questions

Is the Claude Agent SDK free?
The SDK itself has no license fee — pip install claude-agent-sdk or npm install @anthropic-ai/claude-agent-sdk are both free downloads. You pay standard Claude API token rates for what the agent actually uses (or draw on an existing Claude Pro/Max/Team/Enterprise subscription's usage limits), plus $0.08/session-hour if you run it through the separate, optional Claude Managed Agents hosted product.
Can I use the Claude Agent SDK with GPT, Gemini or another non-Anthropic model?
No — unlike OpenAI Agents SDK, Google ADK and Microsoft Agent Framework, which all reach other vendors' models through a LiteLLM-style integration, the Claude Agent SDK runs Claude models only. A GitHub issue asking Anthropic to support other providers was closed as "not planned."
Is the Claude Agent SDK open source?
Partly. The Python and TypeScript wrapper packages both carry an MIT license on GitHub, but Anthropic's own docs state that use of the SDK as a whole is governed by its Commercial Terms of Service, and the compiled Claude Code CLI binary the wrapper bundles and spawns as a subprocess isn't published as source — so the full stack isn't self-hostable-forever the way a fully open-source framework is.
What's the difference between the Claude Agent SDK and Claude Managed Agents?
The Agent SDK is a library you run yourself — it spawns and supervises a claude CLI subprocess on your own infrastructure. Claude Managed Agents is a separate, Anthropic-hosted REST API where Anthropic runs the agent and the sandbox instead, so you send events and stream back results with no hosting infrastructure of your own to operate.
How is the Claude Agent SDK different from the Claude Code CLI?
The CLI is Anthropic's terminal interface for interactive, one-off use. The Agent SDK is the same underlying agent harness exposed as a Python or TypeScript library, for building your own application or product around it rather than typing into a terminal.

Claude Agent SDK alternatives

  • OpenAI Agents SDK

    A lighter-weight official SDK from another major lab that IS genuinely multi-provider through LiteLLM — for teams that don't want to be single-vendor on Anthropic.

  • Google Agent Development Kit

    Google's own official SDK, spanning four languages and genuinely model-agnostic (Gemini, Claude, GPT and more via LiteLLM) — for teams that want a major-lab SDK without the single-vendor lock-in.

  • LangChain

    The largest, most battle-tested third-party ecosystem (142k+ GitHub stars), fully model-agnostic by design — for teams not specifically committed to building on Claude.

Get a quote from Claude Agent SDK

Tell us what you need. We make the introduction to Claude Agent SDK.

Claude Agent SDK

from Free

Visit ↗