Engineering Levers: Cut the Unit Cost of Every Call
Six engineering levers cut the unit price of tokens you are already committed to spending: prompt caching,
batch processing, model routing, context management, semantic caching, and output control. Individually each
saves 20–90% on its slice of the bill; stacked, teams routinely report 70–90% total reductions
without changing what the AI delivers.
| Tactic |
Published saving |
Key condition |
Source |
| Prompt caching (Anthropic) |
90% off cached reads; writes cost 1.25x (5-min TTL) |
Stable prompt prefix; ~1.4 reads per write to break even |
Source |
| Prompt caching (OpenAI) |
50% off cached tokens, automatic |
Prompts >1,024 tokens; reuse within ~5–10 min |
Source |
| Prompt caching (Google Gemini) |
90% off on Gemini 2.5+ (implicit) |
Storage fee applies to explicit caches |
Source |
| Batch API (all three providers) |
Flat 50% off input and output |
Up-to-24-hour turnaround acceptable |
Source |
| Model routing (RouteLLM, ICLR 2025) |
75–85% cost cut at 95% of frontier quality |
Router trained on preference data |
Source |
| Cascading (FrugalGPT) |
Up to 98% in benchmark settings |
Cascade tuned per query type |
Source |
| Semantic caching |
20–45% typical production; 73% named case; 86% AWS study |
High query repetition; tuned similarity threshold |
Source |
| Structured outputs |
Failure/retry rate 8–15% → <0.1% |
Schema-enforced generation |
Source |
| On-demand tool loading |
85–98.7% reduction in tool-definition overhead |
Agentic workloads with large tool catalogs |
Source |
| Prompt compression (LLMLingua) |
Up to 20x compression, ~1.5% quality loss |
Long prompts; small-LM compressor in pipeline |
Source |
Prompt Caching (50–90% Off Repeated Context)
Prompt caching stores the stable prefix of your prompts — system instructions, tool definitions,
shared reference documents — so repeat calls are billed at a deep discount. Anthropic bills cached
reads at 10% of the standard input rate; OpenAI applies an automatic 50% discount on prompts over 1,024
tokens; Gemini 2.5+ models discount cached input 90% (sources in table above). One independent cross-provider
study measured real API cost reductions of 41–80% from caching alone, alongside 13–31% faster
time-to-first-token (Source: PwC study, via Sthambh).
Two practical notes. First, structure prompts so everything static comes before anything dynamic —
cache hits require an identical prefix. Production teams that restructure this way report 74–84% hit
rates on stable agent
workloads (Source: Agentbrisk prompt caching deep dive).
Second, mind the write cost on Anthropic: cache writes bill at 1.25x input, so caching only pays above
roughly 1.4 reads per write.
Batch Processing (Flat 50% Off, Stacks With Caching)
Every major provider — OpenAI, Anthropic, Google — offers a flat 50% discount on asynchronous
batch processing in exchange for an up-to-24-hour
turnaround (Source: CodeWords, Anthropic Batch API guide).
Classification runs, embeddings, evaluations, summarization backlogs, nightly report generation: most
organizations have large workloads with no real-time requirement that are quietly paying full price.
The discounts stack. Cached reads processed through a batch job can push effective savings past 95% on
eligible workloads (Source: Anthropic combined-discount framing, via Dotzlaw).
If you remember one tactical pairing from this guide, make it caching-plus-batch.
Model Routing and Cascading (Right-Size Every Request)
Routing sends each request to the cheapest model that can handle it, escalating to frontier models only when
needed. The UC Berkeley RouteLLM system maintained 95% of GPT-4 quality while sending only 14–26% of
queries to the expensive model — a 75–85% cost reduction on routed
traffic (Source: RouteLLM, ICLR 2025).
RouterBench found 52.8% of prompts are optimally handled by models under 20B
parameters (Source: TianPan.co routing analysis).
In production terms, Amazon Bedrock’s intelligent prompt routing reports roughly 30–60% savings,
and enterprises using tiered routing typically cut costs 60–80% without user-experience
impact (Source: Sphere Partners).
This is already mainstream practice: 37% of enterprises run five or more models in production, tuned to use
case, risk, and
cost (Source: Swfte, consistent with Menlo Ventures’ market data).
Defaulting every request to the most capable model is the single fastest way to burn budget 10–100x
faster than necessary.
Context-Window Management
Unmanaged context is structural overhead you pay on every turn. An agent with a 4,000-token system prompt
re-sent across 20 turns spends 80,000 tokens on repetition
alone (Source: Waxell, AI agent context cost analysis).
The fixes escalate in sophistication: sliding-window truncation, rolling summarization of older turns, and
anchored session-state summaries that preserve decisions while discarding transcript bulk.
The biggest published wins come from loading context on demand instead of preloading everything.
Anthropic’s engineering team cut tool-definition overhead 85% with on-demand tool search — and
accuracy improved (Opus 4: 49% → 74% on the affected workloads); their code-execution approach
to tool use cut context from ~150,000 tokens to ~2,000, a 98.7%
reduction (Source: Anthropic, Advanced tool use).
Leaner context is not a quality sacrifice; long-context research shows model quality degrades as
irrelevant context accumulates.
Semantic Caching (With Honest Production Numbers)
Semantic caching returns a stored answer when a new query means the same thing as a previous one, skipping
the LLM call entirely. Honest expectations matter here: real production hit rates typically run
20–45%, not the 90%+ that appears in marketing material — vendor figures often describe match
accuracy, not hit
frequency (Source: production data analysis).
Even so, a 30% hit rate on a $5,000/month bill saves ~$1,500/month with cache overhead under 5% of the
savings.
The best cases are genuinely strong: one production deployment cut its LLM API bill from $47,000 to $12,700
per month (-73%) at a 67% hit rate with a 0.8% false-positive
rate (Source: VentureBeat),
and AWS research on 63,796 real chatbot queries measured 86% cost reduction at optimal similarity thresholds.
High-repetition workloads — support, FAQ, internal search — are where this lever belongs.
Output-Length Control and Structured Outputs
Output tokens cost 3–8x more than input tokens across all major providers, because generation requires
a full forward pass per
token (Source: Burnwise token optimization guide).
That asymmetry makes output control disproportionately valuable: set max_tokens ceilings by task
type, instruct brevity explicitly, and constrain output to schemas. One worked example: a team at 1M
requests/month cut a $15,000 monthly bill to ~$3,600 (-76%) purely by stacking output caps, brevity
prompting, and structured output — no model
change (Source: TokenCost).
Structured outputs also eliminate a silent retry tax. Unschemaed JSON generation fails parsing 8–15%
of the time, and every failed generation roughly doubles that call’s cost; schema-enforced output
drops failure below 0.1% for 30–300 overhead
tokens (Source: TokenMix, citing OpenAI’s published data).
To compare how these unit costs play out across providers for your specific workload mix, use the
cloud AI token cost comparator.