Create chat completion
POST /v1/chat/completions — the primary BlazeInfer endpoint.
POST /v1/chat/completionsSends a conversation and returns one assistant message.
Request body
| Field | Type | Required | Notes |
|---|---|---|---|
model | string | yes | A full model ID or an alias. See console |
messages | array | yes | system, user, assistant and tool messages |
max_tokens | integer | no | Cap on the reply. On reasoning models it includes the reasoning tokens, so leave room for them. Set it explicitly |
temperature | number | no | Sampling randomness |
top_p | number | no | Nucleus sampling |
n | integer | no | Number of choices to return |
stream | boolean | no | Return Server-Sent Events |
stream_options | object | no | Leave it out to get a final usage chunk. If you send it, set include_usage: true |
stop | string | string[] | no | Stop sequences. On reasoning models a stop sequence can also match inside the reasoning, which leaves content empty |
seed | integer | no | Best-effort determinism |
logprobs | boolean | no | Return token log probabilities |
tools | array | no | Function definitions — see Tool calling |
tool_choice | string | object | no | auto, none, required or a specific function |
response_format | object | no | {"type": "json_object"} or {"type": "json_schema", ...} — see Structured outputs |
The exact set of request fields a model accepts depends on the model.
Unsupported fields may be rejected with 400.
Response
A standard OpenAI chat completion:
{
"id": "chatcmpl-68a578067bc0c028",
"object": "chat.completion",
"created": 1793684132,
"model": "google/gemma-4-31b-it",
"choices": [
{
"index": 0,
"message": { "role": "assistant", "content": "Hello!" },
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 19,
"completion_tokens": 3,
"total_tokens": 22,
"prompt_tokens_details": { "cached_tokens": 0 }
}
}The response is shortened here; some models add extra fields. Reasoning models
also return their reasoning in message.reasoning_content or
message.reasoning, depending on the model. prompt_tokens_details can be
null on some models.
Streaming
With stream: true, the response is an SSE stream of chat.completion.chunk
objects. The finish_reason arrives in its own chunk with an empty delta.
When you leave out stream_options, or set include_usage: true, a final
chunk with an empty choices list carries usage. The stream ends with
data: [DONE]. See Streaming.
Errors
| Status | When |
|---|---|
400 | The model rejected the request, for example bad JSON, a missing messages field, a prompt that is too long, or tools sent to a model that does not accept them. The message is always The upstream provider rejected the request. |
401 | Missing or invalid API key |
404 | Unknown or unavailable model |
429 | No credit left, or a temporary overload |
503 | The model is temporarily unavailable |
Error responses are JSON, except a 429 from a credit rule, which may be plain
text. See Errors & retries for what to retry.