ScriptsApr 8, 2026·2 min read

Anthropic Agent SDK — Build Production AI Agents

Official Anthropic SDK for building AI agents with tool use, memory, and orchestration. Production-grade agent framework with Claude as the backbone for autonomous tasks.

AG
Agent Toolkit · Community
Quick Use

Use it first, then decide how deep to go

This block should tell both the user and the agent what to copy, install, and apply first.

pip install claude-agent-sdk
from claude_agent_sdk import Agent, tool

@tool
def search_web(query: str) -> str:
    "Search the web for information."
    return do_search(query)

agent = Agent(
    model="claude-sonnet-4-20250514",
    tools=[search_web],
    system="You are a helpful research assistant.",
)

result = agent.run("Find the latest news about AI regulation in the EU")
print(result.output)

What is the Anthropic Agent SDK?

The Anthropic Agent SDK is the official Python framework for building production AI agents powered by Claude. It provides structured tool use, conversation memory, multi-turn orchestration, and guardrails — everything needed to build autonomous agents that reliably complete complex tasks. Think of it as the "official way" to build Claude-powered agents beyond simple API calls.

Answer-Ready: Anthropic Agent SDK is the official framework for building production AI agents with Claude. Structured tool use, conversation memory, multi-turn orchestration, and safety guardrails. Supports agent handoffs, parallel tool execution, and streaming. The backbone for Claude Code's own agent system.

Best for: Developers building production autonomous agents with Claude. Works with: Claude Opus, Sonnet, Haiku via Anthropic API. Setup time: Under 3 minutes.

Core Features

1. Tool Use (Structured)

from claude_agent_sdk import Agent, tool

@tool
def get_weather(city: str) -> dict:
    "Get current weather for a city."
    return {"temp": 22, "condition": "sunny"}

@tool
def send_email(to: str, subject: str, body: str) -> str:
    "Send an email."
    return f"Email sent to {to}"

agent = Agent(
    model="claude-sonnet-4-20250514",
    tools=[get_weather, send_email],
)

2. Multi-Turn Orchestration

# Agent maintains conversation state across turns
result = agent.run("What's the weather in Tokyo?")
result = agent.run("Now email that to alice@example.com")
# Agent remembers previous context

3. Agent Handoffs

from claude_agent_sdk import Agent

researcher = Agent(name="researcher", model="claude-sonnet-4-20250514",
    system="You research topics thoroughly.")
writer = Agent(name="writer", model="claude-sonnet-4-20250514",
    system="You write clear, engaging content.")

# Researcher hands off to writer
orchestrator = Agent(
    model="claude-sonnet-4-20250514",
    agents=[researcher, writer],
    system="Coordinate research and writing tasks.",
)

4. Streaming

for event in agent.run_stream("Analyze this codebase"):
    if event.type == "text":
        print(event.text, end="")
    elif event.type == "tool_use":
        print(f"\n[Using tool: {event.tool_name}]")

5. Guardrails

agent = Agent(
    model="claude-sonnet-4-20250514",
    max_turns=10,           # Limit autonomous loops
    max_tokens=4096,        # Limit output length
    allowed_tools=["search_web"],  # Restrict tool access
)

Architecture

Component Purpose
Agent Core orchestration loop
Tool Typed function the agent can call
Memory Conversation state management
Handoff Transfer between specialized agents
Guardrail Safety and resource limits

FAQ

Q: How does this relate to Claude Code? A: Claude Code is built on top of the Agent SDK. The SDK gives you the building blocks to create your own agent systems.

Q: Can I use it with other LLMs? A: The SDK is designed for Claude. For multi-provider support, use LiteLLM or Bifrost as a proxy.

Q: Is it production-ready? A: Yes, the SDK is designed for production use with proper error handling, retries, and resource management.

🙏

Source & Thanks

Created by Anthropic. Licensed under MIT.

anthropics/claude-agent-sdk — Official Anthropic Agent SDK

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets