Chat completions

Request fields, message roles and response shape.

POST /v1/chat/completions

Requires an inference key, account access and sufficient balance and key budget. uRouter validates the request, reserves a maximum cost and settles the actual charge. Accounts without access receive 503; invalid keys receive 401.

Minimal body

Requires an account with paid inference access.

{
  "model": "MODEL_ID",
  "messages": [
    {
      "role": "user",
      "content": "Explain what an API is in one sentence."
    }
  ],
  "max_tokens": 256
}

Fields

Use the exact model ID. These are schema bounds, not a guarantee that every model accepts every value. Unknown fields are rejected.

Fields
FieldType / boundsPurpose
modelstring, 1–150 charactersRequired public model ID.
messagesarray, 1–500 itemsRequired conversation history.
max_tokens / max_completion_tokensinteger, 1–131072Output ceiling. Use one; model-specific limits can be lower.
temperaturenumber, 0–2Sampling temperature.
top_pnumber, 0–1Nucleus sampling.
stopstring or up to 8 stringsEach string up to 200 characters.
streambooleanRequest event-stream output.
stream_options.include_usagebooleanRequest usage in the stream.
tools, tool_choicefunction definitions / selectionSee Parameters & tools.
response_formattext, json_object or json_schemaSee Parameters & tools.
reasoning_effort, reasoningmodel-dependentSee Parameters & tools.

Messages

Each message has role and content. Content is a string, null, or 1–100 text/image parts. Text strings are limited to 1,000,000 characters in the schema; token context limits still apply.

Messages
RoleUse
system, developerInstructions. Model-specific handling must be checked.
userUser input, optionally with image parts.
assistantPrior output, including tool_calls when needed.
toolTool result with the matching tool_call_id.

Completion shape

The response uses choices[].message and finish_reason, with optional token usage. Tool calls may have null text content. A uRouter accounting extension records request_id, nullable cost_usd, and accounting (pending or settled).