v1

latestOpenAPI 3.1.02026-07-267724480.0 KB

Chat Completions

Routes chat requests across multiple model providers. Request parameters and response fields can vary significantly by provider, so check the official documentation for the provider behind the model you use when you need provider-specific parameters or behavior details.

post/v1/chat/completions

Request body

modelstring required

Model ID to use for this request. See the Models page for current options.

streamboolean

If true, partial response tokens are delivered incrementally via server-sent events (SSE). The stream ends with a data: [DONE] message.

temperaturenumber

Sampling temperature between 0 and 2. Higher values (e.g., 0.8) produce more random output; lower values (e.g., 0.2) make output more focused and deterministic. Recommended to adjust this or top_p, but not both.

top_pnumber

Nucleus sampling parameter. The model considers only the tokens whose cumulative probability reaches top_p. For example, 0.1 means only the top 10% probability tokens are considered. Recommended to adjust this or temperature, but not both.

ninteger

Number of completion choices to generate for each input message. Defaults to 1.

stopstring

Up to 4 sequences where the API will stop generating further tokens. Can be a string or an array of strings.

max_tokensinteger

Maximum number of tokens to generate in the completion. The total of input + output tokens is capped by the model's context length.

presence_penaltynumber

Number between -2.0 and 2.0. Positive values penalize tokens based on whether they have already appeared, encouraging the model to explore new topics.

frequency_penaltynumber

Number between -2.0 and 2.0. Positive values penalize tokens proportionally to how often they have appeared, reducing verbatim repetition.

logit_biasobject

A JSON object mapping token IDs to bias values from -100 to 100. The bias is added to the model's logits before sampling. Values between -1 and 1 subtly adjust likelihood; -100 or 100 effectively ban or force selection of a token.

userstring

A unique identifier for your end-user. Helps with abuse detection and monitoring.

max_completion_tokensinteger

An upper bound for the number of tokens to generate, including visible output tokens and reasoning tokens. Use this instead of max_tokens for GPT-4.1+, GPT-5 series, and o-series models.

logprobsboolean

Whether to return log probabilities of the output tokens.

top_logprobsinteger

Number of most likely tokens to return at each position (0-20). Requires logprobs to be true.

reasoning_effort'low' | 'medium' | 'high'

Controls the reasoning effort for o-series and GPT-5.1+ models.

service_tier'auto' | 'default' | 'flex' | 'priority'

Specifies the processing tier.

Example request

{
  "model": "gpt-4.1"
}

Response

Successful chat completion response.

idstring

Unique completion identifier.

object'chat.completion'

Object type. Non-streaming responses use chat.completion.

createdinteger

Unix timestamp of creation.

modelstring

The model used (may include version suffix).

service_tierstring

Service tier that processed the request, when the provider reports one.

system_fingerprintstring nullable

Provider backend configuration fingerprint, when the provider reports one.

Example response

{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 1774412483,
  "model": "gpt-5.4-2026-03-05",
  "usage": {
    "prompt_tokens": 29,
    "completion_tokens": 2,
    "total_tokens": 31
  },
  "service_tier": "default",
  "system_fingerprint": "fp_490a4ad033"
}