To migrate from OpenRouter you change three values in an OpenAI-SDK app: the base URL becomes https://api.oneaiapikey.com/v1, the key becomes one from the One AI API Key console, and the model id loses its author/ prefix and comes from our list. Then you check four things the URL does not carry: how fallbacks are written, what happens to provider routing options, which free ids you use, and whether you depend on an endpoint we do not offer.
What actually changes when you leave OpenRouter?
Three values change, and a handful of optional features do not map one to one. OpenRouter describes the move to its own service the same way: its migration cookbook says most migrations come down to the base URL, the API key and the model ID. The same is true in the other direction, because both sides speak the OpenAI format.
| Setting | OpenRouter | One AI API Key |
|---|---|---|
| Base URL | https://openrouter.ai/api/v1 |
https://api.oneaiapikey.com/v1 |
| Key | A key from OpenRouter, often in OPENROUTER_API_KEY |
A key from the console, suggested variable ONEAIAPIKEY_API_KEY |
| Model id | author/model, for example openai/gpt-4o-mini |
No slash prefix; copy the id from the model list |
| Attribution headers | HTTP-Referer and X-OpenRouter-Title, optional |
Not needed; X-Title groups usage by tool |
| Fallbacks | models array in the body; automatic provider fallback |
X-Fallback-Models header (up to 3 ids) or one console fallback |
| Provider options | A provider object (sort, require_parameters, zdr) |
Not used here |
| Free models | :free variants, 50 requests a day, 1,000 after $10 of credit |
:free ids sharing 100 requests and 3,000,000 tokens a day |
| Money | Credits with a 5.5% purchase fee on Standard | Prepaid credit, no fee when you add it |
Everything in the left column is from OpenRouter’s own pages, read on 26 November 2026: the compatibility page for the first four rows, the FAQ and pricing page for variants, fallback, free caps and the fee. The right column is our own documentation, which also has a short migration page and the quickstart for a first call. If you want the fee comparison behind the last row, the gateway fees guide lays out what several gateways charge, and the OpenRouter comparison is dated and sourced.
Before: your app on OpenRouter
After: the same app, new base URL
How do you swap the base URL and key without leaking the old one?
Set the new base URL and key from a new environment variable, and make the code refuse to start without it. The reason is a trap that OpenRouter’s compatibility page describes in the other direction, and which bites harder when you leave: if the key you pass to the official openai-python or Node client is missing, the SDK quietly falls back to OPENAI_API_KEY.
There are two ways to get this wrong while migrating. The first is the one OpenRouter documents: your new variable is unset in one environment, the SDK reads OPENAI_API_KEY instead, and an old key goes to the new host, which rejects it. That is noisy and harmless. The second is quieter and worse. You change base_url to ours and leave api_key=os.environ["OPENROUTER_API_KEY"] alone. Now your OpenRouter key is sent in the Authorization header of every request to a different company. We reject it, but we have received it, and you should treat it as exposed and rotate it. Our guide to API key security covers rotation, and the 12-factor config rule of keeping settings in the environment is what makes the fix a one-line change.
# .env, before
OPENROUTER_API_KEY=<your OpenRouter key>
# .env, after: a new name, so the old key can never be sent to the new host by accident
ONEAIAPIKEY_API_KEY=<your key from the console>
# delete OPENROUTER_API_KEY from every service that now talks to https://api.oneaiapikey.com/v1Create the key under Keys in the console and set a spend limit and an expiry date when you do, as the authentication guide shows; the guide to one key per project with spend limits is the pattern we recommend. A limit costs nothing and caps a loop that goes wrong on the first day, which is the day you are most likely to have one. The three snippets below show the swap in Python, Node and curl, with the guard that stops the silent fallback and a fallback header, which the next sections explain.
import os
from openai import OpenAI
# Before:
# client = OpenAI(
# base_url="https://openrouter.ai/api/v1",
# api_key=os.environ.get("OPENROUTER_API_KEY"),
# )
# After. Fail loudly when the key is missing, so the SDK cannot quietly fall back to OPENAI_API_KEY.
api_key = os.environ.get("ONEAIAPIKEY_API_KEY")
if not api_key:
raise RuntimeError("ONEAIAPIKEY_API_KEY is missing or empty")
client = OpenAI(base_url="https://api.oneaiapikey.com/v1", api_key=api_key)
reply = client.chat.completions.create(
model="z-ai-glm-5.3:free", # copied from the model list, no author/ prefix
max_tokens=200,
messages=[{"role": "user", "content": "Reply with the single word: ready"}],
# OpenRouter: extra_body={"models": ["<fallback-a>", "<fallback-b>"]}
extra_headers={"X-Fallback-Models": "qwen-qwen3.8-27b:free,deepseek-deepseek-v4.1-flash:free"},
)
print(reply.model) # the model that answered, which may be a fallback
print(reply.choices[0].message.content)
print(reply.usage)import OpenAI from "openai";
// Before: baseURL "https://openrouter.ai/api/v1" and apiKey process.env.OPENROUTER_API_KEY
const apiKey = process.env.ONEAIAPIKEY_API_KEY;
if (!apiKey) throw new Error("ONEAIAPIKEY_API_KEY is missing or empty");
const client = new OpenAI({ baseURL: "https://api.oneaiapikey.com/v1", apiKey });
const reply = await client.chat.completions.create(
{
model: "z-ai-glm-5.3:free", // copied from the model list, no author/ prefix
max_tokens: 200,
messages: [{ role: "user", content: "Reply with the single word: ready" }],
},
// Up to 3 fallback ids, tried in order when the provider fails before answering
{ headers: { "X-Fallback-Models": "qwen-qwen3.8-27b:free,deepseek-deepseek-v4.1-flash:free" } },
);
console.log(reply.model, reply.choices[0].message.content);curl https://api.oneaiapikey.com/v1/chat/completions \
-H "Authorization: Bearer $ONEAIAPIKEY_API_KEY" \
-H "Content-Type: application/json" \
-H "X-Fallback-Models: qwen-qwen3.8-27b:free,deepseek-deepseek-v4.1-flash:free" \
-d '{
"model": "z-ai-glm-5.3:free",
"max_tokens": 200,
"messages": [{"role": "user", "content": "Reply with the single word: ready"}]
}' -iIf your tool is not a hand-written SDK call, the same two values go in its settings. The SDKs and frameworks page lists base URL settings for the common libraries, the coding tool guides cover Cline, Cursor, Aider and others, and our post on setting up a coding agent compares them. For the environment-variable route, the guide to switching an OpenAI SDK app to a different base URL shows Node and Python without editing code.
How do OpenRouter model ids map to ours?
They do not map by rule, so copy each id from our list instead of editing the old one. OpenRouter asks for the author prefix, with ids such as openai/gpt-4o-mini. Ours have no slash prefix. Several ids start with the vendor name joined by a hyphen, such as z-ai-glm-5.3:free or qwen-qwen3.8-27b:free, which looks like a prefix with the slash replaced. Do not rely on that pattern. Spellings and version numbers differ, some ids have a priced twin and a free one, and a rule that works for three models will fail on the fourth.
Where do you find the right id? Three places agree with each other: the models table in the docs, the free models list for ids ending in :free, and GET /v1/models with your key, which returns the ids that key may call. If the key has a model allowlist, only those appear, so test with the same key your app will use.
Suffixes need special care. OpenRouter’s FAQ lists variants you can add to any slug: :free, :batch, and routing variants such as :nitro (sort providers by throughput), :floor (by price), :exacto (tool-calling reliability) and a deprecated :online. A :free suffix exists on both sides, but the ids differ, and the behaviour differs too: ours share one daily allowance, and a few are free-lane twins of priced models that draw on your sign-up credit first, which each model’s page states. The routing variants have no equivalent here, so remove them and decide what you wanted from them separately. The router ids map more closely: where OpenRouter has openrouter/auto, we have auto, auto:cheap and auto:best, and X-Auto-Allow and X-Auto-Deny narrow the choice, as the routing documentation explains.
Keep the mapping in one place and test it. The script below checks that every id on the right-hand side of your map is available to your key, and exits non-zero when one is not, so it can run in CI.
import os, sys
from openai import OpenAI
# Left: the slug your code sends to OpenRouter today. Right: the id you copied from this gateway's model list.
MODEL_MAP = {
"<your-openrouter-slug-a>": "z-ai-glm-5.3:free",
"<your-openrouter-slug-b>": "qwen-qwen3.8-27b:free",
}
client = OpenAI(base_url="https://api.oneaiapikey.com/v1", api_key=os.environ["ONEAIAPIKEY_API_KEY"])
available = {m.id for m in client.models.list().data} # GET /v1/models: the ids this key may call
missing = [new for new in MODEL_MAP.values() if new not in available]
print("not available to this key:", missing or "none")
sys.exit(1 if missing else 0)One more reason to keep ids in configuration rather than scattered through the code: ids change on every gateway. Free models in particular move; on 25 November 2026 we removed 11 ids from our own free lane because the log showed no successful request for them in 24 hours. A model id read from an environment variable is a restart, not a deploy. If you are picking a replacement, the model comparison and the guide to choosing a model for coding agents help, and the post on which free models to use for what sorts the free list by task. For priced replacements, cheap open model prices per million tokens lines up rates from the vendors’ own pages.
What replaces the models array and provider routing?
The X-Fallback-Models header replaces the fallback array, and nothing replaces the provider object. This is the biggest behavioural difference in the migration, so it deserves a precise description of both sides.
On OpenRouter, a failing provider is handled by routing. The FAQ says that if a provider returns an error, OpenRouter falls back to the next provider automatically, and the pricing page says failed attempts are not billed, so with fallback you pay only for the run that answers. On ours, when a provider fails before sending any part of the answer, the gateway first retries the model you named, up to twice. If the model is still failing, fallback rules, presets and automatic routing move the request to another similar model: up to three ids from your X-Fallback-Models header, in order, or a fallback you set once in the console. The free lane also retries a failing :free call on another model by itself. The reply carries X-Fallback-From with the model that failed, and its model field names the model that answered. Only the attempt that answers is billed. The failover section and the headers reference have the exact rules.
| OpenRouter feature | What to do here |
|---|---|
models array in the body |
Move the ids to X-Fallback-Models, up to 3, and add them to the key’s allowlist if it has one |
| Automatic fallback across providers of one model | Retries, then fallback rules, presets and auto routing to a similar model; name your own fallbacks too |
provider object (sort, require_parameters) |
Remove it; the gateway does not use it |
provider.zdr |
Remove it; read what the gateway records and the privacy guide |
:nitro, :floor, :exacto, :online suffixes |
Remove the suffix; pick the model and fallbacks yourself |
openrouter/auto |
Use auto, auto:cheap or auto:best |
| Attribution headers | Leave them or drop them; X-Title groups usage by tool |
Here is where OpenRouter is the stronger product, and we would rather you know before you migrate. Its routing moves a request to another provider of the same model, so the answer comes from the same weights. Ours retries the named model, then moves to a different, similar model, which is a different answer and may be a weaker one. If your app needs the same model from any provider, that is a reason to stay. If you are fine with a named second choice, the header is enough, and the uptime and fallbacks guide shows how much a second route adds.
Which features and endpoints do not carry over?
Anything outside chat, streaming, tools, vision and structured output needs a check, because our surface is narrower than OpenRouter’s. OpenRouter’s compatibility page lists chat completions, responses, embeddings, images, speech and transcription, models, files and batches as supported. Ours is documented on the migration guide and the API reference.
Here is what the migration guide says. Chat completions, streaming, tools and parallel tool calls, images in messages and reasoning_effort work as in the OpenAI API. The Responses API works on GPT models and is stateless, so send the full history each time instead of relying on stored state. Assistants, Threads, Files, Batch, fine-tuning and image variations are not available and answer 501. Embeddings work only when an embedding model is enabled for your account, so check GET /v1/models before building on it. If your pipeline uses OpenRouter’s Batch or Files endpoints, that part does not move and needs a plan B.
Three model-specific differences matter when you switch families. On Claude models through chat completions, response_format is dropped, so use a forced tool call or the /v1/messages route, as the structured output page says. Claude prompt caching works only through /v1/messages, covered in the prompt caching guide and the Anthropic Messages page. And Claude needs max_tokens, which defaults to 8192 here when you leave it out. We describe these from our documentation and have not sent test traffic to Claude models for this post.
Streaming deserves its own test. OpenRouter’s compatibility page says it sends periodic comment lines (: OPENROUTER PROCESSING) on slow starts and an error chunk if a provider fails mid-stream. The official SDKs ignore comment lines, so they are fine. A hand-written SSE parser should do the same, and should treat a chunk with an error key as a failure on both sides. Ours passes chunks as they arrive, and an error that comes after the answer started streaming is passed on as it is, per the routing documentation, so a mid-stream error is possible on both. The streaming guide and the post on streaming versus non-streaming responses cover what to handle.
What happens to your money, and to a free-tier habit?
Your credit stays with OpenRouter, so plan the last few weeks there. Credit does not move between gateways, and OpenRouter’s rules on getting it back are strict: the FAQ says refunds for unused credits can be requested within 24 hours, that platform fees are not refunded, and that crypto payments are never refundable, and the terms reserve the right to expire credits 365 days after purchase. In practice, stop topping up when you decide to leave, and let the balance run down. The post on prepaid credits says how large a balance is worth holding on any gateway, and the money-back terms checklist lists what to read before you add credit to the next one.
Fee on adding $100 of credit, from each vendor's own terms
- OpenRouter, Business$8.008% on credit purchases
- OpenRouter, Standard$5.505.5% with a $0.80 minimum
- One AI API Key$0.00no top-up fee; margin is inside the token rate
Our side of the money is short. First a dated caveat: on 26 November 2026 every priced id on the models page is marked unavailable because its upstream route is not answering, so a migration today means the free ids, and you should check a priced model’s page before you move paid traffic to it. A sign-in gives $10 of credit for priced models, once per connection or device. Adding credit later is done by email from $1, with no fee and no processing charge, because online checkout is not open yet; the pricing page shows the steps. Once a key is created and its usage is consumed we do not give money back; for a key that does not work or a technical problem on our side, contact support at somdutt777@gmail.com with a genuine concern. The billing documentation shows the arithmetic of a charge, and the transparency page says what we monitor and what we cannot see.
A free-tier habit changes in three ways. OpenRouter’s free models allow 20 requests a minute and 50 a day, rising to 1,000 a day once an account has bought at least $10, and per its pricing page failed attempts count toward that cap. Ours is 47 free models sharing 100 requests and 3,000,000 tokens a day per account, refilling at 00:00 UTC, in the API and in the chat alike (the chat guide shows what it can do). The free ids work with a $0 balance, with no top-up and no card, and keep working after the sign-up credit is spent. So a script that made 500 free calls a day after a $10 purchase will hit our cap first, and one that sent a few very long prompts will find ours more generous in tokens. The free tier comparison puts all the published caps next to each other.
What do errors and rate limits look like after the switch?
The codes you already handle still apply, and a few have different causes. OpenRouter’s pricing page says there is no plan-based rate limit on paid models, so a 429 there normally comes from a provider. Ours behaves the same for provider throttling, and adds limits you can set yourself, so the same status can mean different things.
| Status | What it means here | Retry? |
|---|---|---|
| 401 | Key missing, mistyped, disabled, expired or deleted | No: fix the key, see the stale-key trap above |
| 402 | A paid model with a $0 balance | No: add credit |
| 403 | Balance too low for this request, key spend limit reached, model not on the key’s list, or IP not allowed | No: add credit or edit the key |
| 429 | The provider is throttling, the key reached its requests-per-minute limit, or the daily free cap was reached | Yes, with backoff; honour Retry-After |
| 500, 502, 503 | Usually a short provider problem | Yes, with backoff |
The errors page has the exact codes, and the rate-limit guide says to retry 429, 500, 502, 503 and network errors with backoff and not to retry the others. The official SDKs already retry twice, so raise their retry count for batch work rather than adding a second loop that multiplies attempts. Our post on LLM API 429 errors separates the causes, and the errors page on retries has a hand-written loop.
How do you check the migration before real traffic moves?
Send the same small set of prompts to both gateways, compare the answers and the cost lines, and move traffic in steps. The comparison costs almost nothing, and it is the only way to find out whether a particular model behaves as you expect on a different route.
Migration checklist
0 of 12 done
Not started
Begin with the inventory and the new key. Nothing else is safe until you know where the old key is used.
A sensible rollout is three steps behind one environment variable. First a development environment on the free ids, which costs nothing and tests the plumbing. Then a small share of production, perhaps one request in twenty, with the old route kept intact. Then everything, with the old key still present in a secret store for a week in case you need to roll back, but not in the same service’s environment. At each step open the usage page and check that the model, tokens and cost match what your own logs say. If you want a stronger check that a route serves the model it names, the guide to verifying an LLM API gives six tests that run on a free model, and the reseller risks research explains why they matter on any cheap route.
Where are you migrating from?
An OpenAI SDK app
A framework such as LangChain or the Vercel AI SDK
provider object or a models array, because they are not used here. The SDKs and frameworks page lists base URL settings per library.A coding agent or editor
Mostly free models
OpenRouter with my own provider keys
When should you not migrate?
Do not migrate if one of three things is central to your app. The first is automatic provider fallback for the same model: OpenRouter has it, while we retry and then move to another similar model, which is not the same weights. The second is bring-your-own-key, which we do not offer. The third is breadth: its catalogue is larger than ours, and the pricing page lists 600+ models, so a rare model may exist there and not here. Our comparison page says all three, and the post on OpenRouter alternatives sets seven options side by side if neither gateway fits.
If none of those applies, the reasons to move are specific: no credit fee, a $0.80 minimum that no longer eats small top-ups, per-key spend limits and model lists, a free lane, and Anthropic and OpenAI formats on one key, as what an LLM gateway is explains. Whether those matter to you is a question about your own bill, and the cost calculator is the quickest way to answer it, with ten tactics to reduce LLM API costs for the part the gateway does not control. The One AI API Key review is the plain-spoken read of the service you would be moving to. If you are still choosing, our 12-point provider checklist scores the whole decision, and the transparency page says what we monitor and what we cannot see.
Send one request before you change anything
$10 sign-up credit, 47 free models sharing 100 requests and 3,000,000 tokens a day, no card.
Frequently asked questions
How long does it take to migrate from OpenRouter?
:nitro, and any use of OpenRouter's Batch or Files endpoints. Budget an afternoon for an app with one model and a day or two for one with routing rules, and use the checklist above to keep count.Will my OpenAI SDK code work unchanged?
Do I need to keep my OpenRouter credit?
Can I keep OpenRouter as a fallback?
Why does my free-model code return errors after I switch?
:free suffix exists on both sides, but the ids are different, so an OpenRouter slug will not match ours. Copy ids from the free models list, and remember that ours share one daily allowance of 100 requests and 3,000,000 tokens per account. A 429 with the daily-limit code means you reached it. The free ids work with a $0 balance, with no top-up and no card, and they keep working after the sign-up credit is spent. The browser chat is the quickest place to try an id.What is the equivalent of the models fallback array?
X-Fallback-Models header with up to three model ids, or a fallback model you set once in the console. The failover rules explain the order, and a reply from a fallback carries X-Fallback-From. The gateway retries the named model up to twice first, and if it is still failing, fallback rules, presets and automatic routing move the request to another similar model. The difference to know about is that this is another model, not another provider of the same model.