Skip to content
On this page

Getting started

Introduction

RelayRouter is an [OI]-compatible AI gateway. One key reaches every model in the catalog, with one balance and one usage ledger.

RelayRouter sits between your application and the upstream providers. It resolves the model, enforces your limits, reserves credit, proxies the request, and records usage — all behind a single endpoint.

How it works

  • One endpoint. Chat, embeddings, images, audio, video, and moderation all use the [OI] request shape.
  • One key. Keys look like sk-or-v1-… and can carry RPM, concurrency, spend caps, and BYOK credentials.
  • One balance. Prepaid micro-USD. Each request reserves the worst-case cost before proxying, so parallel requests cannot overdraw the account.
  • Automatic failover. Retryable upstream failures are retried, then failed over to the model's fallback chain when enabled.

Base URL

EnvironmentSchemeBase URL
Productionhttpshttps://api.relayrouter.org
Localhttphttp://127.0.0.1:8080

All requests use application/json except SSE streams, audio bytes, multipart uploads, and HTML pages. CORS is permissive and no cookies are used.

Two kinds of tokens

TokenUsed forLifetime
JWTDashboard endpointsReturned by /auth/signup and /auth/signin. Used for /auth/me, /keys, /usage, /deposits, and the rest of the dashboard surface. Lifetime: 24 hours (JWT_TTL_HOURS).
API keyInference endpointssk-or-v1-… keys minted from /keys. Used for inference endpoints. Dashboard endpoints also accept them. Lifetime: until revoked or expired.

There is no refresh endpoint

When a JWT expires you receive 401. Store the token, catch the error, and send the user back to sign in.

Money and pricing

Every internal amount is an integer in micro-USD: 1_000_000 micro = $1.00. Never do float math on balance_micro; display micro / 1e6. Model prices in the catalog are USD per one million tokens.

A request costs the flat network fee plus the serving model's token cost. Failed upstream calls are never billed. See Billing & deposits for the exact formula.

What to read next