# 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. ## Install Save the content below to `.claude/skills/` or append to your `CLAUDE.md`: ## Quick Use ```bash pip install claude-agent-sdk ``` ```python 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) ```python 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 ```python # 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 ```python 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 ```python for event in agent.run_stream("Analyze this codebase"): if event.type == "text": print(event.text, end="") elif event.type == "tool_use": print(f"\ [Using tool: {event.tool_name}]") ``` ### 5. Guardrails ```python 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](https://github.com/anthropics). Licensed under MIT. > > [anthropics/claude-agent-sdk](https://github.com/anthropics/claude-agent-sdk) — Official Anthropic Agent SDK ## Quick Use ```bash pip install claude-agent-sdk ``` Anthropic's official agent framework for building production-grade Claude agents. ## What is the Anthropic Agent SDK? Anthropic's official Python framework for building production-grade AI agents on Claude. Provides tool calls, conversation memory, multi-turn orchestration, and safety guardrails. **TL;DR**: Anthropic's official agent framework. Structured tool calls + conversation memory + agent handoff + safety guardrails. The underlying architecture of Claude Code. Production-ready. **Best for**: Developers building production-grade autonomous Claude agents. ## Core Features ### 1. Tool Calls Define tools with Python decorators; types inferred automatically. ### 2. Agent Handoff Hand off tasks between specialized agents. ### 3. Streaming Real-time text and tool-call events. ### 4. Safety Guardrails Turn limits, tool allowlists, output-length controls. ## FAQ **Q: Relationship to Claude Code?** A: Claude Code is built on the Agent SDK. The SDK is the foundation for building custom agent systems. ## Source & Thanks > [anthropics/claude-agent-sdk](https://github.com/anthropics/claude-agent-sdk) — Official Anthropic --- Source: https://tokrepo.com/en/workflows/anthropic-agent-sdk-build-production-ai-agents-b9f86852 Author: Anthropic