routing.run docs
One OpenAI- and Anthropic-compatible API for 29 models. Point the code you have at routing.run, keep the rest, and pay for what you use from a prepaid balance.
Quick start
Three steps, in the order the dashboard asks for them.
Create a key
Sign in with GitHub, Google, Discord, Apple or an email link, then make a key in API keys. Name it after the place it runs.
Add credits
Top up from $5 in Billing. Credits you buy don't expire.
Send a request
Put the key in
ROUTING_API_KEYand call the API. It shows up in Usage within seconds.Shellcurl https://api.routing.run/v1/chat/completions \ -H "Authorization: Bearer $ROUTING_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "claude-sonnet-5.5", "messages": [{"role": "user", "content": "Hello"}] }'
Authentication
Send your key as a Bearer token: Authorization: Bearer $ROUTING_API_KEY. The Anthropic endpoint also accepts x-api-key. Keys spend from your balance, so keep them on your server and never in browser code or a public repository. Revoke a leaked key in API keys; it stops working at once.
OpenAI and Anthropic
One key for both. Use the base URL your client expects.
OpenAI-compatible
For the OpenAI SDKs and anything that asks for an OpenAI base URL.
Anthropic-compatible
No /v1: the Anthropic SDKs and Claude Code add /v1/messages themselves.
Every model works through both, so a Claude model can be called with the OpenAI SDK and the other way round.
Billing
Pay as you go: add credits from $5, and each request is charged for its tokens at our price for its model, below list. Your balance, spend and every request are in the dashboard. A failed request isn't charged.
Our prices are rounded up and list prices rounded down, so a saving the dashboard shows is never overstated. Savings use today's prices.
Endpoints
Bodies follow the OpenAI and Anthropic formats, including streaming with "stream": true.
| Method | Path | What it does |
|---|---|---|
| POST | /v1/chat/completions | OpenAI Chat Completions, with streaming and tools |
| POST | /v1/responses | OpenAI Responses |
| POST | /v1/messages | Anthropic Messages |
| GET | /v1/models | Every model you can call, with its status |
| GET | /v1/pricing | Price per 1M tokens for each model, ours and at list |
Models
Use a model id as model, for example claude-sonnet-5.5. Every model with its price is in Models, or ask the API:
curl https://api.routing.run/v1/models \
-H "Authorization: Bearer $ROUTING_API_KEY"Errors
Errors come back as JSON with a message that says what to fix. A failed request isn't charged.
| Status | Meaning |
|---|---|
| 400 | The request body is invalid. The message says which field. |
| 401 | The API key is missing, wrong or revoked. |
| 402 | Your balance is empty. Add credits in Billing. |
| 404 | The model id doesn't exist. Check GET /v1/models. |
| 429 | Too many requests. Back off and retry after a few seconds. |
| 503 | The model is unavailable right now. Retry shortly, or use another model. |
Claude Code
Claude Code talks to the Anthropic-compatible API. Set three variables and start it.
export ANTHROPIC_BASE_URL=https://api.routing.run
export ANTHROPIC_AUTH_TOKEN=$ROUTING_API_KEY
export ANTHROPIC_MODEL=claude-sonnet-5.5
claudeCodex
Add routing.run as a model provider in Codex's config, then run codex as usual.
model_provider = "routing"
model = "claude-sonnet-5.5"
[model_providers.routing]
name = "routing.run"
base_url = "https://api.routing.run/v1"
env_key = "ROUTING_API_KEY"
wire_api = "responses"Cursor
Cursor takes an OpenAI-compatible base URL in its model settings.
Open Settings, then Models, and paste your key as the OpenAI API key.
Turn on Override OpenAI Base URL and set it to
https://api.routing.run/v1.Add a model by its id, for example
claude-sonnet-5.5, and pick it in the chat.
OpenCode
Add a provider to opencode.json; the key comes from your environment.
{
"provider": {
"routing": {
"npm": "@ai-sdk/openai-compatible",
"options": {
"baseURL": "https://api.routing.run/v1",
"apiKey": "{env:ROUTING_API_KEY}"
},
"models": { "claude-sonnet-5.5": {} }
}
}
}Cline
Cline works with any OpenAI-compatible provider.
In Cline's settings, set API Provider to OpenAI Compatible.
Set Base URL to
https://api.routing.run/v1and paste your key as the API key.Set Model ID to a model id, for example
claude-sonnet-5.5.
Zed
Add an OpenAI-compatible provider in Zed's settings.json. Zed reads the key from ROUTING_API_KEY.
{
"language_models": {
"openai_compatible": {
"routing": {
"api_url": "https://api.routing.run/v1",
"available_models": [
{
"name": "claude-sonnet-5.5",
"display_name": "Claude Sonnet 5.5",
"max_tokens": 1000000
}
]
}
}
}
}OpenAI SDK
Change two arguments and keep the rest.
import os
from openai import OpenAI
client = OpenAI(base_url="https://api.routing.run/v1", api_key=os.environ["ROUTING_API_KEY"])
response = client.chat.completions.create(
model="claude-sonnet-5.5",
messages=[{"role": "user", "content": "Hello"}],
)
print(response.choices[0].message.content)import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.routing.run/v1",
apiKey: process.env.ROUTING_API_KEY,
});
const response = await client.chat.completions.create({
model: "claude-sonnet-5.5",
messages: [{ role: "user", content: "Hello" }],
});
console.log(response.choices[0].message.content);Anthropic SDK
Use the Anthropic-compatible base URL, without /v1.
import os
from anthropic import Anthropic
client = Anthropic(base_url="https://api.routing.run", api_key=os.environ["ROUTING_API_KEY"])
message = client.messages.create(
model="claude-sonnet-5.5",
max_tokens=1024,
messages=[{"role": "user", "content": "Hello"}],
)
print(message.content[0].text)import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({
baseURL: "https://api.routing.run",
apiKey: process.env.ROUTING_API_KEY,
});
const message = await client.messages.create({
model: "claude-sonnet-5.5",
max_tokens: 1024,
messages: [{ role: "user", content: "Hello" }],
});Vercel AI SDK
Use routing.run as an OpenAI-compatible provider.
import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
import { generateText } from "ai";
const routing = createOpenAICompatible({
name: "routing",
baseURL: "https://api.routing.run/v1",
apiKey: process.env.ROUTING_API_KEY,
});
const { text } = await generateText({
model: routing("claude-sonnet-5.5"),
prompt: "Hello",
});LangChain
ChatOpenAI takes the base URL and key directly.
import os
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(
model="claude-sonnet-5.5",
base_url="https://api.routing.run/v1",
api_key=os.environ["ROUTING_API_KEY"],
)
print(llm.invoke("Hello").content)