QVeris
LLM FINOPS PLAYBOOK

LLM Cost Optimization

Reduce LLM cost by measuring native usage, protecting workload acceptance criteria, and changing one routing, caching, or model lever at a time.

Published: March 20, 2026 · By the QVeris Team

Financial market workflow supporting LLM Cost Optimization LLM 成本优化

TL;DR

Segment workloads

Separate interactive, batch, agent, extraction, coding and multimodal paths.

Set acceptance gates

Define quality, schema, safety, latency and review effort before optimizing.

Optimize biggest drivers

Use measured input, output, retries, cache, tools and agent loops.

Reconcile and repeat

Confirm provider bills, monitor regression and re-evaluate after changes.

Start with a cost tree

Break total cost into workload volume, route mix, input, cached input, output, reasoning, media, tools, retries, failed outputs, human review and platform fees. Add the business denominator—accepted reports, resolved tickets or completed agent tasks—so a high-volume workload is not mistaken for an inefficient one. Rank drivers using reconciled usage and invoice evidence.

Choose the largest controllable driver, not the easiest metric. Repeated static context may justify prompt caching; oversized retrieval may need better chunk selection; verbose outputs may need a stricter schema; simple classifications may fit a lower model tier. Each lever changes a different part of the system and should be evaluated independently.

A cheaper model can increase prompt length, retries or review effort. A shorter prompt can reduce quality, and aggressive caching can serve stale context. Optimize cost per accepted outcome with quality, latency and safety gates, then report uncertainty in estimates rather than celebrating a lower token line before the invoice is reconciled.

Optimization levers

LeverBest fitVerify before choosing
Capability-right modelWorkloads can use smaller or specialized models without failing gates.Golden tasks, version pinning, route policy and fallback semantics.
Prompt and outputRedundant context or unconstrained output is a measured driver.Quality, instruction loss, truncation, structured output and cache effects.
Cache and batchStable prefixes repeat or offline work can wait.Eligibility, TTL, invalidation, privacy, completion window and failures.
Retry and agent loopsRepeated attempts or tool turns consume material usage.One retry owner, budgets, idempotency, termination and tool correctness.

Guardrails for every experiment

Versioned baseline

Freeze prompts, model, route, tools, evaluator and workload sample.

One lever

Change one primary variable so observed savings and regressions are explainable.

Full ledger

Include all attempts, tools, rejected results, review and platform charges.

Rollback trigger

Define quality, safety, latency and error thresholds before launch.

Run the optimization loop

Change one major lever at a time so the result remains attributable. Keep the same workload sample and acceptance criteria for baseline and candidate, and include retries, fallbacks, cache writes, tool calls and human review in both measurements.

  • Measure and reconcile a stable baseline by workload, tenant, route and outcome segment.
  • Choose the largest controllable driver and state one bounded hypothesis with a stop condition.
  • A/B or replay with shared quality, schema, safety and latency gates plus complete cost evidence.
  • Inspect tail cases where savings create more retries, invalid outputs or reviewer effort.
  • Canary, monitor regression, publish assumptions and schedule re-evaluation after price or workload changes.

Make optimization a closed control loop

Operational telemetry flows into an append-only native usage ledger with route, model version, attempts, billable dimensions and outcome tags. A workload registry supplies representative evaluation sets and acceptance gates. The optimizer proposes a versioned routing, prompt, retrieval or caching change rather than mutating production behavior directly.

An evaluation runner measures accepted outcomes and complete estimated cost; a canary enforces promotion and rollback thresholds in live traffic. Provider exports and invoice reconciliation later replace or adjust estimates with financial evidence. Feed those deltas back into the next baseline so optimization does not rely forever on stale token assumptions.

Production rule: never claim savings until the same workload passes the same acceptance gate and reconciled evidence supports the result.

Optimize model and capability spend independently

QVeris external API, tool, service and live-data calls can have cost drivers measured in requests, records, data packages, compute or subscriptions rather than tokens. Preserve native units, price versions, freshness and quality outcomes in a capability ledger. A cheaper data source is not a saving if it returns stale or incomplete evidence that causes the agent to fail.

Optimize model inference and capability access separately, then join them at the workflow acceptance gate. Test whether a model retry can reuse an already verified tool result, whether retrieval can request fewer fields and whether live data needs a shorter freshness window only for certain decisions. Report the total accepted-workflow cost without collapsing unlike units into a fabricated token figure.

Optimize accepted cost, not token price alone

A cheaper model can increase retries, tool calls, review time, or failed tasks. Compare routes with the same workload set and calculate cost per accepted result after the quality gate, including all attempts and external tools.

Accepted-cost worksheet
accepted_cost = (
    model_input_cost
    + model_output_cost
    + cache_write_cost
    + gateway_fee
    + tool_cost
    + retry_cost
    + human_review_cost
) / accepted_results

compare_by = [
    "workload", "route", "exact_model", "prompt_version",
    "quality_gate", "latency_slo", "region", "price_version"
]

# Never average unrelated workloads into one global model score.
  • Start with high-volume workloads that already have an objective quality check.
  • Test prompt reduction, output caps, caching, batch, routing, and model changes one at a time.
  • Promote only when accepted cost improves without breaking latency, safety, or reliability gates.

Verified implementation reference: OpenTelemetry GenAI conventions.

FAQ

What should I optimize first?

The largest reconciled driver with a safe, measurable and reversible lever.

Is a smaller model always cheaper?

No. It may require more context, retries, review or fallback attempts.

How do I avoid quality loss?

Define gates before the experiment and keep evaluator versions fixed.

Official sources and further reading