ultrarouter docs
API reference

Chat

OpenAI-compatible chat completions (streaming + non-streaming).

OpenAI-compatible chat completions (streaming + non-streaming).

This page is GENERATED from the OpenAPI spec (openapi.yaml) — it can never drift from the served API. Set UR_BASE_URL (required: your gateway’s URL) and UR_API_KEY (an ur_sk_* key); secrets are always the $UR_API_KEY placeholder.

Create a chat completion

POST /v1/chat/completions

OpenAI-compatible chat completions. Set stream:true for OpenAI-shaped SSE: a text/event-stream of chat.completion.chunk events, a consolidated final chunk carrying usage + the ur block, then data: [DONE]. Requires API-key scope: gateway:invoke.

Auth: API key (Authorization: Bearer ur_sk_…).

curl -sS -X POST "$UR_BASE_URL/v1/chat/completions" \
  -H "Authorization: Bearer $UR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-5-mini",
    "messages": [
      {
        "role": "user",
        "content": "Say hello in one word."
      }
    ]
  }'