Quickstart
Get started with Reroute
Reroute gives you access to every model in the catalog through a single API endpoint. It prices each request against the model's listed rate and routes it to a carrier that serves the model.
| Approach | Best for |
|---|---|
| API | Full control, any language, no dependencies |
| OpenAI SDK | Drop-in for code that already uses OpenAI |
| Streaming | Chat UIs that render tokens as they arrive |
Create an API key
Sign up, then open Settings → Keys and create a key. The full secret starts with sk-rr-v1- and is shown exactly once; we only store its hash. Export it as REROUTE_API_KEY.
Using the Reroute API
The examples below set the model to openai/gpt-oss-20b. Any model ID from the catalog works the same way. The two app headers are optional; setting them lists your app on the app rankings.
curl https://reroute.wtf/api/v1/chat/completions \
-H "Authorization: Bearer $REROUTE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-oss-20b",
"messages": [
{ "role": "user", "content": "What is the meaning of life?" }
]
}'Using the OpenAI SDK
Change the base URL and the key. Nothing else in your code needs to change.
from openai import OpenAI
client = OpenAI(
base_url="https://reroute.wtf/api/v1",
api_key="<REROUTE_API_KEY>",
)
completion = client.chat.completions.create(
model="openai/gpt-oss-20b",
messages=[{"role": "user", "content": "What is the meaning of life?"}],
extra_headers={
"HTTP-Referer": "https://your-app.com", # optional, for app rankings
"X-Title": "Your App", # optional, for app rankings
},
)
print(completion.choices[0].message.content)import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://reroute.wtf/api/v1",
apiKey: process.env.REROUTE_API_KEY,
});
const completion = await client.chat.completions.create({
model: "openai/gpt-oss-20b",
messages: [{ role: "user", content: "What is the meaning of life?" }],
});
console.log(completion.choices[0].message.content);Streaming
Set stream: true to receive server-sent events. Every chunk carries the same gen-… ID, which is also returned in the X-Generation-Id response header; the stream ends with data: [DONE].
const stream = await client.chat.completions.create({
model: "openai/gpt-oss-20b",
messages: [{ role: "user", content: "Write a haiku about freight trains." }],
stream: true,
});
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
}Plain fetch
Non-streaming responses include usage.cost: the amount in USD deducted from your balance for this request.
const res = await fetch("https://reroute.wtf/api/v1/chat/completions", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.REROUTE_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "openai/gpt-oss-20b",
messages: [{ role: "user", content: "What is the meaning of life?" }],
}),
});
const data = await res.json();
console.log(data.choices[0].message.content, data.usage.cost);