Docs / API reference

The endpoints.

Base URL: https://redrouter.ai/api/public/v1. All endpoints require a Bearer key and accept cross-origin requests.

POST /chat/completions

Creates a chat completion. OpenAI-compatible request and response shapes.

modelstring, requiredModel id from the catalog, e.g. llama-3.3-70b.
messagesarray, requiredConversation messages with role (system, user, assistant, tool) and content.
max_tokensintegerMaximum completion tokens, 1–32768.
temperaturenumberSampling temperature, 0–2.
top_pnumberNucleus sampling, 0–1.
streambooleanStream the response as server-sent events.
stopstring | arrayUp to 4 stop sequences.
Response
{
  "id": "chatcmpl-...",
  "object": "chat.completion",
  "model": "llama-3.3-70b",
  "choices": [
    {
      "index": 0,
      "message": { "role": "assistant", "content": "..." },
      "finish_reason": "stop"
    }
  ],
  "usage": { "prompt_tokens": 12, "completion_tokens": 40, "total_tokens": 52 }
}

GET /models

Lists the models in the catalog with their modality, parameters, and context length.

Response
{
  "object": "list",
  "data": [
    {
      "id": "llama-3.3-70b",
      "object": "model",
      "name": "Llama 3.3 70B Instruct",
      "family": "Llama",
      "modality": "text",
      "parameters": "70B",
      "context_length": 128000,
      "status": "live"
    }
  ]
}

Error shape

All errors return a consistent JSON body:

Error
{
  "error": {
    "message": "Human-readable description.",
    "type": "invalid_request_error | authentication_error | not_found_error | model_unavailable | upstream_error | rate_limited | spend_cap_reached | server_error",
    "code": 400
  }
}

Rate limits and caps

Every account has a plan with a requests-per-minute limit, a daily token limit and a monthly spend cap. Each response carries X-RateLimit-Limit, X-RateLimit-Remaining and X-RateLimit-Reset headers.

  • 429 rate_limited — too many requests this minute. Wait for Retry-After seconds.
  • 429 daily_tokens_exceeded — daily token limit reached; resets at 00:00 UTC.
  • 402 spend_cap_reached — monthly spend cap reached; resets on the 1st (UTC).
  • 403 model_not_in_plan — the model isn't included in your plan.
  • 403 account_suspended — the account is suspended; contact support.