Skip to content

POST /chat/completions

Create a chat completion, streamed or not. The request body, the response and the status codes.

POST/api/v1/chat/completionsAPI key

Creates a chat completion in the OpenAI format. The full list of body fields with what each does: Parameters. The machine-readable contract: openapi.yaml.

Request body

FieldType
modelstringModel id. Required unless models is given.
modelsstring[]Fallback models, tried after model.
messagesobject[]Required. The conversation.
streambooleanServer-sent events instead of one JSON.
max_tokens, max_completion_tokensintegerOutput limit, 1 to 65536; 4096 when absent.
tools, tool_choiceTool calling.
response_formatobjectJSON mode or JSON Schema.
reasoningobjectReasoning effort and budget.
providerobjectonly, ignore, order, allow_fallbacks, zdr, data_collection.
any other fieldPassed to the provider.

Response

Without stream: a chat.completion object.

FieldType
idstringGeneration id, gen-<uuid>.
objectstringchat.completion
createdintegerUnix time.
modelstringThe model that answered.
providerstringThe hosting provider (Global) or Russia.
choices[].messageobjectrole, content, tool_calls, reasoning.
choices[].finish_reasonstringstop, length, tool_calls, content_filter or error.
choices[].native_finish_reasonstringThe provider's own value.
usageobjectprompt_tokens, completion_tokens, total_tokens, cost (PnP), prompt_tokens_details.cached_tokens, completion_tokens_details.reasoning_tokens.

With "stream": true: text/event-stream of chat.completion.chunk events, keep-alive comments, a final chunk with usage, then data: [DONE]. See Streaming.

Headers

Header
X-Request-IdOn every response.
X-Generation-IdOn streamed responses; a non-streamed response has the id in id.

Status codes

200, 400, 401, 402, 403, 409, 413, 422, 429, 502, 503, 504: see Errors.

Example

curl https://router.nodul.ru/api/v1/chat/completions \
  -H "Authorization: Bearer $NODUL_ROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "google/gemma-3-4b-it", "messages": [{"role": "user", "content": "Hello"}], "max_tokens": 100}'

Try requests with your key in the playground on the API page of your space in the cabinet.

Nodul Router — one API for every model