Architecture / 7 minute read
How to design a model routing policy
Turn a loose preference for a model into rules a team can explain, evaluate, and change safely.
Start with workload requirements
A routing policy is a decision about where a request should go and under what conditions. It is easy to begin with provider names or a single cost preference. A more durable policy starts with the workload: what the request must do, what kind of data it carries, how quickly the user needs an answer, and what a useful result looks like. Those requirements make the route explainable when a team later changes a model or adds a provider.
Write down the task classes that actually differ. For example, short classification, grounded question answering, and code assistance may have distinct context, output, and evaluation needs. Avoid inventing a large taxonomy before observing real applications. A small set of well-understood classes is easier to maintain than a long list whose labels overlap. For each class, record required capabilities, disallowed data, and a way to measure whether the route still serves the task.
Separate eligibility from preference
First determine which routes are eligible. Data handling restrictions, regional requirements, required modalities, output formats, and provider availability can rule out an option. Apply these constraints before ranking candidates by preference. This order prevents a lower cost or faster route from bypassing a hard requirement. If the request lacks information needed to make a safe decision, return a defined error or ask the caller to supply it; do not silently guess.
Among eligible routes, a policy may express preferences such as capability fit, estimated resource use, observed latency, or operational priority. Keep these as explicit inputs with clear defaults. A weighted score can help compare candidates, but its number should not be mistaken for a guarantee of quality. If a route has a hard threshold, state it separately from a soft preference so operators can tell which condition actually determined the choice.
Define fallback behavior
A fallback is useful only when it remains eligible and can satisfy the task well enough. Decide which failures permit a fallback, how many attempts are allowed, and whether the caller can accept a partial result. Provider timeout, rate limiting, invalid output, and policy rejection are different conditions. Retrying an invalid response against the same route may be wasteful; routing around a policy rejection may be unsafe. Make each case visible in the decision record.
Consider idempotency before repeating any action that changes external state. A model request can often be retried without a direct side effect, but an agent tool call or downstream operation may not be safe to repeat. Use request identifiers and state reconciliation where appropriate. When the system cannot establish whether an action completed, surface the uncertainty for an operator or caller instead of creating a duplicate by default.
Make the choice inspectable
For each decision, record a compact explanation: policy version, task class, eligible candidates, selected route, and the reason a higher-priority option was unavailable. Add timing and normalized result information if it will help operations. Avoid putting prompt text, credentials, or unnecessary personal data into the record. The goal is to explain system behavior, not to create a second copy of every user interaction.
Review policy changes with representative examples. Keep a small evaluation set that covers ordinary requests, boundary cases, and known failure modes. Compare candidate routes against the same set and note what the evaluation cannot assess, such as a tone preference that requires human judgment. Use a limited rollout with a clear rollback path when appropriate, and monitor the workload-specific signals that informed the change.
A policy is a maintained product decision. Assign an owner, review it when workload requirements or provider capabilities change, and retire routes that no longer have an operational purpose.