AI Studio
Create
ImageVideoCanvasExplore
Experts
Overview
DocsAPI KeysDiscord
Documentation
Documentation
IntroductionWhy Router9

Studio

Using Studio

For Developers

Quick StartInstall MCP Server

Integrations

Token Plan

API Reference

AuthenticationChat CompletionsModelsRate LimitingErrors

Tools

Audio ToolImage ToolTool Usage & Credits
API Reference

Chat Completions

OpenAI-compatible chat completions API

Create Chat Completion

Generate a model response for the given conversation.

POST /v1/chat/completions

Request Headers

HeaderRequiredDescription
AuthorizationYesBearer sk-r9k-your-key
Content-TypeYesapplication/json

Request Body

ParameterTypeRequiredDescription
modelstringYesModel ID — a provider-prefixed slug from GET /v1/models (e.g. anthropic/claude-opus-5), not a short name like gpt-4o
messagesarrayYesConversation messages
streambooleanNoEnable streaming (default: false)
temperaturenumberNoSampling temperature (0-2)
max_tokensnumberNoMaximum 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!" }]
}

Authentication

How to authenticate with the Router9 API

Models

List available models and understand model routing

On this page

Create Chat CompletionRequest HeadersRequest BodyMessages FormatExample RequestResponseStreamingAuto Model