Skip to main content
POST
Create Chat Completion

Create Chat Completion

POST /v1/chat/completions

Request Body

string
required
Model to use for completion (e.g., gpt-4o, gpt-5.1, claude-sonnet-4-6, deepseek-r1). Append :reasoning-exclude to disable reasoning output for a single request.
array
required
Array of message objects forming the conversation.
integer
Maximum number of tokens to generate. Reasoning tokens are billed as output tokens and counted against this limit.
number
Sampling temperature between 0 and 2.
boolean
Enable streaming responses (SSE).
string
Controls reasoning depth on supported models. One of none, minimal, low, medium, high, xhigh. Silently ignored for models that don’t support reasoning_effort.
object
Reasoning configuration object. Supports:
  • reasoning.effort — same enum as reasoning_effort.
  • reasoning.exclude (boolean) — strip reasoning from the response entirely.
  • reasoning.delta_field"reasoning" or "reasoning_content"; overrides the streaming/non-streaming field name regardless of which endpoint variant was hit.
string
Shorthand for reasoning.delta_field. Accepts "reasoning" or "reasoning_content".
boolean
Shorthand: set to true to force the legacy reasoning_content field, equivalent to reasoning.delta_field = "reasoning_content".

Endpoint Variants (Reasoning Output)

Some models emit a separate reasoning / thinking stream in addition to the final answer. Three base paths control how that stream is surfaced — all of them accept the same request shape and model names. Per-request overrides (reasoning.delta_field, reasoning_delta_field, reasoning_content_compat) take precedence over the endpoint default. If a model does not emit reasoning, these fields are simply absent from the response.

Streaming output shape

When reasoning is delivered as a separate field, deltas are interleaved — reasoning chunks come first, followed by content chunks:
Against /v1legacy/chat/completions the same deltas use delta.reasoning_content instead of delta.reasoning. Against /v1thinking/chat/completions everything appears in delta.content:

Non-streaming output shape

reasoning becomes reasoning_content on /v1legacy/. On /v1thinking/, the reasoning stays embedded inside content ("<think>...</think>The answer...") and no separate field is emitted.

Disabling Reasoning Output

Reasoning can be hidden in three equivalent ways — the model still pays the cost for reasoning compute, but the tokens are stripped from the response:
  1. Request body: { "reasoning": { "exclude": true } }
  2. Model suffix: "model": "deepseek-r1:reasoning-exclude"
  3. Request body: { "reasoning_effort": "none" } (only honored on OpenAI-shaped models — safely ignored elsewhere for API parity).
When excluded, neither the reasoning field nor <think> tags appear in the response, regardless of which endpoint variant was hit.

Example

Streaming

Enable real-time responses with streaming:

Function Calling

Use function calling for tool integration:

Authorizations

Authorization
string
header
required

Enter your API key (starts with 'ek-')

Body

application/json
model
string
required

Model to use for completion

Example:

"gpt-4o"

messages
object[]
required

List of messages

stream
boolean
default:false

Enable streaming

max_tokens
integer

Maximum tokens to generate

temperature
number
default:1

Sampling temperature

Required range: 0 <= x <= 2
top_p
number
default:1

Nucleus sampling

Required range: 0 <= x <= 1
top_k
integer

Top-k sampling

frequency_penalty
number
default:0
Required range: -2 <= x <= 2
presence_penalty
number
default:0
Required range: -2 <= x <= 2
tools
object[]

List of tools

tool_choice
Available options:
none,
auto

Enable web search

thinking
object
reasoning_effort
enum<string>

Reasoning effort level. Silently ignored for models that do not support reasoning_effort, so clients can send a single shared request across providers.

Available options:
none,
minimal,
low,
medium,
high,
xhigh
reasoning
object

Reasoning configuration. Per-request override for reasoning output behavior.

reasoning_delta_field
enum<string>

Shorthand for reasoning.delta_field.

Available options:
reasoning,
reasoning_content
reasoning_content_compat
boolean

Shorthand: set to true to force the legacy reasoning_content field, equivalent to reasoning.delta_field = "reasoning_content".

Response

200 - application/json

Success

id
string
required
object
string
required
Example:

"chat.completion"

created
integer
required
model
string
required
choices
object[]
required
usage
object