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

SettingBeforeAfter
Base URLhttps://openrouter.ai/api/v1https://anyrouter.dev/api/v1
API keyOpenRouter keyAnyRouter key (sk-ar-...) from the dashboard
Modelprovider/modelSame, but confirm each id is in Models; some differ
typescript
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

json
{
  "provider": {
    "only": ["OpenAI", "Groq"],
    "order": ["Groq", "OpenAI"],
    "sort": "latency",
    "max_price": { "prompt": "1.00", "completion": "4.00" },
    "allow_fallbacks": true
  }
}
  • max_price is 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": false when 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

bash
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

SymptomFix
Model id returns 404List Models and use the matching AnyRouter id.
Request fails with a price cap setmax_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