Migrate from OpenRouter
Move from OpenRouter to Flux. Both are OpenAI-compatible gateways, so it is a base URL, key and model swap.
OpenRouter and Flux are both OpenAI-compatible gateways, so migrating is the same kind of swap you would do between any two OpenAI-compatible endpoints. You change three things:
- Base URL to
https://api.fluxrouter.ai/v1 - API key to your Flux key (
sk-...from the dashboard) - Model to
flux-auto(or a specificflux-*id)
The OpenAI SDK, the endpoints, and the request and response JSON stay the same.
Get a Flux key
Sign up at /auth/sign-up and copy your key. It looks like sk-.... Get your key walks through it. The examples below read it from a FLUX_API_KEY environment variable.
Migrate the Python SDK
Before (OpenRouter)
from openai import OpenAI
client = OpenAI(
api_key="sk-or-...",
base_url="https://openrouter.ai/api/v1",
)
response = client.chat.completions.create(
model="anthropic/claude-sonnet-4-5",
messages=[{"role": "user", "content": "Say hello."}],
)
print(response.choices[0].message.content)
After (Flux)
from openai import OpenAI
client = OpenAI(
api_key="sk-...", # your Flux key
base_url="https://api.fluxrouter.ai/v1", # changed base URL
)
response = client.chat.completions.create(
model="flux-auto", # let Flux route, or pin a flux-* id
messages=[{"role": "user", "content": "Say hello."}],
)
print(response.choices[0].message.content)
Migrate the Node SDK
Before (OpenRouter)
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.OPENROUTER_API_KEY,
baseURL: "https://openrouter.ai/api/v1",
});
const response = await client.chat.completions.create({
model: "anthropic/claude-sonnet-4-5",
messages: [{ role: "user", content: "Say hello." }],
});
console.log(response.choices[0].message.content);
After (Flux)
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.FLUX_API_KEY, // your Flux key
baseURL: "https://api.fluxrouter.ai/v1", // changed base URL
});
const response = await client.chat.completions.create({
model: "flux-auto", // let Flux route, or pin a flux-* id
messages: [{ role: "user", content: "Say hello." }],
});
console.log(response.choices[0].message.content);
Mapping model ids
On OpenRouter you pass provider-prefixed model ids like anthropic/claude-sonnet-4-5 or openai/gpt-4o. On Flux you pass a Flux alias instead:
flux-auto(recommended): Flux picks among vetted models for each kind of task, cost-aware, so you usually do not hand-pick a model at all. This is the main difference in day-to-day use: with OpenRouter you choose the model; withflux-auto, Flux chooses for you.- A lane alias (
flux-fast,flux-standard,flux-reasoning) to target a speed and capability lane and its rate. - A
flux-pinned-*id when you want a specific backing model every time. Find the id on Models or list them withGET https://api.fluxrouter.ai/v1/models.
What each option costs is on Pricing. For a side-by-side of the two gateways, see Flux vs OpenRouter.
What stays the same
- The OpenAI SDK and its method names.
- The endpoints:
/v1/chat/completions,/v1/responses,/v1/models. - Auth header style:
Authorization: Bearer sk-.... - The request and response JSON, including streaming, tool calls, and structured outputs.
Before you switch production traffic
Run these checks with the new key before real traffic moves.
- List models.
GET https://api.fluxrouter.ai/v1/modelsproves the key works and shows the ids you can use. - Send one non-streaming call and read the headers. You should see the receipt headers from Receipts, including
X-Flux-Cost-Usd. A streamed response has no cost header. - Send one streaming call. Check that your chunk parsing holds to the end of the stream.
- Run one tool-call round trip with your real tool schema. If tools are essential to your product, test the pinned model you will rely on as well as
flux-auto, because tool support belongs to the model that answers. - Check any pin. Send your
flux-pinned-*id without streaming and readX-Flux-Routed: falseandX-Flux-Model. - Log
X-Flux-Request-Idfrom day one. It is the first thing support asks for. - Canary first. Set a prepaid daily or monthly cap in Billing (see Spend caps), send a slice of traffic, compare errors, latency and cost with your OpenRouter baseline, and keep the old key until a full day runs clean. The old key is your rollback.
Next steps
- Models: the live catalogue and how
flux-autoand pinning work. - How routing works and Lanes.
- Receipts: see which model answered and what it cost.