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 Anthropic SDK?

The Anthropic SDK lets you call Claude models directly using Anthropic’s native API. By pointing base_url to Respan, all requests are routed through the gateway for logging and observability.
This is a pass-through integration. Some features are not available: user rate limits, fallbacks, load balancing, and direct prompt management (use the Prompts API instead).
Default max_tokens: Anthropic requests sent through Respan have a default of 4096 max_tokens. Make sure to explicitly set max_tokens in your requests if you need a different value.

Quickstart

import anthropic

client = anthropic.Anthropic(
    base_url="https://api.respan.ai/api/anthropic/",
    api_key="Your_Respan_API_Key",
)

message = client.messages.create(
    model="claude-3-opus-20240229",
    max_tokens=1000,
    system="Respond only in Yoda-speak.",
    messages=[
        {"role": "user", "content": "How are you today?"}
    ],
    metadata={
        "respan_params": {
            "customer_identifier": "something" # You need to wrap the customer_identifier into the "respan_params" key
        }
    },
)

print(message.content)

Supported parameters

Extra Headers

You can pass additional headers to be sent with your LLM requests using the extra_headers parameter. This is useful for sending custom headers required by specific models or configurations.
import anthropic

client = anthropic.Anthropic(
    base_url="https://api.respan.ai/api/anthropic/",
    api_key="Your_Respan_API_Key",
)

message = client.messages.create(
    model="claude-sonnet-4-20250514",
    max_tokens=1000,
    system="Respond only in Yoda-speak.",
    messages=[
        {"role": "user", "content": "Are there an infinite number of prime numbers such that n mod 4 == 3?"}
    ],
    metadata={
        "extra_headers": {
            "anthropic-beta": "context-1m-2025-08-07"
        }
    },
)

print(message.content)
Extra Headers: The extra_headers parameter allows you to pass additional headers that will be sent with your LLM request. This is particularly useful for accessing beta features like Claude Sonnet 4’s 1M token context window using the anthropic-beta: context-1m-2025-08-07 header.

Respan parameters

To use Respan parameters, pass them in the metadata parameter under the respan_params key. These parameters take precedence over Anthropic parameters if they conflict.

Nested metadata

You can pass multiple Respan-specific parameters using a nested metadata structure. This allows you to include custom_identifier, customer_identifier, and additional custom metadata all in one structure:
import anthropic

client = anthropic.Anthropic(
    base_url="https://api.respan.ai/api/anthropic/",
    api_key="Your_Respan_API_Key",
)

message = client.messages.create(
    model="claude-3-opus-20240229",
    max_tokens=1000,
    system="Respond only in Yoda-speak.",
    messages=[
        {"role": "user", "content": "How are you today?"}
    ],
    metadata={
        "respan_params": {
            "custom_identifier": "session_id",
            "customer_identifier": "customer_id",
            "metadata": {
                "agent": "orchestrator"
            }
        }
    },
)

print(message.content)
Nested Metadata Structure: The metadata object should contain a respan_params key, which itself contains:
  • custom_identifier: A custom identifier for tracking specific requests
  • customer_identifier: An identifier for the customer making the request
  • metadata: An additional nested object for custom metadata fields (e.g., agent type, workflow stage, etc.)