---
title: "Create chat completion (OpenAI-compatible)"
method: POST
path: "/openai/chat/completions"
tags: ["Inference", "dev-api"]
---

# Create chat completion (OpenAI-compatible)

`POST /openai/chat/completions`

## Request

- Base URL: `https://gateway.prem.io`
- URL: `https://gateway.prem.io/openai/chat/completions`
- Auth: HTTP bearer and API key in header `Authorization`

Create a chat completion. Compatible with the OpenAI Chat Completions API. Not end-to-end encrypted — use `/rvenc/chat/completions` for that.

## Headers

- `X-Queue-Timeout` string

## Request body

- CreateOpenAiChatCompletionRequest: Chat completion request in the OpenAI Chat Completions format.
  - `model` string, required: Model name, as listed by `GET /models`.
  - `messages` object[], required: Conversation messages.
  - `stream` boolean: If true, the response is a server-sent events stream.
  - `provider` string: Optional. Pin the request to one of the model's configured backends. Omit to let the platform choose.

## Response `200`

A chat completion, or a server-sent events stream when `stream` is true.

- object

## Other responses

- `400`: Bad request
- `401`: Access token is missing or invalid
- `403`: You do not have the required permissions to access this resource
- `404`: Resource not found
- `429`: Too many requests
- `502`: Upstream service failed
- `503`: Service temporarily unavailable

## Changes

- **2026-11-13** `d46bc3931b34`: 21 warning, 2 info
  - added the new `405.00` enum value to the `allOf[subschema #1]/status` response property for the response status `401`
  - added the new `405.00` enum value to the `allOf[subschema #1]/status` response property for the response status `403`
  - added the new `405.00` enum value to the `allOf[subschema #1]/status` response property for the response status `404`
  - added the new `405.00` enum value to the `status` response property for the response status `400`
  - …19 more
- **2026-10-16** `d5b1beb33be5`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/premai-io/apis/prem-studio-api/changes/openai/chat/completions/post.md)

---

[API](https://skmtc.dev/premai-io/apis/prem-studio-api.md) - [All operations](https://skmtc.dev/premai-io/apis/prem-studio-api/llms.txt) - [OpenAPI document](https://skmtc.dev/premai-io/apis/prem-studio-api/revisions/d46bc3931b34?raw)
