Skip to main content
POST
Create a chat completion

Authorizations

Authorization
string
header
required

Virtual API key. Create one from the FlexAI dashboard. Pass as Authorization: Bearer sk-xxxx.

Body

application/json
model
string
required

Model id. See GET /v1/models for available models.

Example:

"Meta-Llama-3.1-8B-Instruct-FP8"

messages
object[]
required
stream
boolean
default:false
stream_options
object
temperature
number
default:1
Required range: 0 <= x <= 2
top_p
number
Required range: 0 <= x <= 1
max_tokens
integer
Required range: x >= 1
tools
object[]
tool_choice
Available options:
none,
auto,
required
response_format
object
seed
integer
stop
user
string
max_completion_tokens
integer

Newer name for max_tokens; either is honored as-is. Non-streaming requests that set neither default to 2048 output tokens on non-reasoning models (the response then carries x-flexai-max-tokens-defaulted: 2048); reasoning models get no default and are bounded by the non-streaming time budget instead.

Required range: x >= 1
reasoning_effort
enum<string>

Accepted values differ by model. Models with a depth dial take the five gateway levels minimal, low, medium, high, max and return 400 for any other value, including none and xhigh: gpt-oss-120b/gpt-oss-20b accept low, medium, high only; DeepSeek-V4-Flash-0731 accepts all five (only minimal keeps it off; low, medium and high select the model's high effort level, with low and medium reported as x-flexai-adjusted-params: reasoning_effort=high; max selects its maximum). A word that is no effort level at all is a 400 on every reasoning model; a model with no reasoning at all drops the parameter and reports x-flexai-dropped-params. Models with a reasoning on/off switch but no depth dial (gemma-4-31b-it, gemma-4-26B-A4B-it, Qwen3.5-9B, Qwen3.6-27B-FP8, Qwen3.6-35B-A3B-FP8, GLM-4.5-Air-FP8, Qwen3-8B-FP8, NVIDIA-Nemotron-3.5-Lightning-30B-A3B) take all seven values: low, medium, high, xhigh and max turn reasoning on at the model's own depth and the response carries x-flexai-adjusted-params: reasoning_effort=on; none and minimal leave it off. An explicit thinking or chat_template_kwargs.enable_thinking switch wins over a contradicting effort, which is then reported in x-flexai-dropped-params. Reasoning is off by default on every model with an on/off switch; thinking {type: enabled} (or OpenRouter reasoning) turns it on everywhere.

Available options:
none,
minimal,
low,
medium,
high,
xhigh,
max
thinking
object

On/off switch for reasoning on reasoning-capable models; takes precedence over reasoning_effort. disabled turns reasoning off even if reasoning_effort is sent; enabled alone turns it on at the model's default depth. Omitting both reasoning_effort and thinking leaves reasoning off on every switchable model. On a model that cannot stop reasoning (gpt-oss-120b, gpt-oss-20b and the always-thinking models) disabled is a 400 naming thinking, never a silent 200.

Response

Successful response. When stream: true, body is an SSE stream of text/event-stream chunks.

id
string
required
object
enum<string>
required
Available options:
chat.completion
created
integer
required
model
string
required
choices
object[]
required
usage
object