.png&w=3840&q=75)
Switching from OpenRouter to FastRouter: A Production Migration Guide
Moving from OpenRouter to FastRouter? Run smoke tests, audit request fields, bound retries and fallbacks, set budgets, and canary with a safe rollback
.png&w=3840&q=75)
TL;DR
- Keep the underlying model and production parameters fixed during the first comparison. A gateway migration and a model upgrade are separate changes.
- Inventory gateway-specific request fields. OpenRouter provider preferences, fallback configuration, and attribution headers need explicit review, not blind copying.
- Test application contracts, not just HTTP success. Streaming, schema validation, tool calls, and deadlines need separate acceptance checks.
- Coordinate retries across every layer. SDK retries, gateway fallbacks, application retries, and queue redelivery can multiply attempts.
- Keep rollback outside FastRouter. Internal fallbacks cannot recover an application that cannot reach the gateway.
What Transfers, and What Does Not
For a basic text-only chat-completions integration, the familiar pieces remain:
- An OpenAI SDK client.
- A messages array.
- A chat.completions.create call.
- A response consumed by application code.
That is a useful starting point. It is not a production compatibility guarantee.
Area | Migration work |
|---|---|
Connection | Replace the base URL and credential |
Model selection | Verify exact FastRouter identifiers and account access |
Request extensions | Remove or replace gateway-specific fields and headers |
Routing | Recreate provider eligibility, priorities, and fallbacks |
Error handling | Check status handling, error parsing, and retry decisions |
Access control | Configure projects, scoped keys, permissions, and budgets |
Observability | Connect traces, application metrics, and alerts |
Billing | Verify BYOK or Wallet behavior and applicable charges |
Rollout | Establish a canary and an independent rollback path |
The reason to migrate should also be explicit. Built-in project boundaries, scoped access, tracing, or a different billing arrangement can justify the work. A longer feature list alone does not.
A working gateway that the team understands is worth more than an untested replacement.
1. Record the Existing Contract Before Changing the Endpoint
A migration without a baseline produces speculation.
If latency increases after cutover, the team needs to distinguish a gateway change from a provider change, a model change, or a different request mix. Moving all of them together makes the result difficult to explain.
Build a Small, Representative Test Set
The useful test cases are the ones that exercise production dependencies:
- Short interactive text.
- Long input near the application's normal upper range.
- Structured output validated against the production schema.
- Tool calls using actual tool definitions.
- Streaming through the application's real ingress.
- Requests approaching the application deadline.
- Image or other multimodal input, where used.
- Expected failures, including invalid credentials and unknown model identifiers.
Each case needs an application-level pass condition.
For a ticket classifier, success means valid output containing an allowed category, not merely a readable answer. For an agent, success includes a valid tool name and arguments that pass validation. For a streaming interface, success includes interruption handling.
Exact text equality is usually the wrong comparison. The contract matters more than the wording.
Separate Gateway Migration From Model Evaluation
The cleaner sequence is:
- Record representative results through OpenRouter.
- Run equivalent requests through FastRouter using the same underlying model and settings where available.
- Compare task success, latency, failures, and cost.
- Evaluate model substitutions separately.
If the same model is unavailable, that path requires an explicit model evaluation. It is not a mechanical identifier mapping.
2. Swap the Base URL and Credential
FastRouter's API base URL is:
text
The SDK receives that base URL, not the full /chat/completions endpoint.
The examples below read the model identifier from FASTROUTER_MODEL. FastRouter uses provider/model identifiers, for example openai/gpt-5.2. That specific identifier is shown only to illustrate the format; the exact identifier for this migration must be copied from FastRouter's live catalog before execution.
The shell environment must contain:
- FASTROUTER_API_KEY: a non-production FastRouter credential.
- FASTROUTER_MODEL: an exact identifier copied from the current catalog.
Credentials belong in a secret manager or local environment, not in source control.
cURL
This example requires jq to construct the JSON safely.
bash
1: "${FASTROUTER_API_KEY:?FASTROUTER_API_KEY must be set}"2: "${FASTROUTER_MODEL:?FASTROUTER_MODEL must be set}"34jq -n \5 --arg model "$FASTROUTER_MODEL" \6 '{7 model: $model,8 messages: [9 {role: "user", content: "Reply with exactly: migration-ok"}10 ]11 }' |12curl --fail-with-body --max-time 30 \13 https://api.fastrouter.ai/api/v1/chat/completions \14 -H "Authorization: Bearer ${FASTROUTER_API_KEY}" \15 -H "Content-Type: application/json" \16 --data-binary @-17
Python
Install the dependency with pip install openai, then run:
python
1import os23from openai import OpenAI45client = OpenAI(6 api_key=os.environ["FASTROUTER_API_KEY"],7 base_url="https://api.fastrouter.ai/api/v1",8 timeout=30.0,9 max_retries=0,10)1112response = client.chat.completions.create(13 model=os.environ["FASTROUTER_MODEL"],14 messages=[15 {"role": "user", "content": "Reply with exactly: migration-ok"}16 ],17)1819print(response.choices[0].message.content)
TypeScript
Install dependencies:
bash
1npm install openai2npm install --save-dev typescript tsx @types/node3
Save this as smoke.ts and run it with npx tsx smoke.ts:
typescript
1import OpenAI from "openai";23async function main(): Promise<void> {4 const apiKey = process.env.FASTROUTER_API_KEY;5 const model = process.env.FASTROUTER_MODEL;67 if (!apiKey || !model) {8 throw new Error(9 "FASTROUTER_API_KEY and FASTROUTER_MODEL must be set",10 );11 }1213 const client = new OpenAI({14 apiKey,15 baseURL: "https://api.fastrouter.ai/api/v1",16 timeout: 30_000,17 maxRetries: 0,18 });1920 const response = await client.chat.completions.create({21 model,22 messages: [23 { role: "user", content: "Reply with exactly: migration-ok" },24 ],25 });2627 console.log(response.choices[0]?.message.content);28}2930main().catch((error: unknown) => {31 console.error(error);32 process.exitCode = 1;33});
Automatic SDK retries are disabled deliberately. The smoke test should expose the first failure, not hide it behind another attempt. These client settings do not disable any retries configured inside the gateway.
Test Streaming Separately
After the Python smoke test, the same client can run a streaming check:
python
1stream = client.chat.completions.create(2 model=os.environ["FASTROUTER_MODEL"],3 messages=[{"role": "user", "content": "Count to five."}],4 stream=True,5)67for chunk in stream:8 if not chunk.choices:9 continue1011 content = chunk.choices[0].delta.content12 if content:13 print(content, end="", flush=True)1415print()
The empty-choices guard matters. OpenAI-compatible streams can include chunks without a completion choice, such as usage-only chunks when supported and requested. Blindly indexing choices[0] can turn a successful inference into an application exception.
This loop tests text deltas. It does not validate streamed tool-call assembly.
Streaming also needs a test through the production ingress. A proxy that buffers responses can make a healthy stream look stalled until generation finishes.
3. Audit Request Extensions and Map Every Model Identifier
"OpenAI-compatible" does not mean every field accepted by one gateway belongs in another gateway's request.
Find the OpenRouter-Specific Behavior
The inventory should include:
- HTTP-Referer and X-Title attribution headers.
- Provider-preference objects.
- A models array used for fallback.
- Gateway-specific model suffixes.
- Wrapper libraries that inject configuration.
- Error parsers tied to OpenRouter-specific response bodies.
Unknown fields might be rejected or ignored. Silent acceptance is not evidence that the old behavior survived.
A request returning text does not prove that provider restrictions or fallback policies were applied.
Build an Explicit Mapping Table
Search beyond application source:
- Inspect service repositories.
- Check environment configuration, deployment manifests, and feature flags.
- Inspect scheduled jobs, administrative tools, and evaluation harnesses.
- Check database-backed configuration.
- Map every identifier against FastRouter's current catalog.
A useful table records the call site, required behavior, old identifier, new identifier, and test result.
The forgotten branch is the dangerous one. The main chat endpoint can pass while a weekly extraction job still references an unavailable model.
Model mapping also needs parameter validation. Different model families may support different generation settings or token-limit fields. A replacement that accepts a minimal prompt can still reject the production request.
The production parameter set belongs in the test.
Treat Virtual Model Aliases as Deployments
FastRouter's Virtual Model Aliases can separate an application-facing name from its underlying model configuration.
That removes the need for some application releases. It also moves deployment risk into configuration.
An alias change can affect every worker without a corresponding code change. Alias targets therefore need:
- An owner.
- Evaluation before promotion.
- Change history.
- Restricted edit permissions.
- A known rollback target.
An alias removes a code deployment. It does not remove deployment discipline.
4. Rebuild Routing, Fallbacks, and Retry Boundaries
Provider routing and model fallback are related, but they are not the same operation.
Provider routing chooses an eligible route for a model. Model fallback may substitute another model entirely. Confusing the two makes quality and cost changes harder to explain.
FastRouter lists routing strategies including lowest price, lowest latency, highest throughput, weighted shuffle, priority order, category routing, and AI Auto Router. Configuration should follow the current documentation at docs.fastrouter.ai, rather than guessed request parameters.
Keep the First Route Predictable
The initial canary should minimize moving parts.
- Interactive requests need first-token latency and deadline checks.
- Batch workloads need throughput, output validity, and effective-cost checks.
- Sensitive workloads need enforced provider eligibility.
- Tool-using agents need compatible tool behavior across every permitted target.
Priority order is not a compliance boundary. A disallowed provider must be excluded, not placed last.
Automated routing can be evaluated later. During migration, a stable route makes regressions easier to isolate.
Require Every Fallback to Satisfy the Contract
FastRouter's Fallback Models provide a configured chain of alternative models. The exact trigger conditions need verification in the deployed configuration.
A fallback target must preserve:
- Required input modalities.
- Sufficient context capacity.
- Structured-output requirements.
- Tool-calling requirements.
- Approved provider boundaries.
- Acceptable latency and cost.
A fallback that returns prose where the application requires validated JSON has not recovered the task.
Fallback usage also needs visibility. A primary route can fail continuously while a fallback keeps HTTP success rates healthy. Quality, cost, and latency may all change behind that green dashboard.
Stop Retry Multiplication
A request may pass through several retry layers:
- SDK retries.
- Application retries.
- Gateway fallback attempts.
- Queue redelivery.
Each layer needs a defined purpose and a bounded attempt budget. The complete chain must fit within the application deadline.
Malformed requests should not consume a long fallback chain. Retrying an invalid model identifier does not make it valid.
Side-effecting tools need application-level idempotency. If a job executes a refund, loses its acknowledgement, and is redelivered, the refund must not execute again. Gateway inference retries do not automatically duplicate application actions, but workflow retries can.
That distinction matters. So does testing it.
Define Mid-Stream Failure Behavior
Before output reaches the client, a failed attempt may be replaceable. After partial output has been committed, switching models can create duplicated text, contradictory continuation, or invalid structured output.
The application needs an explicit policy:
- Surface the interruption.
- Restart the response visibly.
- Retry only before output has been committed.
Transparent recovery should not be assumed. The actual error and disconnect behavior belongs in staging tests.
5. Recreate Access Boundaries Before Production Traffic Moves
A shared credential can turn a runaway development job into a production incident.
FastRouter's Projects, RBAC, scoped keys, budgets, and Provisioning Keys provide controls for separating workloads. The migration should map operational boundaries onto those controls rather than reproduce an unrestricted shared-key setup.
Useful boundaries include:
- Production versus staging.
- Interactive requests versus batch jobs.
- Separate services or products.
- Customer-specific workloads where isolation is required.
The exact project layout should follow ownership and blast radius. A project per service per environment can work; it is not a universal requirement.
Test Permissions and Budget Enforcement
A tightly scoped key can pass the main smoke test and still fail when a background task calls another model. The scope must cover the complete inventory, including fallback targets.
Budget settings also need observed behavior:
- Does the threshold alert, block, or both?
- What happens to concurrent and in-flight requests?
- How quickly does enforcement react?
- What error does the application receive?
- Can another credential scope bypass the limit?
No particular status code should be assumed.
Provisioning credentials deserve separate handling. A credential capable of creating or revoking application keys should not be distributed to ordinary application containers.
6. Move Observability and Verify Billing
Keep Application Telemetry
FastRouter's Tracing and Alerts are intended to expose inference activity, latency, usage, cost, and operational failures. Available fields and capture settings should be checked against representative requests before replacing existing instrumentation.
Gateway telemetry cannot replace application telemetry.
An HTTP success can still contain an invalid category, unusable JSON, or the wrong tool choice. The canary dashboard should include:
- Gateway errors by status.
- Schema-validation failures.
- Tool-selection and execution failures.
- Time to first token and total duration.
- Deadline violations.
- Retry and fallback activity where exposed.
- Cost per successfully completed task.
Cost per request is incomplete when failed outputs require additional requests.
Decide Payload Policy Before Enabling Capture
Prompts, completions, and tool arguments can contain customer data or secrets.
Before payload capture is enabled, the team needs to establish retention, access permissions, redaction controls, and storage obligations. If acceptable capture controls are unavailable, application-side telemetry may need to remain the primary debugging source.
Alerts need a delivery test too. A saved threshold is not proof that the on-call channel receives a notification.
Choose BYOK or Wallet Deliberately
BYOK uses the team's provider credentials and preserves the direct provider billing path. It is relevant for negotiated rates, committed spend, and account-specific capacity.
It does not automatically establish that every existing legal or data-handling agreement covers an intermediary. That requires review.
Wallet consolidates inference billing through FastRouter. It reduces provider-account administration but introduces a funding dependency. Low-balance behavior and failed replenishment need operational checks.
FastRouter states zero markup on token costs under both options. That claim should be checked against current pricing and account terms. Zero token markup is not the same as zero total platform cost.
One real request should confirm the intended billing path. The first production invoice is too late to discover that traffic used the wrong account.
7. Canary the Migration and Exercise Rollback
A full cutover is not a compatibility test.
The application should retain independently selectable OpenRouter and FastRouter configurations, including credentials, model mappings, and gateway-specific settings.
A controlled rollout proceeds in order:
- Run synthetic requests.
- Move an internal or low-risk workload.
- Route a small, stable production cohort.
- Compare results against predefined acceptance criteria.
- Expand only after representative traffic has passed.
- Retire the old route after the rollback window closes.
Sticky cohorts make investigation easier. Keeping a conversation or job on one route also avoids unnecessary cache fragmentation and behavioral changes within the same workflow.
Shadow traffic needs separate care: it adds cost, duplicates data processing, and must never execute production tool side effects twice.
Rollback belongs outside FastRouter. A runtime flag or deployment configuration should restore the complete OpenRouter path, not just its URL. Whether that requires a deployment depends on how the application loads configuration.
The rollback must be exercised before expansion.
Distribution Notes
Platform Adaptations
Engineering blog: Publish the full guide with the code blocks intact. Suggested URL slug: openrouter-to-fastrouter-migration-guide.
A successful chat completion proves connectivity. It does not prove an LLM gateway migration is safe.
The production checks are elsewhere: forgotten model identifiers, gateway-specific request fields, retry multiplication, partial streams, scoped credentials, and billing paths.
This OpenRouter-to-FastRouter guide covers runnable smoke tests and a canary plan with rollback outside the gateway.
The rule: migrate the gateway first. Evaluate model changes separately.
Attach the article link.
X
A green smoke test can hide a broken LLM gateway migration.
The real checks: model IDs, request extensions, retry budgets, partial streams, scoped keys, and billing.
OpenRouter to FastRouter: production migration guide.
Attach the article link.
Engagement Strategy
- Publish during a weekday morning in the primary engineering audience's time zone. Treat this as a starting hypothesis, not an established optimum.
- Use optional tags sparingly: #LLM, #SoftwareEngineering, #Observability.
- Share through engineering newsletters and relevant developer communities where vendor migration guides are permitted.
- Have the technical author answer compatibility questions with reproducible details. Avoid coordinated promotional comments.
Expected Performance
No historical audience or distribution data is supplied, so numeric engagement projections would be invented. The likely strength is high-intent search and reference sharing rather than broad reach.
Track article visits, code-block copies, documentation clicks, qualified technical questions, and return visits. Establish a baseline before setting numerical targets.
A/B Testing
Test one hook at a time:
- Compatibility angle: "A Successful Chat Completion Is Not a Successful Gateway Migration."
- Failure-mode angle: "The Retry Layers That Break LLM Gateway Migrations."
Compare click-through and engaged reading, not reactions alone.
Brand Compliance
The copy maintains an engineering-first voice, names operational downsides, avoids unsupported competitor fee claims, and distinguishes advertised pricing from verified total cost. Catalog availability and account-specific product behavior remain explicit verification steps.
What to Do This Week
- Monday: inventory the integration. Record model identifiers, request extensions, required capabilities, retry layers, deadlines, and provider restrictions. Include scheduled jobs and database-backed configuration.
- Tuesday: establish the baseline and run smoke tests. Create a non-production FastRouter credential, verify a catalog identifier, and run the cURL, Python, TypeScript, and streaming checks. Save representative failures with secrets removed.
- Wednesday: configure boundaries. Set up projects, scoped credentials, routing, compatible fallback targets, and budgets. Test every required model with the actual service credential.
- Thursday: provoke failures. Exercise invalid credentials, unavailable routes, timeouts, interrupted streams, key revocation, and workflow redelivery. Confirm which layer retries and whether side-effecting tools remain idempotent.
- Friday: prove visibility and rollback. Send a test alert, validate the billing path, and switch the candidate workload back to OpenRouter. Start a production canary only after the acceptance criteria, payload policy, and rollback test are complete.
Related Articles


Can an LLM gateway run free and paid models in one account?
An LLM gateway can run free and paid models in one account. Learn how to define routing, approve fallback paths, and inspect usage before production.


How to connect Codex CLI to FastRouter for automatic failover
Codex CLI FastRouter integration: validate API compatibility, configure model fallbacks, and test recovery before rolling out a governed coding workflow.


LLM gateway for HR tech AI teams: complete 2026 guide
Choose an LLM gateway for HR tech AI teams with tested routing, failover, and governance. Compare architectures and define safe rollout criteria.