Configuring OpenRouter provider routing and model fallbacks
Inspect provider price and capability spreads via OpenRouter's public endpoints API, then combine provider routing, ZDR rules, and model fallbacks safely.
Pinning only a model ID in OpenRouter still leaves your traffic exposed to 7x price swings, different quantizations, and varying data-retention rules across inference providers. This guide combines live public endpoint data with local router tests to show how
providerrouting options andmodelsfallback arrays work together without conflicting.
Verification scope: The endpoint pricing, quantization, and parameter table below comes from a live unauthenticated call to OpenRouter’s public REST API (
GET /api/v1/models/meta-llama/llama-3.3-70b-instruct/endpoints) on2026-12-02(12:43:22Z). The six routing and fallback test cases (S1–S6) run against a local Node.jsv22.23.3router simulator (node:http+node:test) without anOPENROUTER_API_KEY. Live remote inference latency (TTFT) and real upstream failover durations are outside the scope of these tests.
Why the same model ID produces different costs and behavior
Suppose you run a backend API that reviews indemnity and termination clauses in customer contract drafts. You pin meta-llama/llama-3.3-70b-instruct, yet one week your token spend jumps or a request fails parameter validation. Behind a single model ID, OpenRouter routes traffic across multiple inference providers, and without explicit routing rules it picks whichever endpoint fits its default availability and sorting logic.
Querying the public endpoints API for meta-llama/llama-3.3-70b-instruct on 2026-12-02 returned seven active endpoints with wide gaps in price, quantization, and supported parameters:
Endpoint tag (tag) | Provider (provider_name) | Quantization | Input ($/M) | Output ($/M) | 30m Uptime | response_format | structured_outputs |
|---|---|---|---|---|---|---|---|
deepinfra/turbo | DeepInfra | fp8 | $0.10 | $0.32 | 100.0% | YES | YES |
akashml/fp8 | AkashML | fp8 | $0.20 | $0.52 | 100.0% | YES | YES |
parasail/fp8 | Parasail | fp8 | $0.22 | $0.50 | 100.0% | YES | YES |
cloudflare/fp8 | Cloudflare | fp8 | $0.29 | $2.25 | 100.0% | YES | NO |
groq | Groq | unknown | $0.59 | $0.79 | 100.0% | YES | NO |
coreweave/fp16 | CoreWeave | fp16 | $0.71 | $0.71 | 100.0% | YES | YES |
amazon-bedrock/us-east-1 | Amazon Bedrock | unknown | $0.72 | $0.72 | 100.0% | NO | NO |
Input pricing spans 7.2x from deepinfra/turbo ($0.10/M) to amazon-bedrock/us-east-1 ($0.72/M). Output pricing spans 7.0x from deepinfra/turbo ($0.32/M) to cloudflare/fp8 ($2.25/M). Quantization varies across fp8, fp16, and unknown, and amazon-bedrock/us-east-1 supports neither response_format nor structured_outputs.
For a contract-review API with long prompts and strict privacy requirements, fixing only the model name isn’t enough. You need explicit routing rules that define preferred providers, exclude non-compliant endpoints, and control how failover behaves when a provider goes down.
Inspecting provider endpoints with the public API
Before writing a provider block, check which endpoint tags actually exist for your model. OpenRouter’s GET /api/v1/models/:author/:slug/endpoints endpoint requires no API key, so you can run it in a pre-deploy script or CI check.
The script below uses Node.js v22.23.3’s built-in fetch with zero external packages to print each endpoint’s tag, quantization, per-million pricing, and parameter flags:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// inspect-endpoints.mjs (Node.js v22.23.3, no external dependencies)
const MODEL_ID = "meta-llama/llama-3.3-70b-instruct";
const URL = `https://openrouter.ai/api/v1/models/${MODEL_ID}/endpoints`;
function toPerMillion(raw) {
const n = Number(raw);
if (!Number.isFinite(n) || n < 0) return null;
return n * 1_000_000;
}
const res = await fetch(URL, {
headers: {
Accept: "application/json",
"User-Agent": "openrouter-endpoint-inspector/1.0",
},
});
if (!res.ok) {
throw new Error(`HTTP ${res.status} from ${URL}`);
}
const payload = await res.json();
const endpoints = payload?.data?.endpoints ?? [];
for (const ep of endpoints) {
const tag = String(ep.tag ?? "-");
const provider = String(ep.provider_name ?? "-");
const quant = String(ep.quantization ?? "unknown");
const inPm = toPerMillion(ep.pricing?.prompt);
const outPm = toPerMillion(ep.pricing?.completion);
const params = new Set(ep.supported_parameters ?? []);
console.log({
tag,
provider,
quant,
inPerM: inPm !== null ? `$${inPm.toFixed(2)}` : "-",
outPerM: outPm !== null ? `$${outPm.toFixed(2)}` : "-",
structuredOutputs: params.has("structured_outputs"),
responseFormat: params.has("response_format"),
});
}
Pay close attention to the tag field. Targeting deepinfra/turbo or coreweave/fp16 lets you select a specific deployment tier or quantization within a provider instead of matching only the provider name. Because pricing.prompt and pricing.completion arrive as per-token dollar strings, multiply by 1_000_000 to compare per-million rates.
Provider catalogs change without notice. Running node inspect-endpoints.mjs as a periodic check catches removed tags or sudden price spikes before they trigger runtime 503 errors.
Combining provider order, allowlists, and privacy rules
The provider object in a chat completion request controls three things: candidate filtering, ordering, and fallback boundaries. Each option solves a distinct problem, and mixing them carelessly causes surprises:
| Field | Role | Common pitfall and when to use it |
|---|---|---|
order | Preferred provider/tag attempt order | allow_fallbacks defaults to true, so requests still spill over to unlisted providers if your list fails |
only | Strict provider/tag allowlist | Drops every unlisted endpoint; returns HTTP 503 if all listed candidates fail |
ignore | Provider/tag blocklist | Useful for excluding an outlier in output cost or a region with elevated errors |
allow_fallbacks | Allow fallback outside order (default true) | Set false whenever compliance or cost caps forbid unapproved providers |
sort | Candidate sort ("price", "throughput", "latency") | Applies after order if both are present, sorting any remaining fallback candidates |
data_collection | Prompt retention/training policy ("allow" / "deny") | Setting "deny" filters out providers that don’t enforce a no-data-collection policy |
zdr | Require Zero Data Retention (true) | Restricts routing to endpoints that do not retain prompts or responses |
The most frequent mistake is assuming order pins your traffic. If you send provider: { order: ["deepinfra/turbo", "fireworks/fp8"] } without setting allow_fallbacks: false, OpenRouter falls back to a third provider outside your list the moment both preferred endpoints return 502 or 429. That’s fine for a general chatbot where uptime comes first, but it breaks compliance for a contract-review API restricted to vetted vendors.
For confidential contract text, pair zdr: true with data_collection: "deny". If you also want a hard stop rather than silent failover to an unapproved endpoint, combine only with allow_fallbacks: false so the API returns HTTP 503 and lets your application queue or reject the job explicitly.
When not to lock down too hard: putting a single endpoint in only together with allow_fallbacks: false and zdr: true turns any brief provider maintenance into an immediate 503 outage. For non-sensitive classification or summarization jobs where availability matters more than strict pinning, use ignore to drop bad endpoints and leave fallbacks enabled.
Layering model fallbacks and variant suffixes
Provider failover can’t save a request if every allowed endpoint for your primary model is degraded or rate-limited. Passing a models array instead of a single model string tells OpenRouter to try the next model automatically once the first model exhausts its candidates.
Here’s the order in which filtering, provider failover, and model failover execute:
flowchart TD
A["Request (models / provider)"] --> B["Filter candidates (only / ignore / zdr / data_collection)"]
B --> C["Sort & prioritize (order / sort / :floor / :nitro)"]
C --> D{"Endpoint succeeds?"}
D -->|"200 OK"| E["Return response & log model + provider"]
D -->|"Fail (502/429) & next model exists"| B
D -->|"No candidates left (or allow_fallbacks: false)"| F["Return HTTP 503"]
Keep the models array short—two to three models is usually enough. In our contract-review example, meta-llama/llama-3.3-70b-instruct serves as the primary model, with qwen/qwen-2.5-72b-instruct as a secondary model that handles similar context lengths.
Model variant suffixes act as shorthand for routing preferences on a model ID:
:floor— sorts by lowest price (equivalent toprovider.sort: "price"). Good for background batch jobs.:nitro— sorts by highest throughput (equivalent toprovider.sort: "throughput", permitting priority tiers). Good for interactive latency-sensitive flows.:exacto— restricts routing to endpoints vetted for higher tool-calling accuracy.
Watch out for one cross-model interaction: top-level provider constraints apply to every model in the models array. If you put a model-specific tag like only: ["deepinfra/turbo"] alongside a fallback model that doesn’t expose that tag, the fallback model has zero matching candidates and fails immediately with 503. When using models arrays, prefer policy filters (zdr, data_collection) or shared provider slugs over single-model tags.
Verifying six routing policies with a local router simulator
You don’t need a live API key to verify that your request payloads and failover assumptions hold up. Using Node.js v22.23.3’s node:http and node:test, we can run a local OpenRouter-compatible router simulator and assert all six routing behaviors locally.
The simulator catalog mirrors the live pricing spread (deepinfra/turbo at $0.10/M, groq at $0.59/M) and adds fireworks/fp8, together/fp8, and qwen/qwen-2.5-72b-instruct entries to exercise ZDR filtering and cross-model failover. Pointing the same client payload at https://openrouter.ai/api/v1/chat/completions with OPENROUTER_API_KEY requires no schema changes.
Here is the core candidate-selection logic inside mock-router-server.mjs:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// mock-router-server.mjs (candidate selection excerpt)
function selectCandidates(baseModel, providerCfg, variantSort) {
let eps = [...(ENDPOINT_CATALOG[baseModel] ?? [])];
const cfg = providerCfg ?? {};
if (Array.isArray(cfg.only) && cfg.only.length > 0) {
const onlySet = new Set(cfg.only);
eps = eps.filter((e) => onlySet.has(e.tag) || onlySet.has(e.provider));
}
if (Array.isArray(cfg.ignore) && cfg.ignore.length > 0) {
const ignSet = new Set(cfg.ignore);
eps = eps.filter((e) => !ignSet.has(e.tag) && !ignSet.has(e.provider));
}
if (cfg.zdr === true) {
eps = eps.filter((e) => e.zdr === true);
}
if (cfg.data_collection === "deny") {
eps = eps.filter((e) => e.dataCollection === "deny");
}
const sortMode = cfg.sort ?? variantSort;
if (sortMode === "price") {
eps.sort((a, b) => a.inPricePerM - b.inPricePerM);
} else if (sortMode === "throughput") {
eps.sort((a, b) => b.throughputTps - a.throughputTps);
}
if (Array.isArray(cfg.order) && cfg.order.length > 0) {
const ordered = [];
const seen = new Set();
for (const target of cfg.order) {
const match = eps.find((e) => e.tag === target || e.provider === target);
if (match && !seen.has(match.tag)) {
ordered.push(match);
seen.add(match.tag);
}
}
if (cfg.allow_fallbacks !== false) {
for (const e of eps) {
if (!seen.has(e.tag)) ordered.push(e);
}
}
return ordered;
}
return eps;
}
Next, routing-policy.test.mjs sends contract-review payloads and injects upstream 502 failures through an X-Fail-Providers header. S2 and S3 contrast allow_fallbacks: true vs. false, while S5 confirms cross-model failover under shared ZDR constraints:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// routing-policy.test.mjs (selected test cases)
it("S2: order with default allow_fallbacks=true falls back outside order list", async () => {
const { status, data } = await callRouter(
{
model: "meta-llama/llama-3.3-70b-instruct",
provider: {
order: ["deepinfra/turbo", "fireworks/fp8"],
allow_fallbacks: true,
},
messages: [{ role: "user", content: "Review indemnification clause 7.2." }],
},
["deepinfra/turbo", "fireworks/fp8"]
);
assert.equal(status, 200);
assert.equal(data.provider, "Together");
assert.equal(data.routing_audit.selected_tag, "together/fp8");
assert.equal(data.routing_audit.attempts.length, 3);
});
it("S3: allow_fallbacks=false + only returns HTTP 503 when locked providers fail", async () => {
const { status, data } = await callRouter(
{
model: "meta-llama/llama-3.3-70b-instruct",
provider: {
only: ["deepinfra/turbo", "fireworks/fp8"],
order: ["deepinfra/turbo", "fireworks/fp8"],
allow_fallbacks: false,
},
messages: [{ role: "user", content: "Review indemnification clause 7.2." }],
},
["deepinfra/turbo", "fireworks/fp8"]
);
assert.equal(status, 503);
assert.equal(data.error.code, 503);
assert.equal(data.error.metadata.attempts.length, 2);
});
it("S5: models array switches to 2nd model when all providers for 1st model fail", async () => {
const { status, data } = await callRouter(
{
models: [
"meta-llama/llama-3.3-70b-instruct",
"qwen/qwen-2.5-72b-instruct",
],
provider: { zdr: true, data_collection: "deny" },
messages: [{ role: "user", content: "Review termination clause 9.4." }],
},
[
"meta-llama/llama-3.3-70b-instruct:fireworks/fp8",
"meta-llama/llama-3.3-70b-instruct:together/fp8",
]
);
assert.equal(status, 200);
assert.equal(data.model, "qwen/qwen-2.5-72b-instruct");
assert.equal(data.provider, "Fireworks");
assert.equal(data.routing_audit.attempts.length, 3);
});
Running node inspect-endpoints.mjs followed by node --test --test-reporter=spec routing-policy.test.mjs verified all six cases in 79.15 ms:
| Case | Policy configuration | Injected failure | Observed result |
|---|---|---|---|
S1 | order: ["deepinfra/turbo", "fireworks/fp8"] | None | HTTP 200, routed to DeepInfra (deepinfra/turbo) |
S2 | order + allow_fallbacks: true | 1st & 2nd fail | HTTP 200, fell back to unlisted Together (together/fp8) on attempt 3 |
S3 | only + order + allow_fallbacks: false | 1st & 2nd fail | HTTP 503 after 2 attempts; no unlisted fallback |
S4 | zdr: true + data_collection: "deny" + sort: "price" | None | HTTP 200, skipped cheaper non-ZDR endpoint, selected Fireworks |
S5 | models: [llama-3.3-70b, qwen-2.5-72b] + ZDR rules | All 1st-model endpoints fail | HTTP 200, switched to qwen/qwen-2.5-72b-instruct (Fireworks) |
S6 | :floor vs. :nitro suffixes | None | :floor picked deepinfra/turbo ($0.10/M); :nitro picked groq (320 tok/s) |
Figure 1. Top: live unauthenticated GET to OpenRouter’s endpoints API on 2026-12-02 showing 7 endpoints and a 7.2x input price spread. Bottom: local mock router node:test suite passing all 6 scenarios (S1–S6) in 79.15 ms.
Production pitfalls and checklist
Three routing pitfalls to catch before shipping:
- Broken prompt-cache locality: Bouncing requests across different providers invalidates upstream prefix caches and raises both cost and latency. For APIs with large static system prompts, keep a consistent primary endpoint at the front of
order.onlytags blocking fallback models: Model-specific tags inonlycan filter out every endpoint on your secondary model inmodels, turning a failover into an avoidable503.- Logging only
modelwithoutprovider: Without recording both fields from the response, you can’t tell whether a cost jump came from a provider switch or a model switch.
Before enabling custom routing in production, run through these four checks:
- Snapshot endpoints in CI: Call
GET /api/v1/models/:author/:slug/endpointson a schedule to confirm that every tag inorderoronlyis still active and within your price cap. - Pair
onlywithallow_fallbacks: falsewhen pinning: Never rely onorderalone when vendor approval or data residency is mandatory. - Verify ZDR depth across fallbacks: When enabling
zdr: trueanddata_collection: "deny", confirm at least two compliant endpoints exist—or that your secondary model inmodelsalso has ZDR coverage. - Emit unified routing audit logs: Store response
id, resolvedmodel, resolvedprovider, and HTTP status together on every request so failover rates stay visible.