r/devops • u/impassionedultimatum • 8h 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?
2
u/TellersTech DevOps Speaker & Advisor + DevOps Podcaster 8h 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 😅
2
u/happysmileygogetter 8h 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.
4
u/mralex215 8h ago
middlemen only increase costs.
2
u/Dobsen_Runjie 8h 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 8h 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.
1
u/JustXanderOne 7h 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 1h 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.