Router One
Router One

Create Chat Completion

Create a chat completion. OpenAI Chat Completions API compatible; supports streaming and non-streaming responses. When `model` is `auto`, Router One picks the best model based on the active routing strategy.

POST
/v1/chat/completions
AuthorizationBearer <token>

Authenticate with your API Key. Get your API Key in the Router One console; the format is sk-xxx.

In: header

modelstring

Model ID. Set to auto to let Router One's smart routing pick the best model, or specify a model such as gpt-4o or claude-sonnet-4-20250514.

messages

Chat messages, in chronological order.

Items1 <= items
stream?boolean

Whether to enable streaming response. When enabled, returns an SSE event stream.

Defaultfalse
temperature?number

Sampling temperature, range 0-2. Higher values (e.g. 0.8) make output more random; lower values (e.g. 0.2) make it more deterministic.

Default1
Range0 <= value <= 2
max_tokens?integer

Maximum number of tokens to generate.

Range1 <= value
top_p?number

Nucleus sampling parameter. The model considers tokens with the top top_p mass of the probability distribution.

Default1
Range0 <= value <= 1
stream_options?

Streaming response options. Only valid when stream: true.

Response Body

application/json

application/json

application/json

application/json

curl -X POST "https://api.router.one/v1/chat/completions" \  -H "Content-Type: application/json" \  -d '{    "model": "auto",    "messages": [      {        "role": "user",        "content": "Hello"      }    ]  }'
{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 1700000000,
  "model": "gpt-4o",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Hello! How can I help you?"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 9,
    "completion_tokens": 12,
    "total_tokens": 21
  }
}
{
  "error": {
    "message": "Invalid API key",
    "type": "authentication_error",
    "code": "invalid_api_key"
  }
}
{
  "error": {
    "message": "Insufficient balance",
    "type": "billing_error",
    "code": "insufficient_balance"
  }
}
{
  "error": {
    "message": "Rate limit exceeded",
    "type": "rate_limit_error",
    "code": "rate_limit_exceeded"
  }
}
{
  "error": {
    "message": "string",
    "type": "string",
    "code": "string"
  }
}