Routing Policies
Save fallback chains, weighted distribution, latency-first routing, or benchmark-AUTO as a policy and invoke it as model:"policy/<slug>".
A routing policy bundles multiple models into one invocation rule — store up to 10 model entries under a single slug, then set "model": "policy/<slug>" in a normal chat call to route by that rule. There are four types: fallback, weighted, latency, and auto. Policies belong to your account and are invoked with your plm_ key.
routing.policies_enabled). Calling a policy/ model while disabled returns a 400 error — saving policies (CRUD) works regardless of the gate.Policy types#
fallback — entries are tried in the order you registered them. Give an entry retries (0–3) to repeat that same entry before moving to the next one. The first successful response is returned as-is.
weighted — requests are distributed proportionally to each entry's weight (1–10000). Pass a trace_id in the request body and the selection becomes deterministic on its hash — the same trace_id always routes to the same model (sticky). If the picked entry fails, the rest are tried in descending weight order.
latency — entries are reordered fastest-first using response times measured over the last hour (the same scorer as the :nitro suffix). With no measurement data, entries are tried in their declared order.
auto (selected_smart) — auto-selects the highest-scoring model for each request intent (category) within your registered pool, based on benchmark scores. With no scores it falls back to declared order. weight/retries are ignored — only the pool matters. See the selected_smart docs for details.
Invoking a policy#
In a normal chat call, set "model": "policy/<slug>". It works with the OpenAI SDK and your plm_ key; the response's model and provider fields show what actually served the request. Billing is based on the model and provider pricing of the entry that succeeded.
curl https://apirouter.pleum.ai/v1/chat/completions \
-H "Authorization: Bearer plm_..." \
-H "Content-Type: application/json" \
-d '{
"model": "policy/prod-chat",
"messages": [
{"role": "user", "content": "Summarize this document."}
]
}'trace_id(max 128 chars) is a routing-only field — it seeds the weighted policy's sticky selection and is never forwarded to the upstream provider. Put a user ID or session ID there to pin the same user or session to the same model.
curl https://apirouter.pleum.ai/v1/chat/completions \
-H "Authorization: Bearer plm_..." \
-H "Content-Type: application/json" \
-d '{
"model": "policy/ab-test",
"trace_id": "user-1234",
"messages": [
{"role": "user", "content": "Hello!"}
]
}'In streaming, only failures before the first token fall back seamlessly to the next entry. Once any token has been sent to the client, a failure ends the stream instead of falling back (to avoid duplicate output). Per-entry retries apply to non-streaming calls only.
Managing policies#
Create policies on the dashboard's Routing Policies page, or via the /v1/routing-policies management API (JWT auth). See the API reference for field details.
policy/…), current routed parents (benchmark_smart, analytics_smart, perfect), and retired parents (pleum-smart, pleum-perfect) cannot be entries. Total attempts per request are hard-capped (6 by default).