Claude Agent SDK

The Claude Agent SDK (formerly the Claude Code SDK) is Anthropic's Python and TypeScript library that runs Claude Code's agent loop, tools, hooks, subagents and MCP support inside your own program; install it with pip install claude-agent-sdk or npm install @anthropic-ai/claude-agent-sdk.

The Claude Agent SDK is Anthropic's library for building agents on the same tools, agent loop and context management that run Claude Code, in Python (pip install claude-agent-sdk) and TypeScript (npm install @anthropic-ai/claude-agent-sdk); it was called the Claude Code SDK until Sep 29, 2025 (Agent SDK overview, Enabling Claude Code to work more autonomously, Sep 29, 2025). Unlike calling the Messages API, where your code must run every tool, the SDK reads files, runs commands and edits code itself, and you consume a stream of what it did.

Quick facts

Languages Python 3.10+, TypeScript (Node.js 18.14+)
Packages claude-agent-sdk (PyPI), @anthropic-ai/claude-agent-sdk (npm)
Latest versions Python v0.2.178, TypeScript v0.3.318 (both Nov 4, 2026)
Entry point query(); Python also has ClaudeSDKClient
Authentication Claude API key, or Amazon Bedrock, Claude Platform on AWS, Google Cloud's Agent Platform, Microsoft Foundry
Terms Anthropic's Commercial Terms of Service
Repositories anthropics/claude-agent-sdk-python, anthropics/claude-agent-sdk-typescript

Sources for the table: Agent SDK quickstart, Agent SDK overview, Python releases and TypeScript releases, read Nov 6, 2026.

What does the SDK give you?

Everything Claude Code has, as options on a function call: the built-in tools (read, write and edit files, run commands, search the web), permissions and modes, hooks as callbacks in your own code, subagents, MCP servers, sessions you can resume or fork, skills, commands and CLAUDE.md memory loaded from .claude/ folders, and plugins loaded by path. Anthropic's pages also cover custom tools, structured outputs, cost tracking, file checkpointing and hosting (Agent SDK overview, read Nov 6, 2026). Under the hood it runs the Claude Code binary, which both packages bundle, so most installs need no separate Claude Code install.

A first agent

Anthropic's quickstart builds an agent that finds and fixes crash bugs in a file. In Python:

import asyncio
from claude_agent_sdk import query, ClaudeAgentOptions, AssistantMessage, ResultMessage

async def main():
    async for message in query(
        prompt="Review utils.py for bugs that would cause crashes. Fix any issues you find.",
        options=ClaudeAgentOptions(
            allowed_tools=["Read", "Edit", "Glob"],
            permission_mode="acceptEdits",
        ),
    ):
        if isinstance(message, AssistantMessage):
            for block in message.content:
                if hasattr(block, "text"):
                    print(block.text)
        elif isinstance(message, ResultMessage):
            print(f"Done: {message.subtype}")

asyncio.run(main())

The TypeScript version is the same shape: for await (const message of query({ prompt, options: { allowedTools: ["Read", "Edit", "Glob"], permissionMode: "acceptEdits" } })). The steps:

  1. Install the package and set ANTHROPIC_API_KEY in the shell (the SDK does not read .env files on its own).
  2. Write the script above, choosing tools: Read, Glob, Grep for analysis only; add Edit to change code; add Bash for full automation.
  3. Run it (python agent.py, or npx tsx agent.ts); the loop ends with Done: success.

Source: Agent SDK quickstart, read Nov 6, 2026. Options such as system_prompt, mcp_servers and permission_mode shape the agent; an SDK session starts in default permission mode, not auto.

How is it different from the API, the CLI and Managed Agents?

Anthropic's overview draws the lines this way (Agent SDK overview, read Nov 6, 2026):

