Migrating to PrivateRouter
PrivateRouter is OpenAI-compatible. Migrating from OpenAI, Anthropic, or
OpenRouter is a two-line change in 90% of codebases — flip base_url and
swap your model name.
The interactive migration wizard at /migrate walks through
this end-to-end:
- Pick your current provider (OpenAI / Anthropic / OpenRouter).
- See side-by-side "before / after" code for Python, Node, and curl.
- Paste your 30-day token counts to get a personalized savings estimate.
- Copy the generated snippet and ship.
What the wizard does
Behind the scenes, the wizard calls POST /api/migrate/estimate — a
public, unauthenticated endpoint that returns:
recommended_pr_model— the closest PrivateRouter model to whatever you're running today (e.g.gpt-4o→privaterouter/qwen-pro,claude-3-haiku→privaterouter/fast).legacy_cost_usd_30d— what those same tokens would have cost on your current provider, using their publicly listed prices.pr_cost_usd_30d— what they'd cost on PrivateRouter.monthly_savings_usd+savings_pct— the headline numbers.code_snippets— ready-to-paste Python / Node / curl swaps, pre-filled with the recommended model name.
The estimate uses hardcoded list prices on both sides — it's a first-order approximation, not a billing contract. Your actual savings will vary with context length, cache hit rate, and routing decisions.
Manual migration (skip the wizard)
If you'd rather wire it up by hand:
Python (OpenAI SDK)
from openai import OpenAI
client = OpenAI(
api_key="$PRIVATEROUTER_API_KEY",
base_url="https://api.privaterouter.com/v1",
)
resp = client.chat.completions.create(
model="privaterouter/qwen-pro", # was: "gpt-4o"
messages=[{"role": "user", "content": "Hello!"}],
)
print(resp.choices[0].message.content)
Node (OpenAI SDK)
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.PRIVATEROUTER_API_KEY,
baseURL: "https://api.privaterouter.com/v1",
});
const resp = await client.chat.completions.create({
model: "privaterouter/qwen-pro", // was: "gpt-4o"
messages: [{ role: "user", content: "Hello!" }],
});
curl
curl https://api.privaterouter.com/v1/chat/completions \
-H "Authorization: Bearer $PRIVATEROUTER_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "privaterouter/qwen-pro",
"messages": [{"role": "user", "content": "Hello!"}]
}'
Anthropic users
Anthropic's messages API has a slightly different shape. The simplest
path is to switch to the OpenAI SDK pointed at PrivateRouter — the
request payload is almost identical and you don't need a separate
client. The wizard's "Before / After" panes show the exact diff.
Pricing comparison
Pricing details for every PrivateRouter model live on the pricing page and the model leaderboard. A few common mappings:
gpt-4o→privaterouter/qwen-progpt-4o-mini→privaterouter/fastclaude-3.5-sonnet→privaterouter/qwen-proclaude-3-haiku→privaterouter/fastdeepseek-coder→privaterouter/deepseek-codetext-embedding-3-small→privaterouter/embed
API endpoint reference
POST /api/migrate/estimate
Content-Type: application/json
{
"legacy_provider": "openai",
"legacy_model": "gpt-4o",
"input_tokens_30d": 1000000,
"output_tokens_30d": 500000
}
- Auth: none. Public endpoint, indexable.
- Caching:
Cache-Control: public, max-age=3600. - Validation: token counts must be
>= 0;legacy_providermust be one ofopenai,anthropic,openrouter.
Got stuck?
Open a ticket from the contact page and we'll help wire it up. Most migrations take under five minutes.