← Back

How to Test an LLM Router Before Production

Table of Contents

Retries and escalations can erase an LLM router’s savings. Before sending customer traffic through a new policy, measure how many requests produce an acceptable result and what you pay for each of those results.

Build a test set around the work you actually do

Take approved or de-identified examples from a few distinct workloads, such as extracting fields from invoices, answering help-center questions, and drafting support replies. Give each workload a pass condition. Invoice extraction can use exact field checks. A help-center answer should cite the passage that supports the answer. A support draft should follow the team’s escalation rules.

Reserve a set of requests for the final comparison before you tune the policy. Include empty fields, long inputs, and requests that should go directly to a stronger model. Use the same inputs, tools, and grading rules for the current route and the candidate.

Count the cost of the entire request

For each request, record the route chosen, the model that returned the answer, input and output usage, cache activity when available, latency, and whether the result passed. Attribute retries, fallback calls, and model-based scoring to the request that triggered them. Capture these details in traces without copying raw customer prompts into routine logs. OpenTelemetry’s generative AI conventions

Report the pass rate and total cost divided by the number of passing results. In an illustrative 100-request run, a baseline that costs $8.80 and passes 88 requests costs $0.10 per passing result. A candidate that spends $8.40 and passes 80 requests costs $0.105 per passing result. The smaller bill comes with eight fewer usable answers and a 5% increase in cost per passing result.

Test fallback and cache behavior separately

Exercise provider timeouts and rate limits in staging. Check which route the request takes, the time it spends waiting, and where the policy stops retrying. Test a normal multi-turn session twice, once with the policy keeping the same route and once with a switch. Longer prompts can make a cache miss or cache write matter more than the difference in model prices.

Roll out one workload at a time

Choose a workload that cleared its pass threshold and route a small portion of its traffic through the candidate while keeping a baseline group. Set the conditions for rollback before starting. Compare acceptance, tail latency, fallback frequency, and cost per passing result for both groups. Expand the policy when the comparison meets the limits you set. Google’s SRE Workbook on canarying releases

Read the original Ailoot guide for more on prompt caching and production routing decisions. How to Evaluate an LLM Router for Production