Configuring provider routing and model fallback in OpenRouter
Compare provider selection and model fallback in OpenRouter using the public endpoint catalog and two tested request payloads.
A provider change can leave the model ID intact. A model fallback can change it. I use two Jekyll release-note requests to show which fields identify the route that served each one.
I checked the public endpoint catalog on December 1, 2026. I ran the request construction and response handling in Bash with jq 1.7.1, substituting mock responses for curl’s HTTP calls. To send the commands as written, use curl 7.76 or later.
Keep the model and the provider in the same record
In my OpenRouter request walkthrough, I saved the returned model and provider together. That makes a route change easier to interpret. A provider can run a model another company developed, and several providers can offer the same model. Here google/gemma-4-31b-it names the model. kt and crusoe name two endpoint tags for it. A request can keep Gemma fixed and change only its provider, or it can allow a switch to a different model. OpenRouter provider routing · OpenRouter failover
| What you want | What to set | What to inspect |
|---|---|---|
| Prefer certain providers for the same model | model with provider.order | The returned provider |
| Allow the request to reach only approved providers | provider.only | The returned provider and the allowlist |
| Try another model if the primary can’t serve the request | An ordered models array | The first model in the request and the returned model |
Read the tags from the public catalog
The public Gemma endpoint response listed kt as KT and crusoe as Crusoe. This command prints each tag with its display name. The catalog call requires no key. Check the current list before using the example, since an endpoint can be renamed or removed. Gemma endpoint response · List endpoints API
1
2
3
4
set -o pipefail
curl --silent --show-error --fail-with-body \
'https://openrouter.ai/api/v1/models/google/gemma-4-31b-it/endpoints' |
jq -r '.data.endpoints[] | [.tag, .provider_name] | @tsv'
A provider can have endpoints for different regions or service tiers. Use the precise tag if the request must target a specific one. The public catalog tells you which endpoints it lists. Workspace policy and availability can still determine which of them are eligible to receive a particular request. Provider slugs and endpoint tags
Set an order and a boundary for one model
Set OPENROUTER_API_KEY in Bash and save the Jekyll excerpt from the request walkthrough above as release-notes.md. The first prompt names Gemma. I put KT first in order and Crusoe next, then use only to keep the provider candidates within that pair. A completion can use paid credits. Jekyll 4.4.0 release · OpenRouter usage accounting
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
set -o pipefail
openrouter_chat() {
curl --silent --show-error --fail-with-body --max-time 60 \
'https://openrouter.ai/api/v1/chat/completions' \
-H "Authorization: Bearer ${OPENROUTER_API_KEY:?Set OPENROUTER_API_KEY}" \
-H 'Content-Type: application/json' --data-binary @- |
jq '{id, model, provider, cost: .usage.cost,
finish_reason: .choices[0].finish_reason,
error: (.error // .choices[0].error)}'
}
jq -n --rawfile notes release-notes.md '{
model: "google/gemma-4-31b-it",
provider: {order: ["kt", "crusoe"], only: ["kt", "crusoe"]},
messages: [{role: "user", content: ("Summarize in two bullets:\n\n" + $notes)}],
max_completion_tokens: 512
}' | openrouter_chat
A response with model=google/gemma-4-31b-it and provider=Crusoe identifies Crusoe as the provider that ran Gemma. The two fields tell you the final route. Determining whether KT was ineligible at selection time or attempted the request and failed requires routing records for that request. If the response omits the provider, use its generation ID to look up data.provider_name. Get generation metadata
Check whether a different model served the request
Run the second block in the same shell. The messages and output cap stay the same, and the request names Gemma followed by Gemini in models. OpenRouter can try the second model if the primary can’t serve the request. A returned Gemma ID means the primary served it. A returned Gemini ID means the fallback model served it. OpenRouter model fallbacks
1
2
3
4
5
jq -n --rawfile notes release-notes.md '{
models: ["google/gemma-4-31b-it", "google/gemini-3.1-flash-lite"],
messages: [{role: "user", content: ("Summarize in two bullets:\n\n" + $notes)}],
max_completion_tokens: 512
}' | openrouter_chat
I supplied a Gemma response with Crusoe as the provider for the first test, then a Gemini response for the second. The outgoing payloads contained the intended provider policy and the ordered model list, respectively. The response projection reported the model and provider from each fixture. The simulated HTTP 503 produced both an error object and a nonzero exit status. A separate mock HTTP 200 contained a choice-level error, which appeared in error. The curl option --fail-with-body preserves the body on an HTTP failure, and Bash’s pipefail carries an earlier command’s failure through the pipeline. Inspect an authenticated request’s routing record to confirm a real fallback. curl options · OpenRouter error handling
Decide which settings should carry over to a fallback
If a request uses an allowlist across several models, check that the fallback model has at least one provider on the list. A policy that works for Gemma can leave Gemini without an eligible endpoint. For an evaluation that requires a fixed model, send one explicit ID and record the provider as well. For a service request that needs the extra fallback, evaluate the alternative model’s output independently. Successful generation still leaves questions about content quality, and a response marked stop may need application checks. OpenRouter model fallbacks
- Save the requested model or model list with the returned model, provider, and generation ID.
- Mark cost as unavailable when
usage.costis absent. - If the application needs a fixed output shape, check support for each candidate and validate the returned JSON.