If you've shipped an LLM-powered feature, you've probably had the moment where the bill arrives and it's 3x what you modeled. This isn't a "which model is cheapest" post it's a rundown of the concrete techniques that actually reduce spend once you're past the prototype stage.
1. Cache aggressively, but cache the right layer
Most people cache final responses and call it done. The bigger win is caching at the prompt-prefix level - if your system prompt and few-shot examples are static across requests, prompt caching (supported by most major providers now) can cut input token costs by 80-90% on repeated context. This matters most for RAG pipelines where the retrieved context changes but the instructions don't.
2. Right-size the model per task, not per app
A common mistake: picking one "good enough" model and routing everything through it. In practice, tasks vary wildly in difficulty. Classification, extraction, and formatting tasks often run fine on a smaller/cheaper model, while reasoning-heavy tasks need the frontier model. Route by task type, not by feature. A simple heuristic try the cheap model first, escalate on low-confidence output — often cuts costs 40-60% with no perceptible quality drop.
3. Trim your context, don't just trust "big context windows"
Bigger context windows tempt you to dump everything in. But cost scales linearly with tokens, and quality often degrades with irrelevant context (the "needle in a haystack" problem is real). Before increasing context size, ask if better retrieval or summarization would let you send less. Precomputed summaries of long documents are usually cheaper than re-sending the raw document every call.
4. Batch what doesn't need to be real-time
If a workflow doesn't require an immediate response — nightly report generation, bulk classification, embedding backfills batch APIs typically run 50% cheaper than synchronous calls. It's an easy win that's often left on the table because batching wasn't part of the original design.
5. Set hard ceilings, not just budget alerts
Alerts tell you after you've overspent. For anything with unbounded usage (user-triggered agent loops, retries), set actual limits: max tokens per request, max retries per session, and a circuit breaker if a single user session exceeds some threshold. This has saved more than one team from a runaway agent loop eating a week's budget in an afternoon.
6. Re-benchmark quarterly
Pricing and model quality shift fast enough that a cost-optimal setup from six months ago is often no longer optimal. What was the frontier model in Q1 may now have a cheaper, comparable-quality alternative. This is worth a recurring calendar reminder, not a one-time decision.
None of this requires exotic infrastructure mostly it's discipline about measuring cost per task rather than cost per app. When I was mapping out which providers and tools fit into a setup like this, I ended up browsing through a categorized listing on futorax.com, which was a decent way to see what's out there for caching layers, routing, and observability without digging through ten separate "best of" blog posts.
Curious what's worked for others — especially around routing strategies, since that's where I've seen the most disagreement.
Top comments (0)