---
title: "Create a chat completion"
method: POST
path: "/v1/chat/completions"
tags: ["Gateway"]
---

# Create a chat completion

`POST /v1/chat/completions`

## Request

- Base URL: `https://api.roar-ai.com`
- URL: `https://api.roar-ai.com/v1/chat/completions`
- Auth: HTTP bearer

OpenAI-compatible. Streaming (`"stream": true`) returns SSE. Routed, metered, and white-labelled. Name any model from `GET /v1/models`. Requires `inference`.

**Calling from a browser.** Requests carrying an `Origin` header are refused with a 403 unless they also send `x-roar-dangerous-browser-access: true`. Your API key belongs on your server: put it in a web page and every visitor can read it, and there is no way to un-leak it afterwards. Send the header only when that is genuinely what you want — an internal tool, or an app where each person supplies their own key. Server-side calls send no `Origin` and are unaffected.

## Request body

- ChatCompletionRequest
  - `model` string, required: A model id from /v1/models
  - `messages` object[], required
    - `role` string
    - `content` string
  - `stream` boolean
  - `temperature` number
  - `tools` object[]

## Response `200`

A chat completion (or SSE stream)

## Other responses

- `401`: Missing or invalid key
- `402`: Budget exceeded
- `403`: Called from a browser without `x-roar-dangerous-browser-access: true`
- `429`: Rate limited

---

[API](https://skmtc.dev/roar-ai/apis/roar-ai-api.md) · [All operations](https://skmtc.dev/roar-ai/apis/roar-ai-api/llms.txt) · [OpenAPI document](https://skmtc.dev/roar-ai/apis/roar-ai-api/revisions/37e4d0d5a7fe?raw)
