Anthropic

Route Anthropic model calls through Respan Gateway and track requests.
  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.

1{
2 "mcpServers": {
3 "respan-docs": {
4 "url": "https://mcp.respan.ai/mcp/docs"
5 }
6 }
7}
This section is for Respan LLM gateway users.

Use Respan Gateway to call Anthropic models while keeping unified observability (logs, cost, latency, and reliability metrics) in Respan.

Prerequisites

  • A Respan API key
  • An Anthropic API key (BYOK)

Supported SDKs / integrations

Configuration

There are 2 ways to add your Anthropic credentials to your requests:

Via UI (Global)

2

Add your Anthropic API Key

Select Anthropic and paste your API key.

Add Anthropic credentials

Via code (Per-Request)

You can pass credentials dynamically in the request body. This is useful if you need to use your users’ own API keys (BYOK).

Add the customer_credentials parameter to your Gateway request:

1{
2 // Rest of the request body
3 "customer_credentials": {
4 "anthropic": {
5 "api_key": "YOUR_ANTHROPIC_API_KEY"
6 }
7 }
8}

Override credentials for a particular model (Optional)

One-off credential overrides. Instead of using what is uploaded for each provider, this targets credentials for individual models.

1{
2 // Rest of the request body
3 "customer_credentials": {
4 "anthropic": {
5 "api_key": "YOUR_ANTHROPIC_API_KEY"
6 }
7 },
8 "credential_override": {
9 "claude-3-5-sonnet-20240620": {
10 "api_key": "ANOTHER_ANTHROPIC_API_KEY"
11 }
12 }
13}

Log Anthropic requests

Monitor your Anthropic Claude API calls by logging requests and responses asynchronously. Track metrics like cost, duration, and performance for all Claude models including Claude 3.5 Sonnet, Claude 3 Opus, and more.

Anthropic Python SDK
1import requests
2
3url = "https://api.respan.ai/api/request-logs/create/"
4payload = {
5 "model": "claude-3-5-sonnet-20240620",
6 "prompt_messages": [
7 {
8 "role": "user",
9 "content": "What's the weather like today?"
10 }
11 ],
12 "completion_message": {
13 "role": "assistant",
14 "content": "I don't have access to real-time weather data, but I can help you find weather information."
15 },
16 "cost": 0.00042,
17 "generation_time": 1.8,
18 "customer_params": {
19 "customer_identifier": "user_456"
20 }
21}
22headers = {
23 "Authorization": "Bearer YOUR_RESPAN_API_KEY",
24 "Content-Type": "application/json"
25}
26
27response = requests.post(url, headers=headers, json=payload)