Using routing policies
Gateway resolves a routing policy for each request from the request and your organization’s configuration. The recommended way to pick one is its model alias: send @alias/<slug> as model.
How routing policies are applied
The first match wins.
- A concrete
model. Aprovider/modelID or bare model name routes directly, ignoringrouting_policy_idand key bindings. priority_order, an inline priority list.- A model alias.
@alias/<slug>routes through the policy it names. routing_policy_id, in the body or theX-Merge-Routing-Policy-Idheader.- A policy bound to the API key.
POST /v1/embeddingsignores key bindings. - The customer’s default policy, when the request names a customer.
- The project’s default policy, when a project API key,
project_id, or theX-Project-Idheader sets a project. - The organization default policy.
If nothing resolves, Gateway rejects the request because no model or policy applies. Key bindings to deleted, inactive, or differently scoped policies are skipped. When a project policy resolves, its tag rules can select another strategy.
model values
Failover
The same rules cover vendor fallback within a model and model fallback in Priority policies and priority_order: Gateway tries eligible vendors, then the next model. It retries vendor throttles, outages, timeouts, connection failures, and billing errors. Invalid requests stop routing; credential rejections usually do. Some successful-looking 200 responses, such as an empty completion, can fail over too. The collapsed tables below summarize status-code behavior; Errors covers other cases.
Streams fail over only before the first chunk reaches you. If every candidate fails, Gateway returns the last error.
A model that fails 3 times in 60 seconds on one vendor is skipped there until a health probe (every 30 seconds) succeeds. That vendor’s other models keep routing.
Sending a priority list with the request
Send priority_order to set the order per request instead of storing a policy. Entries follow the failover rules. Stored policies are bypassed, but each entry still honors the key’s allowed models, vendor and region restrictions, zero data retention, and provider access; disallowed entries are skipped.
A successful list is saved as a policy scoped to the request’s customer, project, or organization. The same list and scope always get the same ID, returned in routing.policy_id and x-merge-routing-policy-id and reusable as routing_policy_id. Inline policies never become defaults and are listed only with include_inline=true.
Reference
priority_order entries
priority_order can’t be combined with routing_policy_id, a model alias, or top-level vendor or vendors. It works on /v1/responses and every compatible endpoint.
The organization and each project and customer have at most one default policy. Select others by alias or routing_policy_id.