Skip to main content
POST
POST /v1/chat/completions Send a chat request to any supported provider through the gateway. The response format is identical to OpenAI’s chat completions API regardless of which provider handles the request.

Auth

All three schemes are accepted:
Bearer (OIDC) is supported but in Alpha. Contact us if you need OIDC auth.

Request

Gateway-specific fields

Response

Non-streaming

Response headers

Streaming

When stream: true, the response is an OpenAI-compatible SSE stream. Each data: line is a JSON chunk. Final line is data: [DONE].

Examples

Structured output

With fallback chain

Errors

Authorizations

Authorization
string
header
required

OIDC JWT issued by your auth provider (Alpha). Full self-serve configuration is coming soon — contact us for early access. Use this for browser/frontend clients where a user is signed in.

Body

application/json
model
string
required

Model in provider/model-id format. Supported providers: openai, anthropic, google, mistral.

Examples:

"openai/gpt-4o"

"anthropic/claude-3-5-sonnet-20241022"

"google/gemini-2.5-flash"

"mistral/mistral-large-latest"

messages
object[]
required
Minimum array length: 1
max_tokens
integer

Maximum tokens to generate. The gateway maps this to the correct upstream parameter — max_completion_tokens for OpenAI reasoning models, max_tokens for everything else.

Example:

1024

temperature
number

Sampling temperature. Omit for reasoning models (o3, o3-mini, o4-mini) — the gateway strips it automatically based on the model catalog.

Required range: 0 <= x <= 2
Example:

0.7

top_p
number

Nucleus sampling. Supported by all providers.

Required range: 0 <= x <= 1
stream
boolean
default:false

When true, the response is an OpenAI-compatible SSE stream. Each data: line is a JSON object regardless of the upstream provider.

x-gatelit-output-schema
object

Structured output configuration. The gateway translates to the correct provider-specific format automatically.

x-gatelit-prompt-id
string

Associates this request with a saved prompt in the dashboard. The prompt's content is not used — only the ID is logged for correlation.

x-gatelit-fallback-chain
object[]

Ordered list of fallback models to try if the primary model fails. Each entry specifies a model and the error types that trigger it.

Response

Successful response.

  • Non-streaming: Content-Type: application/json
  • Streaming: Content-Type: text/event-stream

Response headers always include:

  • x-gatelit-request-id — use for log lookup in the dashboard
  • x-gatelit-model — the provider/model that responded
  • x-gatelit-auth-modeBearer, GatelitSigned, or GatelitKey

OpenAI-compatible chat completion response. Returned when stream is false (default).

id
string
object
string
Example:

"chat.completion"

created
integer
model
string

The upstream model that handled the request.

choices
object[]
usage
object