The TL;DR

In rough order of leverage on a typical production LLM workload in 2026:

1. Prompt caching (60–80% cost cut on agent/chat) · 2. Model routing (50–70% cut on mixed workloads) · 3. Batch API for async work (50% cut on offline pipelines) · 4. Output-shape engineering (20–40% cut by trimming tokens) · 5. Semantic caching (30–60% on repetitive workloads, use carefully) · 6. Speculative decoding / streaming (not cost, but TCO via latency) · 7. Fine-tuning a small model (high payoff only above ~100M tokens/month per task).

If you are running LLMs in production in 2026 and your monthly bill keeps surprising your CFO, you are not alone. Almost every team we've seen running real inference at scale has the same problem in the first 6–12 months: the bill grows faster than the user base, the FinOps slack channel gets noisy, and someone proposes "let's just switch to a cheaper model" as if that were a strategy.

It isn't a strategy. Cost optimization is a stack, and "use a cheaper model" is one lever out of seven. Pulled in isolation, it usually trades off measurable quality for marginal cost wins. Pulled in combination with the other six, it's the last lever you reach for, not the first. This guide is the practical, opinionated playbook for engineers actually running LLM inference in production — not a vendor pitch, not a theoretical survey, just the patterns we've seen work across teams in our directory of 118 AI and tech companies.

Why LLM Bills Get Out of Control

Before pulling levers, get clear on where the money actually goes. From cost breakdowns of teams we've worked with, the dominant failure modes are surprisingly consistent:

Failure modeTypical share of waste
Frontier model for every request30–50% — 70% of requests don't need it
No prompt-cache hits20–40% — long system prompts re-billed in full each call
Bloated system prompts & few-shots10–25% — "let me also include 8 examples just in case"
Unbounded retries on failure5–15% — quiet but real, especially with agents
Real-time API for async workloads10–30% — batch would have been 50% cheaper
No output-token discipline10–20% — "respond with explanation" instead of structured output

The point: before optimizing, instrument. You cannot cut what you can't see. Every production LLM workload needs per-request cost telemetry (input tokens, output tokens, cached tokens, model used, route taken, retry count) attributed by user, feature, and route. Most cost surprises are also instrumentation surprises — you find out the chatbot has been falling back to the frontier model for every retry only because somebody finally looked.

5–10x
Typical bill bloat vs. what the workload needs
~10%
Discount on cached input tokens (Anthropic, similar elsewhere)
50%
Discount on batch API tokens vs. real-time

The Seven Levers, In Priority Order

Lever 1 — Biggest Single Win for Most Apps

Prompt caching for stable prefixes

Prompt caching lets the model reuse its internal processing of a stable prefix — system prompt, tool definitions, few-shot examples, retrieved context that doesn't change — across multiple requests. Cached tokens are billed at roughly 10% of standard input rate on Anthropic and similar discounts on other providers. The first-token latency drops 2–4x as a free bonus.

The practical move: identify the stable prefix in your prompts and mark it for caching. For chat apps, this is usually the system prompt plus tool definitions. For agents, it's the system prompt plus the stable scaffolding. For RAG, it's the system prompt — retrieved context is per-request, so it's the bit after the cache marker.

Best for
Agents, chatbots, RAG, anything with a system prompt > 1k tokens
Expected savings
60–80% on input cost; 2–4x faster TTFT
Gotcha
Cache TTL is typically 5 minutes — if traffic is sparse, cache hits drop. Some providers offer "extended TTL" tiers.
Lever 2 — The Single Highest-Leverage Architectural Change

Model routing by request difficulty

The biggest waste in most production LLM systems is using a frontier model for every request when 70–80% of requests are routine. The fix is a router: a small, fast classifier (or a small LLM) that triages requests into "easy" and "hard" buckets, then routes each to the appropriate model tier.

The router itself can be embedding-based (cosine similarity to known easy/hard examples) or LLM-based (a fast Haiku-tier call that returns a difficulty label). The economics work because the router cost is 1–3% of the inference it replaces.

Build the eval first. Sample 200–500 real requests, label them by "did the small model produce a response indistinguishable from the large model?", and use that as your routing oracle. Anything below 95% quality on the routed-to-small bucket means the router is too aggressive — tighten it.

Best for
Mixed-difficulty workloads: chat, search, summarization, classification
Expected savings
50–70% on overall token cost
Gotcha
Without an eval, you'll route requests that needed the frontier model to the small one and degrade quality silently. Always pair routing with measurement.
Lever 3 — Forgotten Free Discount

Batch APIs for anything non-realtime

