Loading...
    • Developer Guide
    • API Reference
    • MCP
    • Resources
    • Release Notes
    Search...
    ⌘K
    First steps
    Intro to ClaudeQuickstart
    Models & pricing
    Models overviewChoosing a modelWhat's new in Claude 4.5Migrating to Claude 4.5Model deprecationsPricing
    Build with Claude
    Features overviewUsing the Messages APIContext windowsPrompting best practices
    Capabilities
    Prompt cachingContext editingExtended thinkingEffortStreaming MessagesBatch processingCitationsMultilingual supportToken countingEmbeddingsVisionPDF supportFiles APISearch resultsStructured outputsGoogle Sheets add-on
    Tools
    OverviewHow to implement tool useToken-efficient tool useFine-grained tool streamingBash toolCode execution toolProgrammatic tool callingComputer use toolText editor toolWeb fetch toolWeb search toolMemory toolTool search tool
    Agent Skills
    OverviewQuickstartBest practicesUsing Skills with the API
    Agent SDK
    OverviewTypeScript SDKPython SDKMigration Guide
    Guides
    Streaming InputHandling PermissionsSession ManagementStructured outputs in the SDKHosting the Agent SDKModifying system promptsMCP in the SDKCustom ToolsSubagents in the SDKSlash Commands in the SDKAgent Skills in the SDKTracking Costs and UsageTodo ListsPlugins in the SDK
    MCP in the API
    MCP connectorRemote MCP servers
    Claude on 3rd-party platforms
    Amazon BedrockMicrosoft FoundryVertex AI
    Prompt engineering
    OverviewPrompt generatorUse prompt templatesPrompt improverBe clear and directUse examples (multishot prompting)Let Claude think (CoT)Use XML tagsGive Claude a role (system prompts)Prefill Claude's responseChain complex promptsLong context tipsExtended thinking tips
    Test & evaluate
    Define success criteriaDevelop test casesUsing the Evaluation ToolReducing latency
    Strengthen guardrails
    Reduce hallucinationsIncrease output consistencyMitigate jailbreaksStreaming refusalsReduce prompt leakKeep Claude in character
    Administration and monitoring
    Admin API overviewUsage and Cost APIClaude Code Analytics API
    Console
    Log in
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...

    Solutions

    • AI agents
    • Code modernization
    • Coding
    • Customer support
    • Education
    • Financial services
    • Government
    • Life sciences

    Partners

    • Amazon Bedrock
    • Google Cloud's Vertex AI

    Learn

    • Blog
    • Catalog
    • Courses
    • Use cases
    • Connectors
    • Customer stories
    • Engineering at Anthropic
    • Events
    • Powered by Claude
    • Service partners
    • Startups program

    Company

    • Anthropic
    • Careers
    • Economic Futures
    • Research
    • News
    • Responsible Scaling Policy
    • Security and compliance
    • Transparency

    Learn

    • Blog
    • Catalog
    • Courses
    • Use cases
    • Connectors
    • Customer stories
    • Engineering at Anthropic
    • Events
    • Powered by Claude
    • Service partners
    • Startups program

    Help and security

    • Availability
    • Status
    • Support
    • Discord

    Terms and policies

    • Privacy policy
    • Responsible disclosure policy
    • Terms of service: Commercial
    • Terms of service: Consumer
    • Usage policy
    Agent SDK

    Agent SDK overview

    Build custom AI agents with the Claude Agent SDK

    The Claude Code SDK has been renamed to the Claude Agent SDK. If you're migrating from the old SDK, see the Migration Guide.

    Installation

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

    SDK Options

    The Claude Agent SDK is available in multiple forms to suit different use cases:

    • TypeScript SDK - For Node.js and web applications
    • Python SDK - For Python applications and data science
    • Streaming vs Single Mode - Understanding input modes and best practices

    Why use the Claude Agent SDK?

    Built on top of the agent harness that powers Claude Code, the Claude Agent SDK provides all the building blocks you need to build production-ready agents.

    Taking advantage of the work we've done on Claude Code including:

    • Context Management: Automatic compaction and context management to ensure your agent doesn't run out of context.
    • Rich tool ecosystem: File operations, code execution, web search, and MCP extensibility
    • Advanced permissions: Fine-grained control over agent capabilities
    • Production essentials: Built-in error handling, session management, and monitoring
    • Optimized Claude integration: Automatic prompt caching and performance optimizations

    What can you build with the SDK?

    Here are some example agent types you can create:

    Coding agents:

    • SRE agents that diagnose and fix production issues
    • Security review bots that audit code for vulnerabilities
    • Oncall engineering assistants that triage incidents
    • Code review agents that enforce style and best practices

    Business agents:

    • Legal assistants that review contracts and compliance
    • Finance advisors that analyze reports and forecasts
    • Customer support agents that resolve technical issues
    • Content creation assistants for marketing teams

    Core Concepts

    Authentication

    For basic authentication, retrieve an Claude API key from the Claude Console and set the ANTHROPIC_API_KEY environment variable.

    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 Foundry: Set CLAUDE_CODE_USE_FOUNDRY=1 environment variable and configure Azure credentials

    For detailed configuration instructions for third-party providers, see the Amazon Bedrock, Google Vertex AI, and Microsoft Foundry documentation.

    Unless previously approved, we do not allow third party developers to apply Claude.ai rate limits for their products, including agents built on the Claude Agent SDK. Please use the API key authentication methods described in this document instead.

    Full Claude Code Feature Support

    The SDK provides access to all the default features available in Claude Code, leveraging the same file system-based configuration:

    • Subagents: Launch specialized agents stored as Markdown files in ./.claude/agents/
    • Agent Skills: Extend Claude with specialized capabilities stored as SKILL.md files in ./.claude/skills/
    • Hooks: Execute custom commands configured in ./.claude/settings.json that respond to tool events
    • Slash Commands: Use custom commands defined as Markdown files in ./.claude/commands/
    • Plugins: Load custom plugins programmatically using the plugins option to extend Claude Code with custom commands, agents, skills, hooks, and MCP servers. See Plugins for details.
    • Memory (CLAUDE.md): Maintain project context through CLAUDE.md or .claude/CLAUDE.md files in your project directory, or ~/.claude/CLAUDE.md for user-level instructions. To load these files, you must explicitly set settingSources: ['project'] (TypeScript) or setting_sources=["project"] (Python) in your options. See Modifying system prompts for details.

    These features work identically to their Claude Code counterparts by reading from the same file system locations.

    System Prompts

    System prompts define your agent's role, expertise, and behavior. This is where you specify what kind of agent you're building.

    Tool Permissions

    Control which tools your agent can use with fine-grained permissions:

    • allowedTools - Explicitly allow specific tools
    • disallowedTools - Block specific tools
    • permissionMode - Set overall permission strategy

    Model Context Protocol (MCP)

    Extend your agents with custom tools and integrations through MCP servers. This allows you to connect to databases, APIs, and other external services.

    Building with the Claude Agent SDK

    If you're building coding agents powered by the Claude Agent SDK, please note that Claude Code refers specifically to Anthropic's official product including the CLI, VS Code extension, web experience, and future integrations we build.

    For partners integrating Claude Agent SDK:

    The use of Claude branding for products built on Claude is optional.

    When referencing Claude in your agent selector or product:

    Allowed naming options:

    • 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 or to discuss your product's Claude integration, contact our sales team.

    Reporting Bugs

    If you encounter bugs or issues with the Agent SDK:

    • TypeScript SDK: Report issues on GitHub
    • Python SDK: Report issues on GitHub

    Changelog

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

    • TypeScript SDK: View CHANGELOG.md
    • Python SDK: View CHANGELOG.md

    Related Resources

    • CLI Reference - Complete CLI documentation
    • GitHub Actions Integration - Automate your GitHub workflow
    • MCP Documentation - Extend Claude with custom tools
    • Common Workflows - Step-by-step guides
    • Troubleshooting - Common issues and solutions
    • Installation
    • SDK Options
    • Why use the Claude Agent SDK?
    • What can you build with the SDK?
    • Core Concepts
    • Authentication
    • Full Claude Code Feature Support
    • System Prompts
    • Tool Permissions
    • Model Context Protocol (MCP)
    • Building with the Claude Agent SDK
    • For partners integrating Claude Agent SDK:
    • Reporting Bugs
    • Changelog
    • Related Resources