Skip to main content
Claude Agent SDK is Anthropic’s Python SDK for building AI agents powered by Claude. It wraps the Claude Code CLI, providing a programmatic interface for creating agents with tools, hooks, and MCP servers. Add the AI Gateway to get:
  • Multiple Claude Providers - Route through Anthropic, Bedrock, or Vertex AI
  • Observability - Track costs, tokens, and latency for every agent interaction
  • Reliability - Automatic fallbacks, retries, and caching
  • Governance - Budget limits, usage tracking, and team access controls

Claude Agent SDK Documentation

Learn more about Claude Agent SDK’s core concepts and features

Quick Start

1

Install the SDK

2

Add Provider in the AI Gateway

Go to Model CatalogAdd Provider.Select Anthropic, Bedrock, or Vertex AI as your provider and configure your credentials.
3

Get AI Gateway API Key

Go to API Keys and generate your AI Gateway API key.
4

Configure Environment Variables

Set the following environment variables before running your agent:
Replace @anthropic-prod with your provider slug from the Model Catalog.
There are multiple ways to configure models, you can use the provider header, attach config directly to the API key, specify config header, etc.

Basic Usage

Simple Query

Using ClaudeAgentOptions

Interactive Client with Tools

Adding Observability

Trace IDs for Request Tracking

Add trace IDs to group related requests in the AI Gateway’s dashboard:

Custom Metadata

Add metadata for filtering and analytics:

Using AI Gateway Configs

For advanced routing, fallbacks, and caching, create a AI Gateway Config and reference it:

Example: Fallback Configuration

Create a config in the Strata Cloud Manager with fallback logic:
This automatically switches to Bedrock if the primary Anthropic provider fails.

Switch Providers

Change providers by updating the x-portkey-provider header: Replace with your actual provider slugs from the Model Catalog.

Custom Tools with MCP Servers

Claude Agent SDK supports custom tools via MCP servers. All tool calls are tracked in the AI Gateway:
Last modified on September 15, 2026