Major providers offer batch APIs at ~50% discount on input and output tokens with a 24-hour completion SLA. If a workload doesn't need sub-minute latency, it should be on the batch API. Common candidates: nightly enrichment, bulk classification, evaluation runs, document processing, content moderation backlogs, dataset generation for fine-tuning.

The reason teams don't use batch APIs more is organizational, not technical. Real-time and batch are different code paths; engineers default to real-time because it's already wired up. Spending a week to route the obvious offline workloads to batch is a 50% saving on that workload type for as long as the workload exists. There are very few engineering investments with that ROI.

Best for
Async pipelines, bulk processing, eval runs, dataset prep
Expected savings
50% on input + output tokens
Gotcha
Batch has a 24h SLA; not for anything user-facing. Watch for "we'll just push it through batch and wait" creep into product flows.
Lever 4 — The Easiest Win Nobody Names

Output-shape engineering (cut output tokens)

Output tokens cost 3–5x more than input tokens at most providers. Most production prompts treat output length as an afterthought — "respond in JSON" with no schema constraint, or "explain your reasoning" when the user only needs the answer.

Concrete moves: use strict structured output (JSON schema or tool-use), give explicit max-token caps based on what the downstream consumer actually parses, drop "think step by step" from prompts where the steps aren't used downstream, and switch reasoning-style chains-of-thought to summary-only outputs for non-debug paths.

For one team we worked with, switching their classification pipeline from "respond with reasoning and category" to "respond with just the category code" cut output tokens by 90% and dropped overall cost on that path by ~25%. Same quality.

Best for
Classification, extraction, anything with a programmatic consumer
Expected savings
20–40% on output cost
Gotcha
Don't strip reasoning that's actually used for quality. Eval-driven trimming, not blind cuts.
Lever 5 — Powerful but Dangerous

Semantic caching for repetitive workloads

Semantic caching stores full request-response pairs and returns a cached response when a new request is semantically similar (typically via embedding similarity over the prompt or query). Different from prompt caching: semantic cache skips the model call entirely.

Where it works: FAQ-style chatbots, support agents, search re-ranking, anything where the same question gets asked many ways and the correct answer doesn't depend on user context. Hit rates of 30–60% are realistic on those workloads.

Where it breaks: any workload where similar prompts can have different correct answers (personalized recommendations, anything user-context-dependent, anything time-sensitive). Set the similarity threshold high (cosine ≥ 0.95) and treat the cache as a probabilistic optimization with a fallback path — never as a source of truth.

Best for
FAQ chat, support, repetitive Q&A
Expected savings
30–60% on hit-rate-dependent workloads
Gotcha
False-positive cache hits look like silent quality regressions. Always log cache-hit responses for sampling review.
Lever 6 — TCO Lever, Not Direct Cost

Streaming + speculative decoding for latency-cost

Streaming the response doesn't cut token cost, but it dramatically improves perceived latency, which lets you stick with a smaller model that would otherwise feel slow. Speculative decoding (where a draft model proposes tokens and a target model verifies them) is increasingly available from providers and cuts wall-clock time at no quality cost.

These don't show up in your bill directly, but they expand the design space — you can route more workloads to smaller models without users noticing the wall-clock difference. The cost win shows up in Lever 2's column.

Best for
User-facing chat, agents, anything where TTFT matters
Expected savings
Indirect — unlocks aggressive routing
Lever 7 — Only at Scale

Fine-tuning a small model for a narrow task

Fine-tuning a small open-weight or hosted small model on your specific task can match frontier quality at 10–30x lower cost per request. The catch: you only get there after exhausting prompt engineering, model routing, and caching — AND you need enough volume on a single task to amortize the training cost and ops burden.

Rough break-even in 2026: ~100M tokens/month on a single workload type. Below that, prompt engineering + routing + caching wins on TCO. Above it, fine-tuning starts to pay back within 2–3 months. The hidden cost is operational: now you own model versioning, eval drift, prompt-template versioning, and rollback playbooks.

Best for
High-volume narrow tasks: classification, extraction, specific reformatting
Expected savings
10–30x per request, amortized after 2–3 months
Gotcha
You now own the model. Account for ops cost in the breakeven math.

The AI Gateway Pattern (Why You Want One)

By the time you've implemented two or three of these levers, you'll notice the patterns are bleeding across every service that touches the LLM API. Caching code in three places. Routing logic forked twice. Eval coverage uneven. This is the prompt for centralizing on an AI gateway.

An AI gateway is a thin routing layer between your application and the LLM providers. It owns: model selection routing, prompt caching configuration, semantic cache, retries with backoff, fallback chains, per-route observability (latency, cost, quality), and provider abstraction. Application code calls the gateway, which calls the right provider with the right model and cache config.

