> ## Documentation Index
> Fetch the complete documentation index at: https://docs.routerbase.com/llms.txt
> Use this file to discover all available pages before exploring further.

# OpenAI Chat API

> OpenAI chat models — GPT-5.6 (Luna/Terra/Sol), GPT-5 (5/5.4/5.4-mini/5.5/nano), GPT-4 (4o/4o-mini/4.1/4.1-nano) and the o-series (o3, o4-mini) — via RouterBase, OpenAI-compatible with per-user prompt caching.

## Overview

OpenAI's chat models on RouterBase, served through the standard
OpenAI-compatible chat completions endpoint with streaming, tool
calling, vision input, and **per-user prompt caching**. Covers the
**GPT-5.6** and **GPT-5** flagship families, the **GPT-4** family, and
the **o-series** reasoning models.

|              |                                             |
| ------------ | ------------------------------------------- |
| **Provider** | OpenAI                                      |
| **Families** | `gpt-5.6`, `gpt-5`, `gpt-4`, `o-series`     |
| **Modality** | Chat                                        |
| **Input**    | Text, image                                 |
| **Output**   | Text                                        |
| **Caching**  | Per-user prompt cache (automatic, isolated) |

## Models

### GPT-5.6

The GPT-5.6 tiers are named rather than numbered; all three share a
1M-token context window, reasoning, structured outputs, tool calling and
prompt caching, and differ in capability and price.

| Model                  | Tier               | Use it for                                     |
| ---------------------- | ------------------ | ---------------------------------------------- |
| `openai/gpt-5.6-sol`   | Highest capability | The hardest reasoning, long multi-step work    |
| `openai/gpt-5.6-terra` | Balanced           | General production work; the default choice    |
| `openai/gpt-5.6-luna`  | Lightweight        | High-volume, latency- and cost-sensitive calls |

Prompts above 272K tokens are billed by the upstream at a higher rate than
the one published for the model. Split very long inputs if that matters to
you.

### Other families

* `openai/gpt-5.5`
* `openai/gpt-5.4`
* `openai/gpt-5.4-mini`
* `openai/gpt-5`
* `openai/gpt-5-nano`
* `openai/gpt-4.1`
* `openai/gpt-4.1-nano`
* `openai/gpt-4o`
* `openai/gpt-4o-mini`
* `openai/o3`
* `openai/o4-mini`

Pricing is deliberately not reproduced here. Rates are set per model in the
RouterBase catalogue and can be overridden per account, so any figure copied
into this page is a snapshot that goes stale the next time a rate changes.
Fetch the current rate for any model from the [Models API](/api-reference/models):

```http theme={null}
GET /api/models/{model}/pricing
```

URL-encode the slash in the model id — e.g. `openai%2Fgpt-5.5`.

## Endpoint

```http theme={null}
POST https://routerbase.com/v1/chat/completions
```

Drop-in compatible with the OpenAI [Chat Completions API](https://platform.openai.com/docs/api-reference/chat) —
point your existing OpenAI client at `https://routerbase.com/v1` with
your RouterBase key. See the full [Chat Completions reference](/api-reference/chat-completions)
for every supported parameter.

## Quickstart

```bash theme={null}
curl https://routerbase.com/v1/chat/completions \
  -H "Authorization: Bearer $ROUTERBASE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-5.4",
    "messages": [
      { "role": "user", "content": "Explain prompt caching in one sentence." }
    ]
  }'
```

```python theme={null}
from openai import OpenAI

client = OpenAI(
    base_url="https://routerbase.com/v1",
    api_key="$ROUTERBASE_API_KEY",
)

resp = client.chat.completions.create(
    model="openai/gpt-5.5",
    messages=[{"role": "user", "content": "Hello!"}],
)
print(resp.choices[0].message.content)
```

Set `"stream": true` for token streaming (Server-Sent Events), exactly
like the OpenAI API. Swap `model` for any id from the table above.

## Prompt caching

RouterBase routes every customer through a shared upstream account but
isolates each customer's prompt cache automatically — your cached
prefixes are never shared with, or served to, another customer. You
don't set anything: caching is on by default.

```json theme={null}
"usage": {
  "prompt_tokens": 1247,
  "completion_tokens": 89,
  "prompt_tokens_details": { "cached_tokens": 1200 }
}
```

Streaming responses carry the same breakdown on the final chunk's
`usage`. OpenAI's automatic prefix cache needs a prompt of at least
\~1024 tokens to take effect, so caching benefits long, stable system
prompts and tool definitions.
