API Reference
Chat Completions
OpenAI-compatible chat completions API
Create Chat Completion
Generate a model response for the given conversation.
POST /v1/chat/completionsRequest Headers
| Header | Required | Description |
|---|---|---|
Authorization | Yes | Bearer sk-r9k-your-key |
Content-Type | Yes | application/json |
Request Body
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Model ID — a provider-prefixed slug from GET /v1/models (e.g. anthropic/claude-opus-5), not a short name like gpt-4o |
messages | array | Yes | Conversation messages |
stream | boolean | No | Enable streaming (default: false) |
temperature | number | No | Sampling temperature (0-2) |
max_tokens | number | No | Maximum tokens to generate |
Model ids are provider-prefixed slugs, not short aliases. gpt-4o or
claude-3-sonnet return 404 model_not_found unless your deployment has
configured a matching route — see Models.
Messages Format
{
"messages": [
{ "role": "system", "content": "You are a helpful assistant." },
{ "role": "user", "content": "Hello!" }
]
}Example Request
curl https://api.router9.com/v1/chat/completions \
-H "Authorization: Bearer sk-r9k-your-key" \
-H "Content-Type: application/json" \
-d '{
"model": "anthropic/claude-opus-5",
"messages": [
{ "role": "user", "content": "Explain quantum computing in one sentence." }
]
}'Response
{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 1714000000,
"model": "anthropic/claude-opus-5",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Quantum computing uses quantum mechanical phenomena like superposition and entanglement to process information in ways classical computers cannot."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 15,
"completion_tokens": 28,
"total_tokens": 43
}
}Streaming
Set stream: true to receive responses as Server-Sent Events (SSE).
curl https://api.router9.com/v1/chat/completions \
-H "Authorization: Bearer sk-r9k-your-key" \
-H "Content-Type: application/json" \
-d '{
"model": "anthropic/claude-opus-5",
"messages": [{ "role": "user", "content": "Hello!" }],
"stream": true
}'The response is a stream of data: lines:
data: {"id":"chatcmpl-abc","choices":[{"delta":{"role":"assistant"},"index":0}]}
data: {"id":"chatcmpl-abc","choices":[{"delta":{"content":"Hello"},"index":0}]}
data: {"id":"chatcmpl-abc","choices":[{"delta":{"content":"!"},"index":0}]}
data: [DONE]Token usage is included in the final chunk before [DONE].
Auto Model
If your administrator has configured an auto route, setting model to
"auto" lets Router9 pick a model for you. auto is not a built-in
alias — on a deployment with no auto route, this returns
404 model_not_found. See Models for how to
check whether it's available.
{
"model": "auto",
"messages": [{ "role": "user", "content": "Hello!" }]
}