Docs › Migrate from OpenRouter
Migrate from OpenRouter
Change two lines: the base URL and the key. Model IDs stay the same.
The change
Both APIs are OpenAI-compatible and use the same model IDs, so most apps only need a new base URL and key.
Config
# Before: OpenRouter
base_url = "https://openrouter.ai/api/v1"
api_key = "sk-or-v1-…"
model = "mistralai/ministral-3b-2512"
# After: TokenCenter
base_url = "https://api.tokenctr.com/v1"
api_key = "ck_…" # from tokenctr.com/start.html
model = "mistralai/ministral-3b-2512" # same model IDsPython
import os
from openai import OpenAI
client = OpenAI(
base_url="https://api.tokenctr.com/v1", # was https://openrouter.ai/api/v1
api_key=os.environ["TOKENCENTER_API_KEY"],
)JavaScript
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.tokenctr.com/v1", // was https://openrouter.ai/api/v1
apiKey: process.env.TOKENCENTER_API_KEY,
});curl
curl https://api.tokenctr.com/v1/chat/completions \
-H "Authorization: Bearer $TOKENCENTER_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "mistralai/ministral-3b-2512",
"messages": [{"role": "user", "content": "Say hello in five words."}],
"max_tokens": 100
}'What’s different
| TokenCenter | |
|---|---|
| Streaming | Not available yet. Turn streaming off in your tool or send "stream": false. |
| Models | 284 OpenRouter models with fixed per-token prices. Models with variable pricing and :free variants aren’t offered. Check GET /v1/models for the exact list. |
| Prices | The same input and output prices OpenRouter lists, with zero markup. If the provider reports a higher actual cost for a call, that cost is charged. |
| Credit | Separate prepaid balance bought on Pricing. OpenRouter credit doesn’t carry over. |
| Headers | OpenRouter’s HTTP-Referer and X-Title headers aren’t needed and have no effect. |
| Request fields | Your request body is passed through unchanged, so fields like tools, response_format, reasoning and provider behave as they do on OpenRouter. |
| Balance | Each response includes x-cosmos-credit-balance with your remaining credit. |
| Limits | 60 requests per minute per key, 120 per IP address. |
Checklist
- Get a key and save it.
- Add credit to it.
- Change the base URL and API key in your app.
- Turn off streaming.
- Set
max_tokensso the hold on your balance stays small. - Make one test call and check the
x-cosmos-credit-balanceheader.