Connect your app
Point your SDK at the gateway by changing its base URL.
To send your app’s calls through the gateway, change the base URL in your client. Your code stays the same, and the model can be from any provider the gateway has.
Base URLs
Each SDK takes the base URL its own API uses. For a gateway on localhost:8080:
| Client | Base URL | Requests go to |
|---|---|---|
| OpenAI SDK, and frameworks built on it | http://localhost:8080/v1 | /v1/chat/completions, /v1/responses, /v1/images/..., /v1/audio/..., /v1/embeddings, /v1/videos |
| Anthropic SDK | http://localhost:8080 | /v1/messages |
| Google GenAI SDK | http://localhost:8080 | /v1beta/models/{model}:generateContent |
Use your gateway’s address in place of localhost:8080. GET /v1/models lists every provider’s models. For every endpoint, see API formats.
API keys
Pass a client key as the SDK’s API key. The gateway accepts it as Authorization: Bearer, x-api-key or x-goog-api-key, which covers all three SDKs, and removes it before calling the provider.
With no client keys set, any value works, and the gateway only answers on loopback.
Examples
from openai import OpenAI
client = OpenAI(base_url="http://localhost:8080/v1", api_key="your-client-key")
reply = client.chat.completions.create(
model="claude-haiku-5-5",
messages=[{"role": "user", "content": "Hello!"}],
)
print(reply.choices[0].message.content)A model name such as claude-haiku-5-5 goes to the provider that lists it. To pick the provider yourself, write provider/model, such as anthropic/claude-haiku-5-5. To define names of your own with fallback, see Routes and fallback.
Claude Code
respan-gateway proxy --anthropic relays Anthropic’s whole API with each client’s own credentials, and needs no config file or keys of its own. Use it to put Claude Code behind the gateway, with Claude models:
respan-gateway proxy --anthropicIn another terminal:
ANTHROPIC_BASE_URL=http://127.0.0.1:8080 claudeClaude Code keeps its own login or API key. Calls through the proxy show up in the web UI at /ui/.
Coding agents such as Claude Code, Codex and Gemini CLI don’t work with another vendor’s models through the gateway yet. Use them with their own vendor’s models.
Integration guides
The guides under Gateway integrations (Vercel AI SDK, LangChain, Pydantic AI and more) work with this gateway too. Follow a guide, then make two changes:
- Replace its base URL, such as
https://api.respan.ai/api/, with the gateway’s from the table above. - Replace
RESPAN_API_KEYwith your client key.
Features of the hosted Respan gateway, such as respan_params and prompt management, aren’t part of this gateway. To log your calls in Respan, turn on the respan plugin; see Plugins.