For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
DiscordPlatform
DocumentationIntegrationsAPI referenceSDKsChangelog
DocumentationIntegrationsAPI referenceSDKsChangelog
    • Overview
  • Tracing
  • Gateway
      • OpenAI SDK
      • Instructor
      • Anthropic SDK
      • Google GenAI
      • LiteLLM
      • RubyLLM
      • Vertex AI
      • AWS Bedrock
      • Cohere
      • Groq
      • Mistral AI
      • Ollama
      • Watsonx
      • Together AI
      • Aleph Alpha
      • HuggingFace
      • Replicate
      • SageMaker
      • Respan API
  • Others
  • Migrating
    • Braintrust
    • Portkey
    • Langfuse
LogoLogo
DiscordPlatform
On this page
  • Setup
  • Switch models
  • Respan parameters
GatewayLLM SDKs

Anthropic SDK (gateway)

Was this page helpful?
Previous

Google GenAI (gateway)

Next
Built with

Route Anthropic SDK calls through the Respan gateway. Only your RESPAN_API_KEY is needed — no separate ANTHROPIC_API_KEY required.

Setup

1

Install packages

$pip install respan-ai respan-instrumentation-anthropic anthropic
2

Set environment variables

$export RESPAN_API_KEY="YOUR_RESPAN_API_KEY"

No ANTHROPIC_API_KEY needed — the Respan gateway handles provider authentication.

3

Point the Anthropic client to the Respan gateway

1import os
2from anthropic import Anthropic
3
4client = Anthropic(
5 api_key=os.environ["RESPAN_API_KEY"],
6 base_url="https://api.respan.ai/api/anthropic/",
7)
8
9message = client.messages.create(
10 model="claude-sonnet-4-5-20250929",
11 max_tokens=1024,
12 messages=[{"role": "user", "content": "Say hello in three languages."}],
13)
14print(message.content[0].text)

Switch models

Change the model parameter to use different Claude models through the same gateway.

1message = client.messages.create(model="claude-sonnet-4-5-20250929", max_tokens=1024, messages=messages)
2message = client.messages.create(model="claude-3-5-haiku-20241022", max_tokens=1024, messages=messages)
3message = client.messages.create(model="claude-3-opus-20240229", max_tokens=1024, messages=messages)

See the full model list.

Respan parameters

Pass additional Respan parameters via metadata under the respan_params key for gateway features.

1message = client.messages.create(
2 model="claude-sonnet-4-5-20250929",
3 max_tokens=1024,
4 messages=[{"role": "user", "content": "Hello"}],
5 metadata={
6 "respan_params": {
7 "customer_identifier": "user_123",
8 "metadata": {"session_id": "abc123"},
9 "thread_identifier": "conversation_456",
10 }
11 },
12)

See Respan params & metadata for the full list.