Skip to main content
kRouter

API Reference

OpenAI-compatible /v1/chat/completions, /v1/messages, /v1/models endpoints exposed by kRouter on localhost:20128.


kRouter exposes the standard OpenAI Chat Completions endpoint plus an Anthropic-compatible /v1/messages shim, both on http://localhost:20128.

POST /v1/chat/completions

Standard OpenAI shape. Pass model as <provider-alias>/<model-id>.

curl http://localhost:20128/v1/chat/completions \
  -H "Authorization: Bearer sk-krouter-XXXX" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "cc/claude-opus-4-7",
    "messages": [
      {"role": "user", "content": "Hello!"}
    ],
    "stream": true
  }'

Streaming, tool calls, and function calling all work as in the upstream OpenAI shape.

POST /v1/messages (Anthropic-compatible)

Used by claude-code and other Anthropic-native clients. kRouter translates to/from the underlying provider's format transparently.

curl http://localhost:20128/v1/messages \
  -H "x-api-key: sk-krouter-XXXX" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "cc/claude-sonnet-4-6",
    "max_tokens": 1024,
    "messages": [{"role": "user", "content": "Hello!"}]
  }'

GET /v1/models

Returns every model your kRouter knows about (including combos), in OpenAI list shape.

curl http://localhost:20128/v1/models -H "Authorization: Bearer sk-krouter-XXXX"

Combos

A combo is a list of provider/model IDs used as fallback chain. You define them in the dashboard.

{
  "model": "my-coding-stack",
  "messages": [{"role": "user", "content": "..."}]
}

When you request my-coding-stack, kRouter tries each model in order — falling through on quota / 429 / 5xx — and returns the first successful response.

See Core concepts for combos and the routing logic.