Skip to navigation

Routing policies

Decide how a customer's requests pick a model

A customer routing policy picks the model when the customer’s request doesn’t pin one. PRIORITY is a ranked list that falls back to the next model on failure; INTELLIGENT lets Gateway choose per request from an allowed set, optimizing for COST, PERFORMANCE, or CAPABILITY.

Create a policy

POST /v1/customers/{customer_id}/routing-policies. The customer’s first policy becomes its default.

curl -X POST https://api-gateway.merge.dev/v1/customers/{customer_id}/routing-policies \
-H "Authorization: Bearer $MERGE_GATEWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "workflow-a",
"strategy": "PRIORITY",
"priority_order": [
{ "model": "openai/gpt-5.5", "priority": 1 },
{ "model": "anthropic/claude-opus-4-8", "priority": 2 }
]
}'

Naming a model the customer’s controls and key usage mode don’t allow returns 400, so check the customer’s allowed models first.

Change the default

Send is_default: true on create or PATCH, or call PUT /v1/customers/{customer_id}/default-routing-policy with {"routing_policy_id": "..."}. Deleting the default leaves the customer with none, so its requests fall back to your organization’s default policy.

GET, PATCH, and DELETE on /v1/customers/{customer_id}/routing-policies/{policy_id} manage a single policy.

Reference

FieldTypeDescription
idUUIDPass as routing_policy_id to select this policy on a request
name, descriptionstringLabel and optional description
strategyenumPRIORITY or INTELLIGENT. Custom strategies and tag rules aren’t supported on customer policies.
is_defaultbooleanUsed when a request names no policy
priority_orderlist of {model, priority}PRIORITY only. Models are tried in order.
allowed_modelslistRequired for INTELLIGENT. The set Gateway chooses from.
allowed_providerslistINTELLIGENT only. Derived from allowed_models. If you send it, it must match their providers.
axisenumINTELLIGENT only: COST (default), PERFORMANCE, or CAPABILITY
created_at, modified_atdatetimeTimestamps

Fields for the other strategy come back null; sending them, or duplicate models in a list, returns 422.

Next steps