# Gateway APIs

> The OpenAI- and Anthropic-compatible gateway APIs Agent Router supports, including Chat Completions, Responses, Messages, and model discovery via /v1/models.

Agent Router supports three inference API formats: the OpenAI Chat Completions API, the OpenAI Responses API, and the Anthropic Messages API, plus an OpenAI-compatible Models endpoint for discovering which models are routable for your API key. All gateway features (routing, fallback policies, traffic splitting, cost tracking, and observability) apply equally regardless of the format chosen. Applications send requests in one format, and the gateway handles provider translation transparently, normalising responses and errors back to the format that was requested. For new projects with no existing SDK preference, Chat Completions offers the widest ecosystem compatibility.

:::tip Management APIs live elsewhere
These are the gateway inference endpoints that applications and SDKs hit. The OpenAPI catalog does not enumerate `/v1/chat/completions` and the other paths on this page. For provisioning keys, clients, models, and other control-plane operations, use the [Management API reference](/reference/api/).
:::

## Endpoint summary

| Format | Path | SDK Method | Streaming |
| --- | --- | --- | --- |
| OpenAI Chat Completions | `/v1/chat/completions` | `client.chat.completions.create()` | `stream=True` |
| OpenAI Responses | `/v1/responses` | `client.responses.create()` | `stream=True` |
| Anthropic Messages | `/v1/messages` | `client.messages.create()` | `stream=True` |
| Models | `/v1/models` | `client.models.list()` | n/a |

In the examples below, replace `PROXY_URL` with the proxy endpoint shown on the Console Dashboard (for example, `https://proxy.poc.tetrate.ai/v1`) and `YOUR_API_KEY` with a key from [API Keys](/agent-router-service/guides/route-requests-across-providers/).

---

## Chat Completions API (`/v1/chat/completions`)

The most widely supported format, compatible with OpenAI and most third-party SDKs.

### Non-streaming

```bash
curl PROXY_URL/chat/completions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o",
    "messages": [{"role": "user", "content": "Hello, world!"}]
  }'
```

```python
from openai import OpenAI

client = OpenAI(
    base_url="PROXY_URL",
    api_key="YOUR_API_KEY",
)

response = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Hello, world!"}],
)

print(response.choices[0].message.content)
```

### Streaming

```bash
curl PROXY_URL/chat/completions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o",
    "messages": [{"role": "user", "content": "Hello, world!"}],
    "stream": true
  }'
```

```python
from openai import OpenAI

client = OpenAI(
    base_url="PROXY_URL",
    api_key="YOUR_API_KEY",
)

stream = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Hello, world!"}],
    stream=True,
)

for chunk in stream:
    content = chunk.choices[0].delta.content
    if content:
        print(content, end="", flush=True)
```

### SSE format

Chat Completions streaming uses data-only SSE. Each event is a `data:` line containing a JSON object, terminated by `data: [DONE]`:

```text
data: {"id":"chatcmpl-...","object":"chat.completion.chunk","choices":[{"delta":{"content":"Hello"}}]}

data: {"id":"chatcmpl-...","object":"chat.completion.chunk","choices":[{"delta":{"content":" world"}}]}

data: [DONE]
```

To receive token usage in the stream, add `"stream_options": {"include_usage": true}` to the request. Usage appears in the final chunk before `[DONE]`:

```json
{"prompt_tokens": 10, "completion_tokens": 5, "total_tokens": 15}
```

---

## Responses API (`/v1/responses`)

The newer OpenAI Responses API provides a simplified interface with semantic streaming events.

### Non-streaming

```bash
curl PROXY_URL/responses \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o",
    "input": "Hello, world!"
  }'
```

```python
from openai import OpenAI

client = OpenAI(
    base_url="PROXY_URL",
    api_key="YOUR_API_KEY",
)

response = client.responses.create(
    model="gpt-4o",
    input="Hello, world!",
)

print(response.output_text)
```

### Streaming

```bash
curl PROXY_URL/responses \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o",
    "input": "Hello, world!",
    "stream": true
  }'
```

```python
from openai import OpenAI

client = OpenAI(
    base_url="PROXY_URL",
    api_key="YOUR_API_KEY",
)

stream = client.responses.create(
    model="gpt-4o",
    input="Hello, world!",
    stream=True,
)

for event in stream:
    if event.type == "response.output_text.delta":
        print(event.delta, end="", flush=True)
```

### SSE format

