r/devops • u/impassionedultimatum • 4d ago
Discussion How do you determine whether your LLM routing layer is reducing costs once retries and failed outputs are factored in?
Routing requests to cheaper models sounds straightforward until you start accounting for what happens when the output isn't usable. Take a data extraction pipeline for example where a smaller model handles most requests fine but occasionally returns malformed JSON or misses required fields (those requests need to be retried and in some cases passed to a more expensive model anyway) which is why this is something I'd want to benchmark with a cost/quality based routing solution like Ramp Router because the initial routing decision might save money while the cumulative cost of getting a usable response tells me something else.
Would it make more sense to measure the cost per successfully validated output against a fixed model baseline rather than looking at average inference cost?
I also wanna understand how people are handling this on the observability side so like are you grouping all inference attempts under a single trace ID and attributing the cumulative cost to the original request? How are you factoring the additional latency into your benchmarks?
4
u/TellersTech DevOps Speaker & Advisor + DevOps Podcaster 4d ago
Yeah… I’d look at cost per successful request, including all the retries and fallbacks. I’d keep everything under the same trace ID and compare the total cost, success rate and latency against just using the better model from the start
You might find that the cheaper model isn’t actually saving you much 😅
3
u/happysmileygogetter 4d ago
Compare cost per successful request, not cost per call. Log every attempt with a request id that stays the same across retries, then for each request sum the tokens across all attempts, including the ones that came back as malformed JSON and any repair or fallback calls.
Then pin a slice of traffic (even 5-10%) to your single default model as a control and compare total cost per completed request, retry rate, parse failure rate and p95 latency. Routers often look cheaper per call while the cheap model's retries and fallbacks to the big model eat the savings, and you only see it once retries are attributed back to the original request.
If you can, track a quality signal on both arms too (user corrections, downstream validation failures). Otherwise you can save money by quietly getting worse.
5
u/mralex215 4d ago
middlemen only increase costs.
2
u/Dobsen_Runjie 4d ago
cost per valid response is the right way to look at it. One thing to watch out for is that retries also burn through your rate limits faster, which doesnt show up on the billing dashboard but can still bottleneck the pipeline
2
u/FUSe 4d ago
Maybe don’t have your model writing json directly. Make a tool call (local function/template) that generates the json and your model calls that tool with just the inputs.
2
u/JustXanderOne 4d ago
Measuring average cost per inference call is definitely a trap when smaller models trigger retries or produce subtly broken outputs. The metric that worked best for us is **cost per deterministically verified outcome**: grouping all attempts (including fallback escalations to a larger model) under a single `execution_id`, validating the output with a strict schema/linter gate before accepting it, and dividing total token spend across the whole retry chain by the number of outputs that actually passed the gate.
1
u/Neat_Basket8230 4d ago
The rate-limit hit was the one that caught me out — it never showed on the bill, but retries burned through the quota and the pipeline stalled while the cost dashboard looked fine. I ended up tracking cost per validated output, retries included, and the cheap model stopped looking cheap once the fallbacks were counted. Latency went in the same bucket, or the router kept winning on paper and losing in practice.
1
u/Valuable_Leave_7314 3d ago
Kinda weird to see "Ramp Router" mentioned here but if we're being practical - before buying any router it's easier to hack together a simple config with a fallback and run 5-10% of real prod traffic through it for a week and look at the actual bill instead of synthetic stuff
1
u/Muted_Jellyfish_6784 2d ago
Measure cost per successful output, not cost per request. Log every attempt with the request ID, model, tokens, validation result, and whether it escalated, then divide total spend by outputs that passed schema validation. Compare against a week of sending everything to the expensive model. Track latency too, since retries can cost more there than in dollars.
The habit that matters is keeping the whole retry chain under one request ID. I use a decision intelligence tool to join routing logs, validation failures, and the downstream records the pipeline produced, so you see the true cost of a usable result rather than the cheap first attempt
0
u/chocopudding17 4d ago
LLM bot