Migrate from OpenRouter
Move OpenRouter Chat Completions requests to AnyRouter. Provider preferences carry over unchanged.
Change the base URL and key. Model ids keep the provider/model form, and request-level provider preferences (only, ignore, order, sort, max_price, allow_fallbacks) work unchanged. Your HTTP-Referer and X-Title headers can stay; AnyRouter reads both for dashboard attribution.
What changes
| Setting | Before | After |
|---|---|---|
| Base URL | https://openrouter.ai/api/v1 | https://anyrouter.dev/api/v1 |
| API key | OpenRouter key | AnyRouter key (sk-ar-...) from the dashboard |
| Model | provider/model | Same, but confirm each id is in Models; some differ |
import OpenAI from "openai"
const client = new OpenAI({
baseURL: "https://anyrouter.dev/api/v1",
apiKey: process.env.ANYROUTER_API_KEY,
})
const completion = await client.chat.completions.create({
model: "anthropic/claude-sonnet-4-6",
messages: [{ role: "user", content: "Summarize this support thread." }],
})Provider preferences
{
"provider": {
"only": ["OpenAI", "Groq"],
"order": ["Groq", "OpenAI"],
"sort": "latency",
"max_price": { "prompt": "1.00", "completion": "4.00" },
"allow_fallbacks": true
}
}max_priceis in dollars per 1M tokens and is a hard filter: if every route is filtered out, the request fails.- Fallbacks are on by default. Set
"allow_fallbacks": falsewhen you need a fixed upstream, for example in an eval run.
All fields: Provider Routing.
OAuth PKCE
The OpenRouter OAuth PKCE flow works too. Swap openrouter.ai for anyrouter.dev in the /auth URL and the /api/v1/auth/keys exchange. See OAuth PKCE.
Verify
curl https://anyrouter.dev/api/v1/chat/completions \
-H "Authorization: Bearer sk-ar-your-key" \
-H "Content-Type: application/json" \
-d '{"model": "anthropic/claude-sonnet-4-6", "messages": [{"role": "user", "content": "Say hello."}]}'Troubleshooting
| Symptom | Fix |
|---|---|
| Model id returns 404 | List Models and use the matching AnyRouter id. |
| Request fails with a price cap set | max_price is a hard filter. Raise the cap; no route fits under it. |
AnyRouter routes requests to third-party models. Models and outputs are provided as is, with no warranty; you use them at your own risk. Disclaimer