Migrate

Switch gateways in two lines. Keep your code.

Migrating from OpenRouter, OpenAI, or Portkey means changing the base URL and the API key while keeping your SDKs and frameworks.

Two lines. That is the migration.

Repoint base_url to http://localhost:4111/v1 and swap the key. Prompts, streaming, and error handling stay unchanged.

1# Before — OpenRouter
2client = OpenAI(
3 base_url="https://openrouter.ai/api/v1",
4 api_key="sk-or-...",
5)
6
7# After — nRouter (only two lines change)
8client = OpenAI(
9 base_url="http://localhost:4111/v1",
10 api_key=os.environ["NROUTER_API_KEY"],
11)
Installpip install openai
1# Cache: enabled (org default). Pass nrouter_cache: false to skip.
2from openai import OpenAI
3import os
4
5client = OpenAI(
6 api_key=os.environ["NROUTER_API_KEY"],
7 base_url="https://api.nrouter.ai/v1",
8)
9
10response = client.chat.completions.create(
11 model="gpt-5.4-mini",
12 temperature=1,
13 max_completion_tokens=1024,
14 messages=[
15 {"role": "user", "content": "Hello! What models do you support?"},
16 ],
17 extra_body={
18 # "nrouter_cache": False, # Uncomment to skip cache
19 },
20)
21
22print(response.choices[0].message.content)

The four-step cutover.

Run nRouter alongside your current setup, verify a slice of traffic, and move the rest when ready.

  • Create a key

    Sign up at nrouter.ai, add credits, and generate an sk-nrouter-* virtual key.Step 1
  • Repoint the base URL

    Set your client base_url to http://localhost:4111/v1, the same OpenAI-compatible path.Step 2
  • Swap the key

    Replace your old provider or gateway key with the nRouter virtual key.Step 3
  • Verify and cut over

    Send a test request, confirm the response shape, and shift traffic when ready.Step 4

Per-source migration notes.

What changes when moving from OpenRouter, OpenAI direct, or Portkey.

From OpenRouter.

OpenRouter is OpenAI-compatible, so migration is a base-URL and key swap.

  • Swap https://openrouter.ai/api/v1 for the nRouter endpoint
  • 0% platform fee vs OpenRouter’s published 5.5% fee on Standard-plan credit purchases
  • Gain built-in guardrails, RBAC teams, and per-team budgets
nRouter vs OpenRouter

From OpenAI direct.

Keep the OpenAI SDK and API surface while unlocking the multi-provider catalog.

  • Replace api.openai.com/v1 with the nRouter endpoint
  • nRouter manages the provider keys; you hold one virtual key
  • Switch models by changing one string with real-time cost tracking
Explore models

From Portkey.

Repoint your gateway base URL and get every governance feature on pay as you go.

  • Swap api.portkey.ai/v1 for the nRouter endpoint
  • Guardrails, observability, and prompt templates included
  • One credit balance and one bill with a 0% platform fee
nRouter vs Portkey

What the two lines buy you.

Pay as you go at exact model list prices with inline guardrails, budgets, and team roles included.

Zero platform fee.

You keep 100% of the credits you buy, settled at each model’s exact list price.

0%

platform fee on credits

Pay as you go.

One self-serve plan with every control unlocked: routing, guardrails, RBAC, and audit logs.

$5

minimum credit purchase

Inline guardrails.

PII redaction, prompt-injection defense, and budget checks run before a provider is called.

$0

held or spent when refused

FAQs

How long does migrating to nRouter take?

The code change is two lines. nRouter exposes an OpenAI-compatible REST API, so you change the base URL and the API key, and your existing code, SDKs, and frameworks keep working without modification.

Do I have to rewrite my code or swap SDKs?

No. nRouter speaks the OpenAI API. If you use the OpenAI Python or Node SDK, LangChain, LlamaIndex, the Vercel AI SDK, or any OpenAI-compatible client, you only repoint the base URL.

Can I migrate from OpenRouter to nRouter?

Yes. OpenRouter is also OpenAI-compatible, so the migration is a base-URL and key swap. nRouter additionally gives you built-in guardrails, team management, audit logs, and a lower platform fee: 0% platform fee on credits versus OpenRouter's published fee on Standard-plan credit purchases.

Can I migrate from OpenAI directly to nRouter?

Yes. Replace api.openai.com with the nRouter endpoint and use a nRouter virtual key. You keep one OpenAI-style API and gain access to multiple model providers, built-in guardrails, per-team budgets, and real-time cost and usage tracking, without managing provider keys yourself.

What about model names, do they change?

You select models by their nRouter model id. The catalog and exact ids are listed on the models page; switching models is a one-string change with no SDK swap.

Is there a cost to migrate or run both in parallel?

No migration fee. You can run nRouter alongside your current gateway during cutover: point a share of traffic at the new base URL, verify, then move the rest. The platform fee is 0%, and usage settles at each model's exact list price from the credits you buy.