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

# Chat completions

> Generate a response from the model connected to your project.

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

Requires an account-linked API key or signed-in session from the project team. The runtime must already be Ready; this call does not start a demo.

## Request

```bash theme={null}
curl "https://platform.r3al.ai/v1/projects/$R3AL_PROJECT_ID/chat/completions" \
  -H "Authorization: Bearer $R3AL_API_KEY" \
  -H 'Content-Type: application/json' \
  --data @- <<EOF
{
  "model": "$R3AL_PROJECT_ID",
  "messages": [{"role": "user", "content": "Insurance Query: How can I check the status of an insurance claim?"}],
  "max_tokens": 512,
  "stream": false
}
EOF
```

| Field | Requirement |
| - | - |
| `model` | Required. Must equal the project ID in the URL. |
| `messages` | Required. 1–100 text messages with `system`, `user`, or `assistant` roles. The last message must be from the user. |
| `max_tokens` | 1–4096; default 512. The connected model may have a smaller context limit. |
| `temperature` | 0–2; default 0. |
| `stream` | Must be `false`; defaults to `false`. |

Each message allows up to 16,000 characters; combined content allows up to 64,000. These request limits do not guarantee that input fits the model's token context. Additional fields are rejected.

## Response

Read the assistant's text from `choices[0].message.content`. A successful response includes a chat completion ID, the project ID as `model`, a choice with its finish reason, and usage when reported by the runtime.

## Errors

| HTTP status | Meaning |
| - | - |
| 401 | Missing, invalid, or unsuitable credentials. |
| 404 | Project does not exist or is outside your team. |
| 422 | Invalid request, unsupported streaming, model ID mismatch, or context limit. |
| 429 | The model is busy; retry after a short delay. |
| 502 | The runtime returned an invalid or mismatched response. |
| 503 | Runtime not connected, loading, stopped, or unavailable. |
| 504 | Inference timed out. |

Runtime failures include `error` and `code`. Check [access status](/api/runtime) before retrying. Avoid unbounded retries while a model is loading.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.