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

# Chat Completions

> Reference the Chat Completions-compatible request, response, streaming, and error behavior.

```text theme={null}
POST /inf/v1/chat/completions
```

This route always accepts and returns OpenAI Chat Completions. Headers and request-body fields cannot select another
caller protocol.

## Request

```bash theme={null}
curl https://llm.example.com/inf/v1/chat/completions \
  -H "Authorization: Bearer $AIRMUX_INFERENCE_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "openai/gpt-4o-mini",
    "messages": [{"role": "user", "content": "Say hello"}],
    "max_completion_tokens": 128
  }'
```

## Core fields

| Field                   | Type             | Notes                                                 |
| ----------------------- | ---------------- | ----------------------------------------------------- |
| `model`                 | string           | Required catalog model ID                             |
| `messages`              | array            | System, developer, user, assistant, and tool messages |
| `stream`                | boolean          | Defaults to `false`                                   |
| `max_tokens`            | integer          | Legacy Chat Completions spelling; minimum 1           |
| `max_completion_tokens` | integer          | Current Chat Completions spelling; minimum 1          |
| `temperature`           | number           | Minimum 0                                             |
| `top_p`                 | number           | Greater than 0 and at most 1                          |
| `stop`                  | string or array  | Normalized to an array                                |
| `seed`                  | integer          | Forwarded when supported                              |
| `tools`                 | array            | Function tools                                        |
| `tool_choice`           | string or object | `auto`, `none`, `required`, or a named function       |
| `parallel_tool_calls`   | boolean          | Requires provider support when supplied               |
| `response_format`       | object           | `text`, `json_object`, or `json_schema`               |
| `reasoning_effort`      | string           | Folded into canonical reasoning configuration         |
| `reasoning`             | object           | Extended reasoning configuration                      |

Other top-level fields are treated as provider extras. A provider profile either forwards them or reports them as dropped in `gateway.adjustments`.
Supplying both output-limit fields is invalid. Either field maps to canonical `max_output_tokens`.

## Response

```json theme={null}
{
  "id": "019...",
  "object": "chat.completion",
  "created": 1789000000,
  "model": "openai/gpt-4o-mini",
  "choices": [
    {
      "index": 0,
      "message": {"role": "assistant", "content": "Hello!"},
      "finish_reason": "stop"
    }
  ],
  "usage": {"prompt_tokens": 8, "completion_tokens": 2, "total_tokens": 10},
  "gateway": {"finish_reason": "stop", "adjustments": []}
}
```

`finish_reason` is one of `stop`, `length`, `tool_calls`, or `content_filter` when present.

## Streaming

Streaming returns Chat Completions SSE chunks, a terminal choice carrying `finish_reason`, a usage-only chunk with
`choices: []` and `gateway`, then `data: [DONE]`. Usage is always included even if the caller omits `stream_options`.
