Skip to main content
  1. Sign up — Create an account at platform.respan.ai
  2. Create an API key — Generate one on the API keys page
  3. Add credits or a provider key — Add credits on the Credits page or connect your own provider key on the Integrations page
Add the Docs MCP to your AI coding tool to get help building with Respan. No API key needed.
{
  "mcpServers": {
    "respan-docs": {
      "url": "https://respan.ai/docs/mcp"
    }
  }
}
This integration is for the Respan gateway.

What is Claude Agent SDK?

The Claude Agent SDK (claude-agent-sdk) is a framework for building agent workflows powered by Claude. Route Claude API calls through the Respan gateway so only a single RESPAN_API_KEY is needed for both the LLM call and trace export.

Quickstart

Step 1: Install packages

pip install claude-agent-sdk respan-exporter-anthropic-agents

Step 2: Set environment variables

export RESPAN_API_KEY="YOUR_RESPAN_API_KEY"
No ANTHROPIC_API_KEY needed — the gateway handles authentication.

Step 3: Point the agent to the Respan gateway

import os
from claude_agent_sdk import ClaudeAgentOptions
from respan_exporter_anthropic_agents import RespanAnthropicAgentsExporter

RESPAN_API_KEY = os.getenv("RESPAN_API_KEY")
BASE_URL = os.getenv("RESPAN_BASE_URL", "https://api.respan.ai/api")

exporter = RespanAnthropicAgentsExporter(
    api_key=RESPAN_API_KEY,
    base_url=BASE_URL,
)

# The Anthropic SDK appends /v1/messages to ANTHROPIC_BASE_URL,
# so point it at the gateway's /anthropic passthrough path.
gateway_url = f"{BASE_URL}/anthropic"

options = ClaudeAgentOptions(
    permission_mode="bypassPermissions",
    max_turns=1,
    env={
        "ANTHROPIC_BASE_URL": gateway_url,
        "ANTHROPIC_AUTH_TOKEN": RESPAN_API_KEY,
        "ANTHROPIC_API_KEY": RESPAN_API_KEY,
    },
)

async for message in exporter.query(
    prompt="Tell me a joke about AI",
    options=options,
):
    print(type(message).__name__)

Step 4: Verify

Open the Logs page to see your gateway requests.

Examples

Tool use via gateway

Run agents with tools, all routed through the gateway.
options = ClaudeAgentOptions(
    permission_mode="bypassPermissions",
    max_turns=3,
    allowed_tools=["Read", "Glob", "Grep"],
    env={
        "ANTHROPIC_BASE_URL": f"{BASE_URL}/anthropic",
        "ANTHROPIC_AUTH_TOKEN": RESPAN_API_KEY,
        "ANTHROPIC_API_KEY": RESPAN_API_KEY,
    },
)

async for message in exporter.query(
    prompt="List the Python files in the current directory.",
    options=options,
):
    print(type(message).__name__)

Gateway URL construction

The Anthropic SDK automatically appends /v1/messages to ANTHROPIC_BASE_URL. The Respan gateway exposes Claude at the /anthropic path.
ANTHROPIC_BASE_URL = https://api.respan.ai/api/anthropic

Final request URL = https://api.respan.ai/api/anthropic/v1/messages
Three environment variables are passed to the Claude subprocess via ClaudeAgentOptions.env (Python) or exporter.withOptions({ env }) (JavaScript):
VariableValuePurpose
ANTHROPIC_BASE_URL{BASE_URL}/anthropicRoutes API calls through gateway
ANTHROPIC_AUTH_TOKENRESPAN_API_KEYAuth token for the subprocess
ANTHROPIC_API_KEYRESPAN_API_KEYAPI key for Anthropic SDK
Looking for tracing integration? See Tracing > Claude Agent SDK.