Responses API streaming uses semantic `event:` plus `data:` lines. Each event has a named type describing what happened:

```text
event: response.created
data: {"id":"resp_...","object":"response","status":"in_progress"}

event: response.output_item.added
data: {"item":{"id":"msg_...","type":"message","role":"assistant"}}

event: response.output_text.delta
data: {"delta":"Hello"}

event: response.output_text.delta
data: {"delta":" world"}

event: response.output_text.done
data: {"text":"Hello world"}

event: response.completed
data: {"id":"resp_...","status":"completed","usage":{"input_tokens":10,"output_tokens":5}}
```

### Differences from Chat Completions

| Aspect | Chat Completions | Responses API |
| --- | --- | --- |
| Input field | `messages` array | `input` (string or array) |
| Usage fields | `prompt_tokens` / `completion_tokens` | `input_tokens` / `output_tokens` |
| SSE format | Data-only (`data: {...}`) with `data: [DONE]` sentinel | Semantic events (`event: response.created`, etc.) |
| Stream usage | Opt-in via `stream_options.include_usage` | Always in `response.completed` event |
| Response access | `response.choices[0].message.content` | `response.output_text` |

---

## Anthropic Messages API (`/v1/messages`)

For applications built with the Anthropic SDK. The gateway accepts standard `Authorization: Bearer` headers; the Anthropic-native `x-api-key` header is not required.

### Non-streaming

```bash
curl PROXY_URL/messages \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -H "anthropic-version: 2023-06-01" \
  -d '{
    "model": "claude-sonnet-4-20250514",
    "max_tokens": 1024,
    "messages": [{"role": "user", "content": "Hello, world!"}]
  }'
```

```python
from anthropic import Anthropic

client = Anthropic(
    base_url="PROXY_URL",
    auth_token="YOUR_API_KEY",
)

response = client.messages.create(
    model="claude-sonnet-4-20250514",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Hello, world!"}],
)

print(response.content[0].text)
```

### Streaming

```bash
curl PROXY_URL/messages \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -H "anthropic-version: 2023-06-01" \
  -d '{
    "model": "claude-sonnet-4-20250514",
    "max_tokens": 1024,
    "messages": [{"role": "user", "content": "Hello, world!"}],
    "stream": true
  }'
```

```python
from anthropic import Anthropic

client = Anthropic(
    base_url="PROXY_URL",
    auth_token="YOUR_API_KEY",
)

with client.messages.stream(
    model="claude-sonnet-4-20250514",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Hello, world!"}],
) as stream:
    for text in stream.text_stream:
        print(text, end="", flush=True)
```

### SSE format

Anthropic Messages streaming uses semantic `event:` plus `data:` lines with block-level granularity:

```text
event: message_start
data: {"type":"message_start","message":{"id":"msg_...","role":"assistant","model":"claude-sonnet-4-20250514"}}

event: content_block_start
data: {"type":"content_block_start","index":0,"content_block":{"type":"text","text":""}}

event: content_block_delta
data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"Hello"}}

event: content_block_delta
data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" world"}}

event: content_block_stop
data: {"type":"content_block_stop","index":0}

event: message_delta
data: {"type":"message_delta","delta":{"stop_reason":"end_turn"},"usage":{"output_tokens":5}}

event: message_stop
data: {"type":"message_stop"}
```

:::note
When using the gateway, authenticate with `Authorization: Bearer YOUR_API_KEY` instead of the Anthropic-native `x-api-key` header. The gateway translates the auth header before forwarding to the provider.
:::

---

## Models API (`/v1/models`)

List the models available to your API key. The endpoint is OpenAI-compatible and requires authentication. Use each returned `id` as the `model` value in Chat Completions, Responses, Messages, and other inference calls.

The response follows the OpenAI list shape (`object: "list"` with a `data` array) and extends each model object with pricing and capability fields used for routing and cost awareness.

### Request

```bash
curl PROXY_URL/models \
  -H "Authorization: Bearer YOUR_API_KEY"
```

```python
from openai import OpenAI

client = OpenAI(
    base_url="PROXY_URL",
    api_key="YOUR_API_KEY",
)

models = client.models.list()
for model in models.data:
    print(model.id)
```

### Response

The example below is truncated. A live response returns every model routable for the key.

