Respan API

The Respan gateway provides an OpenAI-compatible API endpoint that gives you access to 250+ models from all major providers through a single API key and base URL. Every gateway request is automatically captured as a trace, so you get full observability without any SDK setup.

Create an account at platform.respan.ai and grab an API key. For gateway, also add credits or a provider key.

Run npx @respan/cli setup to set up with your coding agent.

The Respan API is the gateway itself. Every request is automatically traced — no SDK or instrumentation needed.

Endpoints

EndpointBase URL
OpenAI-compatiblehttps://api.respan.ai/api/
Anthropic proxyhttps://api.respan.ai/api/anthropic/
Google Gemini proxyhttps://api.respan.ai/api/google/gemini

Environment switching: Respan doesn’t support an env parameter in API calls. To switch between environments (test/production), use different API keys — one for your test environment and another for production. Manage keys in API Keys settings.

Setup

1

Set environment variables

$export RESPAN_API_KEY="YOUR_RESPAN_API_KEY"
2

Make a request

1import os
2import requests
3
4response = requests.post(
5 "https://api.respan.ai/api/chat/completions",
6 headers={
7 "Content-Type": "application/json",
8 "Authorization": f"Bearer {os.environ['RESPAN_API_KEY']}",
9 },
10 json={
11 "model": "gpt-4.1-nano",
12 "messages": [{"role": "user", "content": "Say 'Hello World'"}],
13 },
14)
15print(response.json())
3

Verify

Open the Logs page to see your gateway requests captured as traces.

Switch models

Change the model parameter to use any supported provider through the same endpoint.

1response = requests.post(
2 "https://api.respan.ai/api/chat/completions",
3 headers=headers,
4 json={"model": "gpt-4.1-nano", "messages": messages},
5)
6response = requests.post(..., json={"model": "claude-sonnet-4-5-20250929", "messages": messages})
7response = requests.post(..., json={"model": "gemini-2.5-flash", "messages": messages})

Browse the full model list to see all available models.

OpenAI-compatible parameters

All standard OpenAI chat completion parameters are supported.

ParameterTypeDescription
messagesarrayList of messages in OpenAI format (role + content).
modelstringModel to use (e.g. gpt-4.1-nano, claude-sonnet-4-5-20250929).
streambooleanStream back partial progress token by token.
temperaturenumberControls randomness (0-2).
max_tokensnumberMaximum tokens to generate.
top_pnumberNucleus sampling threshold.
toolsarrayList of tools/functions the model may call.
tool_choicestring|objectControls tool selection.
response_formatobjectForce JSON output.

Respan parameters

Pass Respan-specific parameters in the request body alongside OpenAI parameters. When using the OpenAI SDK, pass them via extra_body.

Observability

ParameterTypeDescription
customer_identifierstringTag to identify the user. See customer identifier.
metadataobjectCustom key-value pairs for filtering and search.
custom_identifierstringExtra indexed tag (shows as “Custom ID” in spans).
disable_logbooleanWhen true, only metrics are recorded.
request_breakdownbooleanReturns a summarization of the response (tokens, cost, latency).

Reliability

ParameterTypeDescription
fallback_modelsarrayBackup models ranked by priority.
load_balance_groupobjectBalance requests across models.
retry_paramsobjectConfigure retries (retry_enabled, num_retries, retry_after).

Caching

ParameterTypeDescription
cache_enabledbooleanEnable response caching.
cache_ttlnumberCache time-to-live in seconds (default: 30 days).
cache_optionsobjectSet cache_by_customer: true to scope cache per customer.

Credentials

ParameterTypeDescription
customer_credentialsobjectPass your customer’s provider API keys.
credential_overrideobjectOne-off credential overrides for specific models.
model_name_mapobjectMap default model names to custom Azure deployment names.

Prompt management

ParameterTypeDescription
promptobjectUse a Respan-managed prompt template.
1{
2 "model": "gpt-4.1-nano",
3 "messages": [],
4 "prompt": {
5 "prompt_id": "your-prompt-id",
6 "variables": {"user_name": "Sarah"}
7 }
8}

Response format

1{
2 "id": "chatcmpl-e1b9665b-c354-41c5-bbe5-178bd0b69773",
3 "object": "chat.completion",
4 "created": 1761546960,
5 "model": "claude-sonnet-4-5-20250929",
6 "choices": [
7 {
8 "index": 0,
9 "finish_reason": "stop",
10 "message": {
11 "role": "assistant",
12 "content": "I'm doing well, thank you for asking!"
13 }
14 }
15 ],
16 "usage": {
17 "completion_tokens": 20,
18 "prompt_tokens": 2619,
19 "total_tokens": 2639
20 }
21}