Documentation
RouterAI speaks the OpenAI and Anthropic APIs. If your code works with either, it works with RouterAI — change the base URL and the key.
Quickstart
- Sign in with your Classai account (or create one).
- Top up from a few dollars.
- Copy your API key from Dashboard → API keys and send a request:
curl https://routerai.id/v1/chat/completions \
-H "Authorization: Bearer $ROUTERAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek-v4.1-flash",
"messages": [{"role": "user", "content": "Hello! Explain RouterAI in one sentence."}]
}'Authentication
Send your key as a bearer token. Keys start with sk_live_; keep them server-side.
Authorization: Bearer sk_live_…
Base URL: https://routerai.id/v1
Models
Use any id from the model list as model. List them from code:
curl https://routerai.id/v1/models -H "Authorization: Bearer $ROUTERAI_API_KEY"
Anthropic format
POST /v1/messages takes the Anthropic Messages format, including streaming and tool use — point the Anthropic SDK at https://routerai.id.
from anthropic import Anthropic
client = Anthropic(base_url="https://routerai.id", api_key="<ROUTERAI_API_KEY>")
msg = client.messages.create(
model="claude-sonnet-5",
max_tokens=1024,
messages=[{"role": "user", "content": "Hello!"}],
)Claude Code & tools
Claude Code:
export ANTHROPIC_BASE_URL="https://routerai.id" export ANTHROPIC_AUTH_TOKEN="<ROUTERAI_API_KEY>" claude
Cursor, Cline, Continue, n8n, LangChain and other OpenAI-compatible tools: set the base URL to https://routerai.id/v1, paste your key, and type a model id.
Errors & billing
401— missing or unknown API key.402— not enough credits; top up and retry.403— the key is disabled, expired, limited to another model, or hit its spending limit.404— unknown model id; seeGET /v1/models.429— too many requests at once; respectRetry-After.502/503— the model's providers are failing or it's temporarily unavailable; failed requests are not billed.
Each request costs input tokens × input price + output tokens × output price, taken from your credits. Cached input is billed lower automatically.