SpyBara
Go Premium

agent-sdk/overview.md 2026-04-14 21:14 UTC to 2026-04-15 18:20 UTC

2 added, 2 removed.

2026
Wed 29 21:21 Tue 28 21:21 Mon 27 21:20 Sun 26 04:08 Sat 25 21:10 Fri 24 18:11 Thu 23 18:19 Wed 22 21:15 Tue 21 21:14 Mon 20 21:14 Sat 18 18:09 Fri 17 21:13 Thu 16 21:13 Wed 15 18:20 Tue 14 21:14 Mon 13 21:14 Sat 11 00:11 Fri 10 21:09 Thu 9 21:14 Wed 8 21:13 Tue 7 21:14 Sat 4 18:05 Fri 3 21:07 Thu 2 21:08 Wed 1 21:12

Agent SDK overview

Build production AI agents with Claude Code as a library

Build AI agents that autonomously read files, run commands, search the web, edit code, and more. The Agent SDK gives you the same tools, agent loop, and context management that power Claude Code, programmable in Python and TypeScript.

import asyncio
from claude_agent_sdk import query, ClaudeAgentOptions


async def main():
async for message in query(
prompt="Find and fix the bug in auth.py",
options=ClaudeAgentOptions(allowed_tools=["Read", "Edit", "Bash"]),
):
print(message)  # Claude reads the file, finds the bug, edits it


asyncio.run(main())

The Agent SDK includes built-in tools for reading files, running commands, and editing code, so your agent can start working immediately without you implementing tool execution. Dive into the quickstart or explore real agents built with the SDK:

Get started

1

Install the SDK

npm install @anthropic-ai/claude-agent-sdk
2

Set your API key

Get an API key from the Console, then set it as an environment variable:

export ANTHROPIC_API_KEY=your-api-key

The SDK also supports authentication via third-party API providers:

  • Amazon Bedrock: set CLAUDE_CODE_USE_BEDROCK=1 environment variable and configure AWS credentials
  • Google Vertex AI: set CLAUDE_CODE_USE_VERTEX=1 environment variable and configure Google Cloud credentials
  • Microsoft Azure: set CLAUDE_CODE_USE_FOUNDRY=1 environment variable and configure Azure credentials

See the setup guides for Bedrock, Vertex AI, or Azure AI Foundry for details.

3

Run your first agent

This example creates an agent that lists files in your current directory using built-in tools.

import asyncio
from claude_agent_sdk import query, ClaudeAgentOptions


async def main():
async for message in query(
prompt="What files are in this directory?",
options=ClaudeAgentOptions(allowed_tools=["Bash", "Glob"]),
):
if hasattr(message, "result"):
print(message.result)


asyncio.run(main())

Ready to build? Follow the Quickstart to create an agent that finds and fixes bugs in minutes.

Capabilities

Everything that makes Claude Code powerful is available in the SDK:

Your agent can read files, run commands, and search codebases out of the box. Key tools include:

Tool What it does
Read Read any file in the working directory
Write Create new files
Edit Make precise edits to existing files
Bash Run terminal commands, scripts, git operations
Monitor Watch a background script and react to each output line as an event
Glob Find files by pattern (**/*.ts, src/**/*.py)
Grep Search file contents with regex
WebSearch Search the web for current information
WebFetch Fetch and parse web page content
AskUserQuestion Ask the user clarifying questions with multiple choice options

This example creates an agent that searches your codebase for TODO comments:

import asyncio
from claude_agent_sdk import query, ClaudeAgentOptions


async def main():
async for message in query(
prompt="Find all TODO comments and create a summary",
options=ClaudeAgentOptions(allowed_tools=["Read", "Glob", "Grep"]),
):
if hasattr(message, "result"):
print(message.result)


asyncio.run(main())

Claude Code features

The SDK also supports Claude Code's filesystem-based configuration. To use these features, set setting_sources=["project"] (Python) or settingSources: ['project'] (TypeScript) in your options.

Feature Description Location
Skills Specialized capabilities defined in Markdown .claude/skills/*/SKILL.md
Slash commands Custom commands for common tasks .claude/commands/*.md
Memory Project context and instructions CLAUDE.md or .claude/CLAUDE.md
Plugins Extend with custom commands, agents, and MCP servers Programmatic via plugins option

Compare the Agent SDK to other Claude tools

The Claude Platform offers multiple ways to build with Claude. Here's how the Agent SDK fits in:

The Anthropic Client SDK gives you direct API access: you send prompts and implement tool execution yourself. The Agent SDK gives you Claude with built-in tool execution.

With the Client SDK, you implement a tool loop. With the Agent SDK, Claude handles it:

# Client SDK: You implement the tool loop
response = client.messages.create(...)
while response.stop_reason == "tool_use":
result = your_tool_executor(response.tool_use)
response = client.messages.create(tool_result=result, **params)

# Agent SDK: Claude handles tools autonomously
async for message in query(prompt="Fix the bug in auth.py"):
print(message)

Changelog

View the full changelog for SDK updates, bug fixes, and new features:

Reporting bugs

If you encounter bugs or issues with the Agent SDK:

Branding guidelines

For partners integrating the Claude Agent SDK, use of Claude branding is optional. When referencing Claude in your product:

Allowed:

  • "Claude Agent" (preferred for dropdown menus)
  • "Claude" (when within a menu already labeled "Agents")
  • "{YourAgentName} Powered by Claude" (if you have an existing agent name)

Not permitted:

  • "Claude Code" or "Claude Code Agent"
  • Claude Code-branded ASCII art or visual elements that mimic Claude Code

Your product should maintain its own branding and not appear to be Claude Code or any Anthropic product. For questions about branding compliance, contact the Anthropic sales team.

License and terms

Use of the Claude Agent SDK is governed by Anthropic's Commercial Terms of Service, including when you use it to power products and services that you make available to your own customers and end users, except to the extent a specific component or dependency is covered by a different license as indicated in that component's LICENSE file.

Next steps