---
title: "Gateway quickstart"
subtitle: "Call any model through one endpoint with your Respan API key."
---

Paste this into your coding agent, or follow the setup below:

```
Help me set up the Respan gateway: fetch and follow https://www.respan.ai/docs/ai-gateway/quickstart.md
```

## Setup

Create a key in [Gateway › API keys](https://platform.respan.ai/platform/gateway/api-keys), set it as `RESPAN_API_KEY`, and point your SDK at the gateway:

<Tabs>
<Tab title="cURL">
```bash
curl https://gateway.respan.ai/chat/completions \
  -H "Authorization: Bearer $RESPAN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "gpt-5.5", "messages": [{"role": "user", "content": "Hello!"}]}'
```
</Tab>
<Tab title="Python">
```python
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://gateway.respan.ai",
    api_key=os.environ["RESPAN_API_KEY"],
)

response = client.chat.completions.create(
    model="gpt-5.5",
    messages=[{"role": "user", "content": "Hello!"}],
)
print(response.choices[0].message.content)
```
</Tab>
<Tab title="TypeScript">
```typescript
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://gateway.respan.ai",
  apiKey: process.env.RESPAN_API_KEY,
});

const response = await client.chat.completions.create({
  model: "gpt-5.5",
  messages: [{ role: "user", content: "Hello!" }],
});
console.log(response.choices[0].message.content);
```
</Tab>
</Tabs>

Change `model` to any ID on [respan.ai/models](https://www.respan.ai/models). Calls are paid from your Respan credits, or by your provider if you [bring your own key](/docs/ai-gateway/spend/credits-vs-byok).
## Migrate from another provider or gateway

Most apps only change the base URL and the API key.

<Tabs>
<Tab title="OpenAI">

Keep the OpenAI SDK. Change the base URL and use your Respan API key. OpenAI model IDs stay the same, such as `gpt-5.5`.

```python
# Before
client = OpenAI(api_key=os.environ["OPENAI_API_KEY"])

# After
client = OpenAI(base_url="https://gateway.respan.ai", api_key=os.environ["RESPAN_API_KEY"])
```

To keep paying OpenAI directly, save your OpenAI key with [BYOK](/docs/ai-gateway/spend/credits-vs-byok#byok).

</Tab>
<Tab title="Anthropic">

Keep the Anthropic SDK. Change the base URL and use your Respan API key.

```python
# Before
client = anthropic.Anthropic(api_key=os.environ["ANTHROPIC_API_KEY"])

# After
client = anthropic.Anthropic(base_url="https://gateway.respan.ai", api_key=os.environ["RESPAN_API_KEY"])
```

For Claude Code, set `ANTHROPIC_BASE_URL=https://gateway.respan.ai` and `ANTHROPIC_API_KEY` to your Respan key, and unset `ANTHROPIC_AUTH_TOKEN`, which Claude Code prefers when both are set. See the [Claude Code guide](/docs/integrations/gateway/claude-code).

</Tab>
<Tab title="OpenRouter">

Change the base URL and key, then the model IDs. Move your fallback list into a [fallback](/docs/ai-gateway/routing/fallbacks) on the model.

```python
# Before
client = OpenAI(base_url="https://openrouter.ai/api/v1", api_key=os.environ["OPENROUTER_API_KEY"])
client.chat.completions.create(
    model="openai/gpt-5.5",
    messages=messages,
    extra_body={"models": ["anthropic/claude-sonnet-4.5"]},
)

# After: "smart" is a fallback route with entries gpt-5.5, then claude-sonnet-4-5-20250929
client = OpenAI(base_url="https://gateway.respan.ai", api_key=os.environ["RESPAN_API_KEY"])
client.chat.completions.create(model="smart", messages=messages)
```

Model IDs come from the [model catalog](https://www.respan.ai/models) and have no vendor prefix: `gpt-5.5`, not `openai/gpt-5.5`. To reach a model through OpenRouter itself, prefix it with `openrouter/`, as in `openrouter/openai/gpt-oss-120b`.

{/* REVIEW: confirm whether the gateway also accepts OpenRouter-style vendor/model IDs (openai/gpt-5.5) as aliases. */}

| OpenRouter | Gateway |
|---|---|
| `models: [...]` fallback list | A [fallback](/docs/ai-gateway/routing/fallbacks#create-a-fallback) |
| `provider.order` | A fallback route whose entries are provider offerings, such as `azure/gpt-5.5`, then `gpt-5.5` |
| `provider.only` | A provider offering ID such as `azure/gpt-5.5` |
| `provider.allow_fallbacks: false` | A provider offering ID, which keeps the request on that provider |
| `user` | `customer_identifier` |

</Tab>
<Tab title="Vercel AI Gateway">

Keep the AI SDK and your model IDs. Install [`@respan/ai-sdk-provider`](https://www.npmjs.com/package/@respan/ai-sdk-provider) and make Respan the default provider once at startup. Each model is called in its native format, so options such as `providerOptions.anthropic` keep working.

```bash
npm install @respan/ai-sdk-provider
```

```typescript
// Before: string model IDs go to Vercel AI Gateway
const result = await generateText({ model: "anthropic/claude-sonnet-4.5", prompt });

// After: set once at startup, and the same IDs go to Respan
import { respan } from "@respan/ai-sdk-provider";

globalThis.AI_SDK_DEFAULT_PROVIDER = respan;

const result = await generateText({ model: "anthropic/claude-sonnet-4.5", prompt });
```

If you call `gateway("...")` directly, call `respan("...")` instead. `openai/`, `anthropic/` and `google/` IDs work as they are; for other models, use the ID from [respan.ai/models](https://www.respan.ai/models). Vercel's `providerOptions.gateway.order` maps to a provider offering ID or a fallback route of provider offerings, and its `models` fallback list to a [fallback](/docs/ai-gateway/routing/fallbacks#create-a-fallback).

</Tab>
<Tab title="LiteLLM">

If you run the LiteLLM proxy, point your clients at the gateway instead. Your routing config moves to [fallbacks](/docs/ai-gateway/routing/fallbacks) and [load balancers](/docs/ai-gateway/routing/load-balancing) in the Respan platform.

```python
# Before
client = OpenAI(base_url="http://localhost:4000", api_key=os.environ["LITELLM_KEY"])
client.chat.completions.create(model="gpt-5.5", messages=messages, extra_body={"fallbacks": ["claude-sonnet-4-5-20250929"]})

# After: "smart" is a fallback route with entries gpt-5.5, then claude-sonnet-4-5-20250929
client = OpenAI(base_url="https://gateway.respan.ai", api_key=os.environ["RESPAN_API_KEY"])
client.chat.completions.create(model="smart", messages=messages)
```

LiteLLM `model_list` entries with weights become a [load balancer](/docs/ai-gateway/routing/load-balancing) across models, or [key weights](/docs/ai-gateway/routing/load-balancing#your-own-keys) across your saved provider keys. If you call the LiteLLM SDK in-process, see the [LiteLLM guide](/docs/integrations/gateway/lite-llm).

</Tab>
</Tabs>

## Logs

Every call shows up in **Logs** with its model, provider, tokens, latency, and cost.

<img src={"/docs/images/gateway-quickstart/logs-first-request-light.webp"} className="block dark:hidden" alt="Gateway Logs listing the latest requests, newest first, with time, log ID, span name, model, system, and user message" />
<img src={"/docs/images/gateway-quickstart/logs-first-request-dark.webp"} className="hidden dark:block" alt="Gateway Logs listing the latest requests, newest first, with time, log ID, span name, model, system, and user message" />

Using a framework or coding agent? See [Integrations](/docs/integrations/gateway/overview).
