Guides
Migrate to MiniRouter
Change the base URL, the key and the model ID. Your SDK stays.
MiniRouter speaks the OpenAI Chat Completions and Responses APIs and the Anthropic Messages API. Existing SDKs work unchanged: point them at MiniRouter, pay from one balance and pick any model in the catalog.
1. Get a key
Create a key, then export it where your app runs.
export MINIROUTER_KEY=mr-live-YOUR-KEY-HEREsetx MINIROUTER_KEY mr-live-YOUR-KEY-HERE2. Change the base URL
Pass the MiniRouter URL and key to your client.
from openai import OpenAI
import os
client = OpenAI(
base_url="https://api.minirouter.sh/v1",
api_key=os.environ["MINIROUTER_KEY"],
)
completion = client.chat.completions.create(
model="openai/gpt-5.6-luna",
messages=[{"role": "user", "content": "Hello"}],
)
print(completion.choices[0].message.content)import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.minirouter.sh/v1",
apiKey: process.env.MINIROUTER_KEY,
});
const completion = await client.chat.completions.create({
model: "openai/gpt-5.6-luna",
messages: [{ role: "user", content: "Hello" }],
});
console.log(completion.choices[0].message.content);curl https://api.minirouter.sh/v1/chat/completions \
-H "Authorization: Bearer $MINIROUTER_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-5.6-luna",
"messages": [
{
"role": "user",
"content": "Hello"
}
]
}'3. Use full model IDs
Prefix the author: gpt-5.6-luna becomes openai/gpt-5.6-luna. See Model IDs.
4. Verify
Send one request, then open Activity. It lists the model, tokens and exact cost.
Anthropic SDK
Messages accepts the key as x-api-key or a bearer token. Only the base URL changes.
from anthropic import Anthropic
import os
client = Anthropic(
base_url="https://api.minirouter.sh",
api_key=os.environ["MINIROUTER_KEY"],
)
message = client.messages.create(
model="anthropic/claude-opus-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.minirouter.sh",
apiKey: process.env.MINIROUTER_KEY,
});
const message = await client.messages.create({
model: "anthropic/claude-opus-5",
max_tokens: 1024,
messages: [{ role: "user", content: "Hello" }],
});
console.log(message.content);curl https://api.minirouter.sh/v1/messages \
-H "Authorization: Bearer $MINIROUTER_KEY" \
-H "Content-Type: application/json" \
-H "anthropic-version: 2023-06-01" \
-d '{
"model": "anthropic/claude-opus-5",
"max_tokens": 1024,
"messages": [
{
"role": "user",
"content": "Hello"
}
]
}'Vercel AI SDK
import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
import { generateText } from "ai";
const minirouter = createOpenAICompatible({
name: "minirouter",
baseURL: "https://api.minirouter.sh/v1",
apiKey: process.env.MINIROUTER_KEY,
includeUsage: true,
});
const { text } = await generateText({
model: minirouter("openai/gpt-5.6-luna"),
prompt: "Hello",
});
console.log(text);Any other OpenAI-compatible client takes the same base URL and key.
Environment variables
OpenAI and Anthropic SDKs read these when code passes no URL or key.
- OPENAI_BASE_URL
https://api.minirouter.sh/v1- OPENAI_API_KEY
- Your MiniRouter key.
- ANTHROPIC_BASE_URL
https://api.minirouter.sh- ANTHROPIC_API_KEY
- Your MiniRouter key.
export OPENAI_BASE_URL=https://api.minirouter.sh/v1
export OPENAI_API_KEY=mr-live-YOUR-KEY-HEREsetx OPENAI_BASE_URL https://api.minirouter.sh/v1
setx OPENAI_API_KEY mr-live-YOUR-KEY-HEREModel IDs
- gpt-5.
6-luna openai/gpt-5.6-luna- claude-opus-5
anthropic/claude-opus-5- gemini-3.
8-flash google/gemini-3.8-flash
Copy exact IDs from the catalog or list them. Let MiniRouter choose with minirouter/auto.
What stays, what changes
- Cost
usage.costandx-minirouter-cost-usd. See billing.Chat Completions streams carry it whenstream_options.include_usageis set.- Balance
x-minirouter-balance-usdon every response.- Served by
x-minirouter-modelandx-minirouter-provider.- Errors
error.codeandx-minirouter-error-codename the cause. See errors.Messages keeps the Anthropic error shape.- Paths
- Paths under
/api/v1also work.
Roll out
FAQ
Do I need a new SDK?
No. OpenAI, Anthropic and OpenAI-compatible clients work with a new base URL and key.
Does the Responses API work?
Yes. Chat Completions and Responses both work through the OpenAI SDK.
How do I see what a request cost?
Read usage.cost or x-minirouter-cost-usd, or open Activity.
What if a model fails?
List up to three backups in models, or fallbacks on Messages. If one cannot start a response, the next answers.