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.
Authenticate with your API Key. Get your API Key in the Router One console; the format is sk-xxx.
In: header
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.
Chat messages, in chronological order.
1 <= itemsWhether to enable streaming response. When enabled, returns an SSE event stream.
falseSampling temperature, range 0-2. Higher values (e.g. 0.8) make output more random; lower values (e.g. 0.2) make it more deterministic.
10 <= value <= 2Maximum number of tokens to generate.
1 <= valueNucleus sampling parameter. The model considers tokens with the top top_p mass of the probability distribution.
10 <= value <= 1Streaming 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"
}
}