Skip to content
INFRO

Documentation

Chat completions

Full reference for POST /v1/chat/completions: every standard OpenAI parameter plus INFRO's routing, fallbacks, and logging extensions.


The chat completions endpoint is the core of the API and is wire-compatible with OpenAI's. Any SDK or tool that speaks the OpenAI protocol works against it by changing the base URL.

Endpoint
POST https://api.infro.io/v1/chat/completions

Request body

modelstringrequired
Model ID in vendor/model-name form, e.g. anthropic/claude-opus-5. Browse IDs in the catalog or via GET /v1/models.
messagesarrayrequired
Conversation history. Each message has role (system | user | assistant | tool) and content (string, or an array of text/image parts for vision).
streamboolean
When true, tokens arrive as server-sent events. See Streaming.
max_tokensinteger
Upper bound on generated tokens. Defaults to the model's maximum output.
temperaturenumber
Sampling temperature, 02. Higher is more random. Some reasoning models ignore or restrict it — check the model page.
top_pnumber
Nucleus sampling. Use temperature or top_p, not both.
stopstring | array
Up to 4 sequences where generation halts.
frequency_penalty / presence_penaltynumber
-2.02.0. Passed through to providers that support them; silently dropped otherwise.
toolsarray
Function definitions the model may call. Normalized across every provider — see Tool calling.
tool_choicestring | object
"auto" (default), "none", "required", or {"type": "function", "function": {"name": "..."}} to force one tool.
response_formatobject
{"type": "json_object"} for JSON mode or {"type": "json_schema", "json_schema": {...}} for validated output. See Structured outputs.
seedinteger
Best-effort deterministic sampling on providers that support it.
userstring
Opaque end-user ID for your own abuse tracking; appears in your usage export.
stream_optionsobject
{"include_usage": true} appends a final chunk with token counts when streaming.

INFRO extensions

INFRO-specific fields sit at the top level of the request body (use extra_body in the OpenAI SDKs). Other OpenAI-compatible backends ignore them, so requests stay portable.

routingobject
{"policy": "cheapest" | "fastest" | "balanced", "providers": {"allow": [...], "deny": [...]}, "regions": ["us", "eu", "ap"]}. All fields optional. Full semantics in Smart routing.
fallbacksarray
Ordered model IDs to try if every provider of model fails, e.g. ["zai/glm-4.6", "deepseek/deepseek-v3.2"]. See Failover & fallbacks.
loggingboolean
Set false to enable zero-logging for this request: prompt and completion content is never written to disk. Metadata (token counts, latency) is still metered for billing. See Privacy & data.

Example request

curl https://api.infro.io/v1/chat/completions \
  -H "Authorization: Bearer $INFRO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "moonshot/kimi-k2",
    "messages": [
      {"role": "system", "content": "You are a concise assistant."},
      {"role": "user", "content": "Summarize SSE in one sentence."}
    ],
    "max_tokens": 200,
    "routing": {"policy": "fastest"},
    "fallbacks": ["zai/glm-4.6"]
  }'

Response

json
{
  "id": "gen-9f27c1d0",
  "object": "chat.completion",
  "created": 1755950000,
  "model": "moonshot/kimi-k2",
  "provider": "nebula",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Server-sent events stream one-way updates from server to client over a single HTTP connection."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 31,
    "completion_tokens": 19,
    "total_tokens": 50,
    "cost": 0.0000554
  }
}
providerstring
INFRO extension: the provider that actually served the request. Useful for debugging latency differences.
usage.costnumber
INFRO extension: the exact USD amount charged for this request, computed from the live per-token rate.
finish_reasonstring
stop, length (hit max_tokens), tool_calls, or content_filter.

Always branch on finish_reason before trusting output: length means the response was truncated mid-thought, and tool_calls means message.tool_calls is populated and content may be empty.

Compatibility notes

  • Parameters a provider doesn't support are dropped silently rather than erroring, so one request shape works across the whole catalog.
  • Token counting uses each provider's native tokenizer; usage is always reported in the upstream provider's own units — the same units its price is quoted in.
  • The legacy POST /v1/completions endpoint is not supported; use chat completions.