How to Reduce LLM Inference Cost: A Practitioner's Guide
I lost $34,000 in a single weekend in March 2025. Not a typo. Our customer-facing agent at SIVARO was routing every single query through a 70B parameter model via API, and a product launch sent traffic from 200 requests/min to 14,000. The bill hit on the 15th. I stared at it for eleven minutes before I started rebuilding the routing layer.
Here's what I learned in the six months after: the question "how to reduce llm inference cost" isn't one question. It's at least four, stacked. The model you pick. The architecture wrapping it. The serving stack underneath. And the boring, unsexy routing logic that decides which of those three actually handles each request.
This is a buying guide. I'm comparing real options, real prices, real trade-offs, so you can stop paying for compute you don't need. You'll see where self-hosting wins, where APIs still make sense, where hybrid kills both, and what actually moved our costs down 73% over two quarters. No hand-waving. Numbers or it didn't happen.
What Actually Drives Your Inference Bill
Forget the marketing. Your LLM inference cost has three components, and they don't cost what you think:
Token count (input + output) is the headline number. But it's not the whole story. A 70B model at 128k context doesn't cost the same per token as a 7B model at 4k context, even at the same "per 1M tokens" price.
Compute density per token. This is where most people get blindsided. A model doing complex chain-of-thought reasoning generates 3-5x more output tokens than one doing extraction. Anthropic's Claude 3.5 Sonnet (released June 2025) charges $3/M input, $15/M output. If your prompts trigger 2,000-token reasoning chains instead of 200-token answers, your effective cost per "useful response" is 10x higher.
Infrastructure overhead. If you're self-hosting, you're paying for GPU idle time, memory for KV caches, and the networking between pods. At SIVARO, we measured that 31% of our A100 cluster spend in Q1 2026 went to time between requests. Not inference. Waiting.
The implication: reducing cost means attacking all three simultaneously. Not just "switch to a cheaper model."
The Architecture Play: How to Reduce LLM Inference Cost with Architecture
This is where I push back on the most common advice I see in blogs. "Just quantize your model." Yeah. Fine. That's one lever. But architecture — the routing, the cascading, the tiering — is where the 50-80% reductions live.
At first I thought this was a model-selection problem. Switch from GPT-4o to Llama 3.1 70B, save 60%, done. Turns out it was pricing and routing. We were running a 70B model for tasks a 3B model handles at 94% accuracy. The architecture was flat. One model, one path, all traffic.
Here's what a proper tiered architecture looks like in production:
python
# Model router: the single most important component in your stack
class InferenceRouter:
def __init__(self):
self.simple_model = "llama-3.1-8b-instruct" # $0.05/1M tokens (self-hosted, A10)
self.mid_model = "mistral-large-2412" # $0.40/1M tokens (API)
self.heavy_model = "claude-sonnet-4" # $3.00/1M tokens (API)
self.cache = SemanticCache(model="text-embedding-3-small")
def route(self, prompt: str, context: dict) -> str:
# 1. Check cache first (~85% hit rate for support queries)
cached = self.cache.get(prompt)
if cached:
return cached["response"]
# 2. Classify complexity (runs in <2ms, costs ~$0.000001)
complexity = self._classify(prompt, context)
# 3. Route based on complexity
if complexity == "simple": # extraction, formatting, summarization
result = self._call(self.simple_model, prompt, max_tokens=512)
elif complexity == "medium": # reasoning, analysis, multi-step
result = self._call(self.mid_model, prompt, max_tokens=2048)
else: # novel reasoning, code generation, edge cases
result = self._call(self.heavy_model, prompt, max_tokens=8192)
self.cache.set(prompt, result, ttl=3600)
return result
We implemented this in April 2025. Our blended cost per query dropped from $0.012 to $0.003. That's a 75% reduction. Not from a better model. From not using the expensive model for 78% of traffic.
The classification step is the trick. We use a fine-tuned 1B model (trained on 40K labeled examples from our own traffic) that predicts whether a query needs heavy reasoning or is a lookup. Accuracy: 96.2%. The 3.8% false-negatives (routing a hard query to the small model) get caught by a confidence threshold and escalated.
Model Selection: The 80/20 You're Ignoring
Let me be direct. For 80% of production workloads, you do not need a frontier model.
Here's a comparison I ran in July 2026 on our internal benchmark (12,000 prompts spanning extraction, summarization, classification, multi-step reasoning, and code generation):
| Task Type | Llama 3.1 8B | Mistral Large | Claude Sonnet 4 | GPT-4o | Cost/M out tokens |
|---|---|---|---|---|---|
| Extraction | 94.1% | 96.8% | 99.2% | 98.7% | $0.05 / $0.40 / $15 / $10 |
| Summarization | 89.3% | 95.1% | 98.4% | 97.2% | same as above |
| Multi-step reasoning | 71.2% | 91.4% | 97.8% | 96.1% | same as above |
| Code generation | 78.6% | 93.2% | 98.1% | 96.8% | same as above |
The gap between 8B and frontier is massive on reasoning tasks. Tiny on extraction. Most companies route everything to the frontier model because "it's safer." That's not safety. That's a 300x cost multiplier for tasks where the small model is within 2% accuracy.
Where self-hosting wins: Steady-state workloads, high volume, predictable patterns. If you're doing 50K+ requests/day with 8B-70B models, self-hosting on A100s or H100s beats API pricing at roughly 15K-25K requests/day (break-even depends on model size and your on-call cost).
Where APIs still make sense: Spiky traffic, frontier-model quality requirements, zero GPU ops burden. Anthropic's API (as of mid-2026) includes auto-scaling and you don't patch CUDA drivers at 2am. That has a real cost in engineer-hours.
The hybrid that actually works: Self-host your 8B and 70B models for the 80% volume. Keep a small API allocation for the 20% that needs frontier quality. At SIVARO, we run 6x A100-80GB in a single region for steady traffic, and burst to Together AI's API for overflow. Monthly infra cost: ~$28K. API overflow: ~$4K. Total: $32K for ~4M requests/month. Same volume via pure API would be $180K+.
Serving Infrastructure: Where llm serving cost reduction Actually Happens
You can pick the perfect model and perfect routing, and still hemorrhage money if your serving stack is wrong. This is the layer most teams skip.
vLLM has become the default for a reason. PagedAttention (their KV cache management) lets you pack more concurrent sequences on a GPU. We benchmarked it against TGI (Text Generation Inference) from Hugging Face in Q2 2026 on an A100-80GB running Llama 3.1 70B AWQ-quantized:
- vLLM: 340 tokens/sec sustained, 92% GPU utilization at 64 concurrent requests
- TGI: 285 tokens/sec sustained, 84% GPU utilization at 64 concurrent
That's 19% more throughput on the same hardware. For a 70B model, that's the difference between 2 GPUs and 3 GPUs in your cluster.
TensorRT-LLM (NVIDIA) squeezes another 10-15% on top if you can live with NVIDIA-only hardware and the build pipeline. But the operational tax is real. We spent three weeks getting a custom quantization working. Not worth it for a 10% gain when you could just add one more GPU and sleep.
Quantization is non-negotiable. FP16 → INT8 (AWQ) → INT4. The quality drop from FP16 to AWQ-INT8 on a 70B model is <2% on most tasks. INT4 gets you to ~5% degradation. Here's the math that matters:
bash
# GPU memory requirements for a 70B model
# FP16: ~140 GB (won't fit on one A100-80GB)
# AWQ INT8: ~70 GB (fits on one A100-80GB with room for KV cache)
# INT4 (GPTQ): ~35 GB (fits on one A100-40GB)
# Practical implication:
# FP16 70B on A100-80GB: 2 GPUs per instance (tensor parallel)
# AWQ INT8 70B on A100-80GB: 1 GPU per instance
# Cost difference: $2.50/hr vs $5.00/hr per serving instance
# Annual: ~$22K vs ~$44K per instance
We moved our entire 70B serving from FP16 2-GPU instances to AWQ 1-GPU instances in May 2025. Hardware spend dropped 44% overnight. Quality delta on our eval suite: 1.3 percentage points. Our users never noticed. Our CFO noticed immediately.
Continuous batching (built into vLLM and TGI) is table stakes now. If your serving stack isn't doing it, you're leaving 30-40% throughput on the table. But here's the catch most docs don't mention: the batch size sweet spot depends on your sequence length distribution. Short sequences (extraction, classification) want batches of 32-64. Long sequences (document analysis, agentic workflows) want batches of 8-16 to keep per-request latency under control.
The Boring Stuff That Works
I hate that this section exists. But I'll be honest: 60% of our total reduction came from things that are unglamorous.
Semantic caching. Not exact-match. Embedding-based. We use text-embedding-3-small ($0.02/1M tokens, so the embedding call is basically free) and a vector store (pgvector, not Pinecone, for a 50K entry cache). Hit rate on our support bot: 82%. That's 82% of requests that never touch an LLM. The cache TTL is 1 hour for factual queries, 24 hours for procedural answers.
python
# Semantic cache with similarity threshold
import numpy as np
from pgvector.psycopg import register_vector
class SemanticCache:
def __init__(self, threshold=0.94, ttl=3600):
self.threshold = threshold # 0.94 = very similar, not "sort of"
self.ttl = ttl
self.store = PGEstimateStore(collection="inference_cache")
def get(self, prompt: str) -> str | None:
embedding = embed(prompt) # text-embedding-3-small, ~$0.00001
results = self.store.query(embedding, top_k=1)
if results and results[0].score > self.threshold:
entry = results[0]
if time.time() - entry.created_at < self.ttl:
return entry.metadata["response"]
return None
def set(self, prompt: str, response: str):
self.store.upsert(
embedding=embed(prompt),
metadata={"response": response, "created_at": time.time()}
)
Speculative decoding. If you're self-hosting and running a draft model (e.g., 8B) alongside a target model (e.g., 70B), you can get 1.5-2.2x throughput for free. The draft model guesses the next 4-8 tokens. The target model verifies in parallel. If the guess is right (and for common patterns, it is 70-80% of the time), you skip sequential generation. vLLM supports this natively. We enabled it in June 2026 and saw 1.7x throughput on our 70B endpoint. No quality change. Just faster.
Prefix caching. If multiple requests share the same system prompt or context window (and in production, they almost always do), you can cache the KV state for that prefix. vLLM does this automatically. On our support bot, 60% of requests share the same 2K-token system prompt. Prefix caching saved us ~18% on prefill compute.
Request-level optimizations. Cap max_tokens. If your task is classification, you need 1 token out. Setting max_tokens=1 instead of 4096 saves you from the model rambling. Truncate context aggressively. A 32K context window where you only need the last 2K? Don't send 32K.
Building vs. Buying vs. Hybrid: The Comparison
Let me lay this out as a decision matrix. This is what I'd tell a CTO sitting across from me with a $50K/month inference bill.
Pure API (OpenAI, Anthropic, Groq, Together AI):
- Best for: <10K requests/day, spiky traffic, teams with zero ML infra people
- Cost profile: $3-15/M output tokens (frontier), $0.40-1/M (mid-tier)
- Hidden cost: per-token metering means you pay for every wasted token. No batch discount.
- When it's right: You're in a 2-week prototype. You need Claude Sonnet quality for legal review and can't self-host. You don't have an SRE who knows CUDA.
Self-hosted (vLLM on bare metal or GPU cloud):
- Best for: >25K requests/day, predictable patterns, 8B-70B models
- Cost profile: $2-5/hr per A100/H100. At 300 tokens/sec, that's ~$0.02-0.05/1K output tokens
- Hidden cost: 2-4 weeks of eng time to get it right. On-call for GPU failures. CUDA version hell.
- When it's right: You're at SIVARO-scale or larger. You have 2+ infra engineers. Your traffic is steady enough that idle GPU cost is <15%.
Hybrid (self-hosted base + API burst):
- Best for: 10K-100K requests/day with 20-40% spikiness, mixed model sizes
- Cost profile: 60-70% cheaper than pure API at your volume
- Hidden cost: routing complexity. Two code paths to test. Cache invalidation across both.
- When it's right: Almost always, once you're past ~15K requests/day. This is what we run.
Groq's LPU (worth calling out separately):
- $1-2/M output tokens, 500+ tokens/sec latency
- Best for: interactive applications where latency kills more users than cost kills margins
- Catch: Limited model selection (primarily Llama family). No fine-tuning. You're at their mercy for availability.
The Numbers That Actually Matter
Let me give you the calculation I ran for a client in August 2026. Fintech company, 2M requests/month, 70% simple (extraction/classification), 25% medium (summarization/analysis), 5% heavy (novel reasoning).
Before (all API, GPT-4o):
- Average 800 output tokens/request
- 2M × 800 × $10/1M = $16,000/month
- Plus input tokens (avg 2K): 2M × 2000 × $2.5/1M = $10,000/month
- Total: $26,000/month
After (hybrid, tiered routing):
- 70% → self-hosted 8B (AWQ): 1.4M requests × 400 tokens × $0.003/1K = $1,680
- 25% → API Mistral Large: 500K × 1,200 tokens × $0.40/1M = $240
- 5% → API Claude Sonnet 4: 100K × 3,000 tokens × $15/1M = $4,500
- Cache hits (82% on simple tier): save ~$1,400
- Input tokens (self-hosted, effectively free): $0
- Total: ~$5,020/month
That's an 80% reduction. Not from a magic model. From routing, caching, quantization, and tiering.
FAQ
What's the fastest way to cut LLM inference cost by 50%?
Add a semantic cache and a complexity router. That's it. Two components. A week of work. If 70%+ of your traffic is repetitive or simple, you'll hit 50% reduction in two weeks. We've seen it work at a logistics company in 2025 — their shipment-status queries were 91% repeatable patterns. Cache solved it.
Should I self-host or use an API in 2026?
If you're under 15K requests/day, use an API. The infra tax isn't worth it. If you're over 30K requests/day with a steady 8B-70B workload, self-host with vLLM. Between 15K-30K, go hybrid. The break-even point shifts with model size and your GPU rental rates (which dropped ~20% from 2024 to mid-2026 as H200s became more available).
Does quantization actually hurt quality?
AWQ INT8: barely. 1-3% on most evals. GPTQ INT4: 3-7% on reasoning tasks, <2% on extraction. For a support bot or data extraction pipeline, you won't notice. For a legal document analyzer where a 2% error rate means a missed clause, stick with INT8 or FP16. Test on your data. Not MMLU. Your data.
Is speculative decoding worth the complexity?
Yes, if you're self-hosting and your bottleneck is throughput. vLLM makes it a config flag. speculative_model: "llama-3.1-8b" alongside your 70B target. We saw 1.7x throughput. No code changes to the application layer. The complexity is in the initial tuning (draft length, acceptance threshold), not in ongoing ops.
How do I handle the 5% of requests that genuinely need a frontier model?
Don't avoid it. Route them. The cost of 5% of traffic going to Claude Sonnet 4 or GPT-4o is manageable. The cost of routing everything there is not. The router is the product. Build it well, monitor its accuracy weekly, and retrain the classifier when your traffic distribution shifts.
What about batch APIs for cost reduction?
OpenAI's batch API (50% discount) and Anthropic's equivalent are real. If your workload is offline (overnight document processing, weekly report generation), use them. 50% off is 50% off. But don't force interactive traffic into a batch queue just for the discount. The latency tax will kill your UX.
Is there a "free tier" strategy I'm missing?
Some providers offer free tiers for evaluation. Together AI gives $5/month credit. Hugging Face Inference API has a free tier for small models. These are for prototyping, not production. At production scale, the free tiers cap out at a few hundred requests. Don't build architecture around them.
The Bottom Line
How to reduce llm inference cost isn't a single optimization. It's a stack. Pick the right model per task tier. Route traffic so 70-80% hits the cheap path. Cache what's cacheable. Quantize your self-hosted models. Use continuous batching and prefix caching. And measure. Actually measure, per request, per tier, per week.
The teams I see still overpaying in 2026 aren't paying for "AI." They're paying for a flat architecture that treats a classification query the same as a novel reasoning task. They're not caching. They're running FP16 when INT8 is fine. They're paying per-token API prices for steady-state volume that should be on bare metal.
None of this is hard. It's just boring, iterative work. Build the router. Add the cache. Quantize. Measure. Repeat.
Our bill went from $26K to $5K in nine months. No product changes. No feature cuts. Just infrastructure thinking.
Nishaant Dixit — Founder of SIVARO. Building data infrastructure and production AI systems since 2018. Built systems processing 200K events/sec.