```json
{
  "object": "list",
  "data": [
    {
      "id": "claude-sonnet-4-6",
      "object": "model",
      "created": 1771393580,
      "owned_by": "system",
      "input_price": "0.000003",
      "caching_price": "0.00000375",
      "cached_price": "0.0000003",
      "output_price": "0.000015",
      "max_output_tokens": 64000,
      "context_window": 1000000,
      "supports_caching": true,
      "supports_vision": true,
      "supports_computer_use": true,
      "supports_reasoning": true
    },
    {
      "id": "gpt-4o-mini",
      "object": "model",
      "created": 1773126109,
      "owned_by": "system",
      "input_price": "0.00000015",
      "caching_price": "0",
      "cached_price": "0.000000075",
      "output_price": "0.0000006",
      "max_output_tokens": 16384,
      "context_window": 128000,
      "supports_caching": false,
      "supports_vision": true,
      "supports_computer_use": true,
      "supports_reasoning": false
    }
  ]
}
```

:::note
`GET /v1/models` returns the models routable for the calling key. For the unauthenticated public catalog with richer metadata, see `https://router.tetrate.ai/api/public/models`. For management-plane catalog CRUD, use `GET /v1/catalog/models` (documented in the [API reference](/reference/api/catalog/agentrouter-catalog-v-1-catalog-service-list-models/)).
:::

---

## Supported endpoint types

The gateway handles nine endpoint types. All use the same model-based routing logic; fallback policies and traffic splitting apply equally across every endpoint.

| Endpoint | Path | Description |
| --- | --- | --- |
| Chat Completions | `/v1/chat/completions` | Standard chat interface (OpenAI-compatible) |
| Completions | `/v1/completions` | Legacy text completions |
| Responses | `/v1/responses` | OpenAI Responses API |
| Messages | `/v1/messages` | Anthropic Messages API |
| Embeddings | `/v1/embeddings` | Text embeddings |
| Images | `/v1/images` | Image generation |
| Audio speech | `/v1/audio/speech` | Text-to-speech (OpenAI-compatible) |
| Rerank | `/v1/rerank` | Reranking |
| Models | `/v1/models` | List available models |

:::note Speech-to-text is not supported
`/v1/audio/transcriptions` returns "Unsupported endpoint". Speech-to-text (Whisper-style) models cannot be called through the gateway.
:::

---

## Provider translation

The gateway automatically translates between the canonical (OpenAI-compatible) schema and 25+ provider-specific APIs. Applications send requests in one format, and the gateway handles all conversions transparently.

**Translated elements:**

- **Request body**: field names, structure, and defaults adjusted per provider
- **Path**: endpoint paths mapped to provider conventions
- **Headers**: authentication and provider-specific headers set automatically
- **Response format**: provider responses normalised back to the format that was requested

For example, an OpenAI Chat Completions request that routes to Anthropic Claude is translated to the Anthropic Messages format before being forwarded, and the response is translated back to Chat Completions format. The application never sees the difference.

No configuration is needed; translation is built into the gateway. For how errors are normalised across providers, see [Gateway Behavior](/reference/gateway-behavior/).

---

## Protocols

The gateway supports REST (HTTPS) for all inference traffic. This is the only protocol needed to use any endpoint.

gRPC is used internally for OpenTelemetry (OTLP) telemetry export. See [OpenTelemetry Export](/agent-router-enterprise/guides/observability-and-analytics/export-telemetry-to-an-observability-stack/) for the configuration surface. WebSocket and gRPC for inference are not currently supported.

---

## Choosing an API format

| Use case | Recommended format |
| --- | --- |
| Widest SDK and tool compatibility | Chat Completions |
| New OpenAI projects with the simplified interface | Responses API |
| Anthropic Claude-native applications | Anthropic Messages |
| Agent frameworks (LangChain, CrewAI, and similar) | Chat Completions |
| Code assistants (Cursor, Cline, Aider) | Chat Completions |
| Streaming with semantic events | Responses API or Anthropic Messages |

All three formats support the same gateway features. The choice is driven by SDK preference and provider ecosystem alignment.

## Related

- [Integrate the Gateway with an App](/agent-router-service/guides/integrate-the-gateway-with-an-app/): developer-side integration patterns for each SDK
- [Gateway Behavior](/reference/gateway-behavior/): request handling, error semantics, and routing resolution rules

Where to go next

  <Link to="/reference/api/" className="tare-nav-card">
    Management API reference
    Control-plane OpenAPI catalog: clients, keys, catalog, and related services.
  </Link>
  <Link to="/reference/gateway-behavior/" className="tare-nav-card">
    Gateway behavior
    How requests are handled, normalised, and routed.
  </Link>