The cost-relevant win: changes happen in one place. Swap providers, A/B test model routing, roll out a new caching strategy — all without touching application code. Most teams running >$10k/month of LLM spend in 2026 have some form of gateway, either built in-house or via products like the Vercel AI Gateway or similar.

The Evals Question You Can't Skip

Every lever above is gated on the same precondition: can you measure quality before and after?

Cost optimization without an eval is just degradation in slow motion. The team that ships aggressive model routing without an eval will discover six weeks later that their support chatbot is now giving subtly wrong answers, with no way to attribute the change. The team with a 200-example golden set can roll out routing, watch the metric for a week, and confidently keep or revert.

You don't need a sophisticated eval framework. The minimum viable version: 200–500 labeled examples from production, a script that runs them against any prompt/model combination, and a simple metric (exact match, BLEU, LLM-as-judge with a tight rubric). Add to it monthly. For deeper guidance see our LLM evaluation guide and AI agent evaluation guide.

What to Stop Doing

Stop — Picking the cheapest model first

It's the lever with the worst quality-to-savings ratio when used in isolation. Apply caching, routing, and output-shape discipline first. Only then ask: "given the routing rules, what's the right model for each tier?"

Stop — Treating LLM cost as a single number

"We spent $X on LLMs this month" is the wrong unit of analysis. Attribute by route, feature, and user. Most optimization wins come from finding the 3 routes that are 80% of the bill, not from trimming every route by 10%.

Stop — Unbounded agent loops

Agents that retry, re-plan, and re-call tools without a hard step ceiling will silently eat 10x their expected budget when something goes wrong. Every agent path needs a max-step limit, a max-token budget, and an alarm when either fires.

Stop — Engineering for a future model

"This will be cheaper when GPT-7 ships" is not a cost plan. Optimize for the model you're paying for today. Providers consistently ship better models — the savings will come anyway, on top of your work, not instead of it.

The 30-Day Cost Reduction Sprint

If you want to act on this in the next month, here's a sequenced plan.

Week 1 — Instrument

Week 2 — Cache and trim

Week 3 — Eval and route

Week 4 — Stabilize

Done well, a 30-day sprint cuts most production LLM bills 50–75% without measurable quality regression. The compounding part is that the infrastructure you build — eval set, gateway, telemetry — pays dividends on every future change to the system, not just this one.

FAQ

Why are LLM costs so high in production?+
Three failure modes dominate: (1) frontier model for every request when 70% don't need it, (2) duplicate inference because no caching exists, (3) bloated system prompts re-sent without cache hits. Fix those three and most teams cut spend 60–85% without quality loss.
What is prompt caching and how much does it save?+
Prompt caching reuses the model's processing of a stable prefix across requests. Cached input tokens are billed at ~10% of standard rate on Anthropic with similar discounts elsewhere. For agents and chat with long system prompts: typically 60–80% cost cut and 2–4x faster TTFT.
When should I use a smaller model instead of a frontier model?+
Most workloads are power-law distributed: 70–80% routine, 20–30% hard. Run an eval — if a smaller model hits 95%+ of your quality bar on routine requests, route them there. Keep frontier for the hard subset.
What is semantic caching and how is it different from prompt caching?+
Semantic caching stores full request-response pairs and serves cached responses for semantically similar requests, skipping the model call entirely. Prompt caching only reuses the stable prefix. Semantic cache: 30–60% hit rates on FAQ workloads, but introduces quality risk — set similarity threshold high (cosine ≥ 0.95) and log all cache hits for review.
Does batching reduce LLM costs?+
Yes — batch APIs offer 50% discounts vs. real-time with a 24h SLA. Use for any workload not needing sub-minute latency: nightly enrichment, bulk classification, evaluation runs, document processing.
Should I fine-tune to reduce cost?+
Sometimes. Break-even in 2026 is roughly 100M+ tokens/month on a single workload type. Below that, prompt engineering + routing + caching typically wins on TCO. Above it, fine-tuning pays back within 2–3 months.
What is the AI Gateway pattern?+
A routing layer between your application and LLM providers. Centralizes caching, retries, fallback, observability, and model routing — instead of each service rolling its own. Lets you swap providers, A/B test routing, and roll out caching changes without touching app code.

Looking for AI & ML engineering roles?

Browse jobs at companies building production LLM systems — with verified culture profiles, comp data, and engineering blogs to evaluate before applying.

Browse AI/ML Jobs → Explore AI Tools →