How to reduce LLM API costs without guessing
A practical checklist for input, output, caching, and model choice.
Measure the token mix first
A model with cheap input can still be expensive when your application generates long answers. Calculate input tokens × input rate + output tokens × output rate, divided by one million. Use a week of representative requests rather than a single prompt.
Choose the smallest model that passes your evaluation
Build a small evaluation set from your real tasks. Check correctness, tool-call reliability, latency, and cost. Use a capable compact model for routine classification or extraction, and reserve heavier reasoning for tasks that benefit from it.
Bound the output
Set an appropriate max_tokens or max_output_tokens. Ask for the format you need and avoid unnecessary explanations in machine-readable workflows. A limit also bounds the budget reserved for a request.
Treat cache discounts as conditional
Cache hits, writes, and retention windows may have different rates. Keep reusable prefixes consistent, measure actual hit rates, and compare the final bill. A published cache-read price is not a promise that every request will hit.
Compare the same thing
Match version, context tier, quantization, service tier, and billing units. Subscriptions and promotional credits are not standard pay-as-you-go prices. Lexelane comparisons retain these conditions and show when a quote is conditional.