Routing & passthrough

Two ways to call Respan: a unified router or a provider-native passthrough.

Respan exposes two different endpoint shapes. Pick whichever fits the SDK or tool you already use.

ShapeBase URLWhen to use
Unified routerhttps://api.respan.ai/api/Point any OpenAI-compatible SDK here. Switch providers by changing the model slug.
Provider passthroughhttps://api.respan.ai/api/anthropic/, https://api.respan.ai/api/google/gemini, https://api.respan.ai/api/google/vertexai/Drop-in replacement for the provider’s own SDK or CLI. Keep using the provider’s native API shape and SDK.

Every request through either shape is automatically logged.


Unified router

The unified router accepts the OpenAI Chat Completions and Responses API formats. You point any OpenAI-compatible SDK at https://api.respan.ai/api/ and call models from any provider by changing the model slug.

1from openai import OpenAI
2
3client = OpenAI(
4 base_url="https://api.respan.ai/api/",
5 api_key="YOUR_RESPAN_API_KEY",
6)
7
8# Switch provider by changing the slug, not the SDK or base URL.
9client.chat.completions.create(model="gpt-4o", messages=[{"role": "user", "content": "Hi"}])
10client.chat.completions.create(model="claude-sonnet-4-5-20250929", messages=[{"role": "user", "content": "Hi"}])
11client.chat.completions.create(model="gemini-2.5-flash", messages=[{"role": "user", "content": "Hi"}])

Endpoints:

EndpointFormat
POST /api/chat/completionsOpenAI Chat Completions
POST /api/responsesOpenAI Responses API
POST /api/embeddingsOpenAI Embeddings

See Create chat completion and Create response for the full schema.


Provider passthrough

Passthrough endpoints accept the provider’s native request and response format unchanged. Use them when you want to keep using the provider’s official SDK or CLI without switching to OpenAI-compatible code.

Anthropic

1import anthropic
2
3client = anthropic.Anthropic(
4 base_url="https://api.respan.ai/api/anthropic/",
5 api_key="YOUR_RESPAN_API_KEY",
6)
7
8message = client.messages.create(
9 model="claude-sonnet-4-5-20250929",
10 max_tokens=1024,
11 messages=[{"role": "user", "content": "Hello"}],
12)

For the Anthropic CLI or Claude Code:

$export ANTHROPIC_BASE_URL="https://api.respan.ai/api/anthropic/"
$export ANTHROPIC_AUTH_TOKEN="YOUR_RESPAN_API_KEY"

Google Gemini

1from google import genai
2
3client = genai.Client(
4 api_key="YOUR_RESPAN_API_KEY",
5 http_options={"base_url": "https://api.respan.ai/api/google/gemini"},
6)

For the Gemini CLI:

$export GEMINI_API_KEY="YOUR_RESPAN_API_KEY"
$export GOOGLE_GEMINI_BASE_URL="https://api.respan.ai/api/google/gemini"

Google Vertex AI

$export GOOGLE_GEMINI_BASE_URL="https://api.respan.ai/api/google/vertexai/"

Which one should I use?

  • Use the unified router if you want one SDK and one base URL across providers, want to use Respan features like inline routing or fallbacks, or are starting fresh.
  • Use a passthrough if you already have provider-native code, want a provider’s CLI (Claude Code, Gemini CLI) to flow through Respan unchanged, or need a feature only the provider’s native API exposes.

Both can be mixed in the same project. For example, route your app’s OpenAI SDK calls through the unified router and route Claude Code through the Anthropic passthrough.


Pin a provider for a passthrough call

By default a passthrough request resolves to its native provider (Anthropic passthrough goes to Anthropic, etc.). To keep a passthrough’s request shape but route the call to a different provider (e.g. send Anthropic-format requests to Vertex AI or Bedrock), use the X-Respan-Route-Provider header. See Providers & models for details.