Migrate from OpenRouter

Move an OpenRouter client to BitRouter Cloud or a self-hosted BitRouter endpoint.

3 min readEdit this page

Migrating from OpenRouter to BitRouter

This guide moves an OpenRouter integration to BitRouter. The hosted path is mostly an endpoint and credential change; the self-hosted path also moves provider credentials and routing policy into infrastructure you control.

Choose the target deployment

BitRouter CloudSelf-hosted BitRouter
Endpointhttps://api.bitrouter.ai/v1http://127.0.0.1:4356/v1 by default
CredentialsOne BitRouter credential; optional Cloud BYOKYour upstream provider keys
Gateway operationsManaged by BitRouterOwned by you
Gateway feeSee the live model catalogNo BitRouter inference fee

OpenRouter's fees and BYOK allowance depend on its current plan. Use OpenRouter's pricing page for a current comparison rather than relying on a copied percentage.

Migration path

Step 1: Choose credentials

Option A: Headless CLI (recommended)

Install the CLI and sign in — bro cloud login runs the RFC 8628 device-code flow, opens an approval URL in your browser, and persists the resulting OAuth credential (auto-refreshed) under $XDG_DATA_HOME/bitrouter/account-credentials.json. After that, every request through the bitrouter provider is authenticated automatically — no API key in your config:

npm install -g bitrouter
bro cloud login

Inspect the local session with bro cloud whoami, and manage account-level resources (API keys, usage, billing, policies, BYOK) with bro cloud --help.

Option B: Dashboard

Sign up at cloud.bitrouter.ai and copy your API key from the dashboard.

For self-hosting, install BitRouter, export your provider keys, and run bro start instead. The Quickstart covers that path.

Step 2: Update the base URL and credential

That's the full migration. Replace your OpenRouter endpoint and key with BitRouter's:

# Before (OpenRouter)
client = openai.OpenAI(
    base_url="https://openrouter.ai/api/v1",
    api_key=OPENROUTER_API_KEY,
)

# After (BitRouter)
client = openai.OpenAI(
    base_url="https://api.bitrouter.ai/v1",
    api_key=BITROUTER_API_KEY,
)
// Before (OpenRouter)
const client = new OpenAI({
  baseURL: 'https://openrouter.ai/api/v1',
  apiKey: OPENROUTER_API_KEY,
});

// After (BitRouter)
const client = new OpenAI({
  baseURL: 'https://api.bitrouter.ai/v1',
  apiKey: BITROUTER_API_KEY,
});
# Before (OpenRouter)
curl https://openrouter.ai/api/v1/chat/completions \
  -H "Authorization: Bearer $OPENROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "openai/gpt-4o", "messages": [{"role": "user", "content": "Hello"}]}'

# After (BitRouter)
curl https://api.bitrouter.ai/v1/chat/completions \
  -H "Authorization: Bearer $BITROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "openai/gpt-4o", "messages": [{"role": "user", "content": "Hello"}]}'

Headers to Remove

If your OpenRouter integration sets any of these headers, you can safely drop them:

OpenRouter headerStatus in BitRouter
HTTP-RefererNot used
X-TitleNot used
transformsNot used — guardrails are configured server-side
routeNot used — routing lives in bitrouter.yaml or a named preset

Next Steps

Need Help?

How is this guide?

On this page