Skip to main content

What a routing policy is

A routing policy is a named set of routing decisions that virtual keys point at. Edit the policy and every key that uses it follows the change; no key is reissued. A policy holds: Manage policies under AI Gateway, Routing Policies in the sidebar (/gateway/routing-policies). The page groups policies by scope: organization, teams, projects. A project policy wins over a team policy, which wins over the organization policy. Creating, editing and deleting need the routingPolicies:manage permission; viewing needs routingPolicies:view.
The Routing Policies page with the Organization, Teams and Projects groups

The Routing Policies page: an organization policy marked as the default and a project policy.

The New routing policy drawer with the name, scope, ordered providers and model tiers

The policy drawer: where it applies, the providers in order, and the three model tiers.

Model tiers

A tier is a reserved model name a client sends instead of naming a model. Point each tier at a model on one of the policy’s providers. A tier the policy names no target for resolves to the policy’s Default model. A policy with no default model leaves that tier unset, and a request for it is refused as an unknown model.
The response reports the model that served the request in model, and extra_fields.model_requested holds the model the tier resolved to. GET /v1/models on the key lists each tier that resolves to a model, with owned_by set to the provider the tier points at, next to the models of the policy’s providers. A tier with no target and no default model is not listed. Model ids in that list carry no provider prefix. Tiers and name mappings are the same mechanism on the wire: an alias the gateway looks up by exact name. See Model aliases.

Model name mapping

A mapping rewrites one requested name to one served name, for example gpt-4o to openai/gpt-5-mini. The served name must be reachable through one of the policy’s providers; the editor refuses a mapping that names a provider the policy does not route through. The key’s own model allowlist is checked against the served model, so a mapping cannot reach a model the key is not allowed to use.

Provider order

The providers list is the key’s fallback chain. The gateway keeps only the providers that can serve the requested model, then tries them in the listed order. A request for a model on a provider the policy does not include is refused with 400 model_not_allowed, and the message names the policy:
The key’s own provider access can still list that provider; the policy is what refuses it. A provider that the key’s provider access drops answers 400 model_not_allowed too, with a message that points at the key’s allowed providers instead of the policy. The code is the same for both; the message is what tells them apart. A policy rule under Restrictions is a different refusal. A model a rule blocks, or a model outside an allow-only list, answers 403 policy_violation, and the message names the model, not the policy:
See Fallback chains for what triggers the move to the next provider.

Attach a policy to a key

1

Create the policy

Click New policy, pick where it applies, add the providers in the order you want, set the tiers and the default model.
2

Point the key at it

Open the key under AI Gateway, Virtual Keys and click Edit. The Routing section is a list of choices: Default: no fallback, Fall back to all eligible providers, then one row per policy the key can reach. Pick the policy and save. The first two choices are the key’s own routing when it uses no policy.
The Edit virtual key drawer showing Provider access and the Routing choices

The Routing section of the edit drawer, with the organization policy selected.

3

Verify

Send a request for fast through the key and read model in the response. Then request a model on a provider that the key’s Provider access still lists but that the policy does not, and check for 400 and "code": "model_not_allowed"; the message names the routing policy, which is what tells you the policy refused it rather than the key. To test a Restrictions rule instead, send a request that matches one and check for 403 and "code": "policy_violation".
Make this the default where it applies marks the policy as the default for its scopes; the policies list shows it with a Default badge.

Propagation

Saving a policy writes a change event. The gateway picks it up on its next change-feed poll and rebuilds the bundles of every key on the policy. Requests already in flight finish on the old configuration. Also check: Policy rules, Model aliases, Fallback chains, Virtual keys.
Last modified on October 12, 2026