You want to Use
Embed Claude Code's agent in your own app, in a process you run Agent SDK
Work interactively or run one-off tasks in a terminal Claude Code CLI
Call the Claude API directly and run the tool loop yourself (or with the client SDK's beta tool runner) Client SDK
Have Anthropic host the agent loop in a managed or self-hosted sandbox Managed Agents

In short: with the client SDK and tool use you write each tool and decide what runs; with the Agent SDK the tools come built in and run on your machine or server; with Managed Agents Anthropic runs the loop and the sandbox, priced at $0.08 per session-hour of active runtime on top of tokens (as of Nov 6, 2026). From other languages, Anthropic suggests calling the CLI with claude -p --output-format json (Claude Code Headless and CI).

Billing and the login rule

The SDK bills like the API: tokens on your Claude API key or cloud account at API rates. Anthropic's overview states that, unless previously approved, third-party developers may not offer claude.ai login or claude.ai rate limits in their products, agents built on the SDK included; builders should use API key authentication (Agent SDK overview, read Nov 6, 2026). Branding rules let a product say "Claude Agent" or "Powered by Claude" but not "Claude Code" or imitate its look.

The rename and breaking changes

On Sep 29, 2025, alongside Claude Code 2.0, Anthropic renamed the Claude Code SDK to the Claude Agent SDK. The TypeScript package moved from @anthropic-ai/claude-code to @anthropic-ai/claude-agent-sdk and Python from claude-code-sdk to claude-agent-sdk. Version 0.1.0 also changed behavior: Python's ClaudeCodeOptions became ClaudeAgentOptions, the system prompt no longer defaults to Claude Code's, and settings files are not loaded unless asked (Migrate to Claude Agent SDK, read Nov 6, 2026). Later, the TypeScript V2 session API was removed in 0.3.142 in favor of query(). The Claude Code GitHub Action and the GitLab integration are both built on the SDK.

Frequently asked questions

What is the Claude Agent SDK? It is Anthropic's Python and TypeScript library that runs Claude Code's agent loop and tools inside your own application, so Claude can read files, run commands, use MCP servers and call subagents without you writing a tool loop.

Is the Claude Code SDK the same as the Claude Agent SDK? Yes. Anthropic renamed the Claude Code SDK to the Claude Agent SDK on Sep 29, 2025, with new package names, claude-agent-sdk and @anthropic-ai/claude-agent-sdk.

Can I use my Claude Pro or Max subscription with the Agent SDK? Anthropic's documentation tells builders to authenticate with an API key or a cloud provider, and does not allow third-party products to offer claude.ai login or its rate limits unless approved.

How is the Claude Agent SDK different from Managed Agents? With the Agent SDK the agent runs in a process you operate; with Managed Agents, Anthropic hosts the loop and a sandbox and charges for session runtime as well as tokens.

Does the Claude Agent SDK need Claude Code installed? Usually not. Both packages bundle a native Claude Code binary; a few installs, such as a Python source distribution on ARM64 Windows, need Claude Code installed separately.

Sources

Moments

Ship your first Managed Agent

Claude

  1. The Claude Agent SDK is Anthropic's library for building agents on the same tools, agent loop and context management…
  2. In short: with the client SDK and tool use you write each tool and decide what runs; with the Agent SDK the tools come…

See also

About this page

Last updated Nov 6, 2026 by the Vi.ki team. Page text CC BY-SA 4.0.

Edit History

Hotkeys

/
Jump to the search box
? or Ctrl + /
Open this list
Esc
Close this list, the photo viewer, or the account menu

Video

Space or K
Play or pause
← →
Back or forward 5 seconds
J L
Back or forward 10 seconds
0 to 9
Go to 0% to 90% of the video
, .
Previous or next frame, while paused
M
Mute or unmute
C
Captions on or off
F
Full screen on or off
A D
Previous or next moment

Photo viewer

← → or A D
Previous or next photo
↑ ↓ or W S
Previous or next photo
Home End
First or last photo
I
Show or hide the photo's info
Z
Clickless on or off: a pointer over a thumbnail shows it
N
Compare with the last photo: back to the one shown before this, and N again comes back
Q
Move the thumbnails to the next edge: top, bottom, left and round
, or Ctrl + ,
Open or close the viewer's settings
V
Clickless pan: a zoomed photo follows the pointer, rather than being dragged
Shift
Browse on or off
B
Show or hide the button bar
T
Show or hide the thumbnails
1
100% zoom on or off
0
Rate the photo as no opinion; again takes the answer back
+ -
Rate the photo a step higher or lower
F
Full screen: the photo alone. F again puts everything back.
Back to top