# Chat completions

```text
POST https://api.continuumlabs.ai/v1/chat/completions
```

Send a conversation and get the model's next message. This is the same format as OpenAI's chat completions endpoint.

## Request

```bash
curl https://api.continuumlabs.ai/v1/chat/completions \
  -H "Authorization: Bearer cl-your-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "glm-5.2",
    "messages": [
      {"role": "system", "content": "You are a careful assistant. Use Australian English."},
      {"role": "user", "content": "Summarise the Notifiable Data Breaches scheme in two sentences."}
    ],
    "temperature": 0.2,
    "max_tokens": 300
  }'
```

## Parameters

| Parameter | Type | What it does |
|---|---|---|
| `model` | string, required | Which model to use. See [models](/docs/models). |
| `messages` | array, required | The conversation so far. Each message has a `role` (`system`, `user`, `assistant` or `tool`) and `content`. |
| `temperature` | number | Randomness, from 0 to 2. Use 0 to 0.3 for extraction and analysis, higher for drafting. |
| `max_tokens` | integer | The most tokens the model may write in its reply. Defaults to 4,096, up to 32,768. Also sets the most a request can cost, which is set aside from your credit until it finishes. |
| `top_p` | number | An alternative to temperature. Change one or the other, not both. |
| `stop` | string or array | Text that ends the reply when the model writes it. |
| `stream` | boolean | Send the reply as it is written. See [streaming](/docs/streaming). |
| `tools` | array | Functions the model may call. See [tool calling](/docs/tool-calling). |
| `tool_choice` | string or object | `auto`, `none`, `required`, or a specific function. |
| `response_format` | object | `{"type": "json_object"}` for JSON. See [JSON output](/docs/json-output). |

Other OpenAI parameters are passed to the model unchanged. Whether a model honours them depends on the model.

## Response

```json
{
  "id": "chatcmpl-...",
  "object": "chat.completion",
  "model": "glm-5.2",
  "choices": [
    {
      "index": 0,
      "message": {"role": "assistant", "content": "The scheme requires..."},
      "finish_reason": "stop"
    }
  ],
  "usage": {"prompt_tokens": 41, "completion_tokens": 58, "total_tokens": 99}
}
```

| Field | What it means |
|---|---|
| `choices[0].message.content` | The model's reply. |
| `choices[0].message.tool_calls` | Functions the model wants to call, if you sent `tools`. |
| `choices[0].finish_reason` | `stop` when the model finished, `length` when it hit `max_tokens`, `tool_calls` when it wants to call a function. |
| `usage` | Tokens used. This is what your account is charged for. |

Some models reason before they answer and return their working in `message.reasoning_content`. Those reasoning tokens are counted in `completion_tokens`.

## Limits

- A request can be up to 4 MB.
- The whole conversation, plus the reply, must fit in the model's context. See [models](/docs/models).
- Requests that run longer than five minutes are stopped. Use [streaming](/docs/streaming) for long replies.

## Response headers

| Header | What it means |
|---|---|
| `x-continuum-region` | The region the gateway ran in for this request, as reported by our host, for example `syd1` for Sydney. |
