How to Cut LLM API Costs by 50% (4 Proven Methods)

Most teams overpay for LLM APIs by 3–5x. Four proven methods - prompt caching, model routing, prompt compression, and async batching - can slash that bill by 50% or more without touching output quality.

SY

Shubham Yadav

Machine Learning Researcher

June 11, 202614 min read
On this page

TL;DR

  • Prompt caching cuts repeated-context costs by 41–81% - zero code changes on OpenAI, one flag on Anthropic.
  • Model routing saves 40–70% per request by sending simple tasks to cheap models like Gemini 2.0 Flash ($0.10/MTok).
  • Prompt compression delivers ~80% cost reduction at 2–3x compression with less than 5% accuracy impact.
  • Batch API gives a flat 50% discount on any async workload - reports, enrichment, bulk classification.
  • Stack all four and a $1,000/mo bill becomes ~$75/mo - a 92% reduction.

Why LLM API Bills Spiral Out of Control

Most teams discover their LLM spend is 3–5x their budget the moment they hit production scale. The pricing page looks fine. The bill does not. (These are the hidden costs that compound once you're live.)

Here's why.

What actually drives your costs

LLM API pricing is dead simple: (input tokens × input price) + (output tokens × output price). But three dynamics turn that formula into a runaway number:

  • Input tokens - every character of your system prompt, conversation history, and context gets billed on every single request.
  • Output tokens - these cost 3–5x more than input tokens. GPT-4o charges $5/MTok input but $15/MTok output.
  • Model tier - the default "use the best model" instinct is expensive. Very expensive.

The real pricing gap

Here's the current pricing landscape across the major providers:

Model Input ($/MTok) Output ($/MTok)
GPT-4o $5.00 $15.00
GPT-4o Mini $0.15 $0.60
Gemini 2.0 Flash $0.10 $0.40
Claude 3.5 Haiku $0.80 $4.00

GPT-4o Mini is 97% cheaper than GPT-4o on input tokens. For classification or tagging tasks, the quality difference is negligible. The cost difference is not.

The "default to the biggest model" trap

It's the most common mistake in LLM cost optimization. Teams prototype on GPT-4o, ship to production on GPT-4o, and never revisit. Every request - from a two-word intent classification to a complex multi-step reasoning task - hits the same $5/MTok model.

That's like hiring a senior architect to hang a picture frame. The work gets done. The invoice hurts.

The good news: you don't need to sacrifice quality to fix this. You need a system.


Method 1 - Prompt Caching (Save 41–81% Overnight)

Prompt caching is the fastest win in LLM cost reduction. For most production apps, you can activate it today and see savings on tomorrow's invoice. (For provider-specific details, see prompt caching as a cost lever.)

What is prompt caching?

Every time you call an LLM, it processes your entire input from scratch - including the system prompt, any RAG context, and few-shot examples you've stuffed in there. Prompt caching stores the processed representation of that static content so the model doesn't recompute it on every request.

The first call writes to the cache (small premium). Every subsequent call reads from it (massive discount).

How the economics work

Event Cost
Cache write (first call) 1.25x standard input rate (+25% premium)
Cache read (subsequent calls) 0.10x standard input rate (90% discount)

That cache write pays for itself after a single cache read. After two reads, you're in pure savings territory. (For the full math, see this break-even analysis for caching.)

Real savings data by model

  • Anthropic Claude - cache reads at 10% of standard rate (90% discount). Real-world savings: 41–80% on total API cost.
  • OpenAI GPT-4o - automatic caching, no code changes needed. Saves 46–48% on cached prefixes.
  • OpenAI GPT-5 - automatic caching saves 79–81%. The newer the model, the bigger the cache benefit.

When to use it

Prompt caching delivers maximum ROI when you have:

  • Repeated system prompts - the same 500–2,000 token instruction block sent with every request
  • RAG context - large document chunks that appear across multiple queries
  • Few-shot examples - static examples in your prompt that never change
  • Conversation history - long multi-turn threads where early messages repeat

Quick implementation checklist

  • Identify your longest static prompt segment (usually the system prompt)
  • On Anthropic: add "cache_control": {"type": "ephemeral"} to that block
  • On OpenAI: do nothing - caching is automatic for prefixes ≥ 1,024 tokens
  • Monitor cache_read_input_tokens in API responses to confirm hits
  • Move dynamic content (user messages, timestamps) to the end of the prompt - caches match from the top

Method 2 - Model Routing (Save 40–70% Per Request)

Model routing is the single highest-ROI optimization you can implement. One routing layer. Immediate savings. No quality loss on the tasks that matter. (More on semantic routing for cost reduction.)

What is model routing?

A routing layer sits between your application and the LLM API. It reads each incoming request, classifies its complexity, and sends it to the cheapest model that can handle it reliably.

Simple tasks go to cheap models. Hard tasks go to frontier models. You stop paying frontier prices for commodity work.

The routing logic

Task Type Model Input Cost
Classification, tagging, formatting GPT-4o Mini or Gemini 2.0 Flash $0.10–$0.15/MTok
Standard summarization, content generation Claude 3.5 Haiku $0.80/MTok
Complex reasoning, multi-step analysis GPT-4o $5.00/MTok

Gemini 2.0 Flash at $0.10/MTok is 50x cheaper than GPT-4o on input. For 60–80% of typical production requests - the routine ones - the quality difference is zero.

A concrete example

A SaaS platform classifying support tickets by urgency and category. Before routing: every ticket hits GPT-4o at $5/MTok. After routing: classification goes to GPT-4o Mini at $0.15/MTok.

That's a 97% cost reduction on that task with near-identical accuracy.

Research from RouteLLM (ICLR 2025) confirms this pattern: a well-trained complexity router achieved 95% of GPT-4 performance while routing only 14–26% of requests to the expensive model.

How to build a simple routing layer (3-step framework)

Step 1 - Classify. Add a lightweight pre-call that scores each request: simple / medium / complex. You can use a small model (GPT-4o Mini costs $0.15/MTok for this), a rules-based heuristic, or a dedicated router like Morph Router.

Step 2 - Map. Define your model tiers. Simple → cheap model. Medium → mid-tier. Complex → frontier. Keep it to three tiers max to start.

Step 3 - Monitor. Track quality metrics per tier. If accuracy drops on a tier, tighten the routing threshold. The goal is the cheapest model that meets your quality bar - not the cheapest model, period.

Quick implementation checklist

  • Audit your current requests - what percentage are genuinely complex?
  • Define three task tiers with clear criteria (e.g., "under 100 words, single intent = simple")
  • Route simple tasks to GPT-4o Mini ($0.15/MTok) or Gemini 2.0 Flash ($0.10/MTok)
  • A/B test output quality on a sample before full rollout
  • Log model used per request to track savings and catch quality regressions

Method 3 - Prompt Compression & Context Trimming (Save 30–50%)

Every unnecessary token in your prompt is money you're paying on every single request. Prompt compression removes those tokens systematically.

What is prompt compression?

Prompt compression reduces the token count of your inputs - system prompts, conversation history, RAG context - without meaningfully changing what the model receives. Think of it as editing your prompts the way a copy editor trims a draft: same meaning, fewer words.

Token optimization isn't glamorous. The savings are.

The token math

Every 1,000 tokens removed from a GPT-4o call saves $0.005 on input alone. That sounds small. At scale:

  • 1,000 tokens trimmed × 10,000 daily requests = $50/day saved
  • That's $1,500/month from a single prompt edit

And if those tokens are in your system prompt, they compound - you're paying for them on every request, forever.

Compression techniques that work

1. Remove filler words and verbose instructions. "Please make sure to always carefully consider the following important guidelines before responding" → "Follow these guidelines." Same instruction. Roughly 70% fewer tokens.

2. Trim conversation history aggressively. Most models only need the last 3–5 turns of context to answer well. Sending 20 turns of history is paying for 15 turns of noise.

3. Use RAG instead of stuffing full documents into context. Retrieve the 3–5 most relevant chunks. Don't paste the entire knowledge base. A 50,000-token document becomes a 2,000-token retrieval.

4. Request structured output. Free-form prose uses more output tokens than JSON. A model describing a data extraction in prose might use 300 tokens. The same data as a JSON object: 80 tokens. Output tokens cost 3–5x more than input - this matters.

What the research says

Light compression at a 2–3x ratio delivers approximately 80% cost reduction with less than 5% accuracy impact, according to analysis published on Towards AI. Microsoft's LLMLingua tool achieves compression ratios up to 20x, though the sweet spot for production use is 3–5x.

The key insight: you don't need aggressive compression to see major savings. Trimming filler and capping history alone often gets you to 30–40% reduction.

Quick implementation checklist

  • Audit your system prompt - remove anything the model does correctly without being told
  • Cap conversation history at 5 turns (or use a sliding window)
  • Switch from full-document context to RAG-retrieved snippets
  • Request JSON output for structured data tasks
  • Use LLMLingua or similar tools for automated compression on long RAG contexts

Method 4 - Batching & Async Processing (Flat 50% Discount)

This is the simplest optimization on the list. If your task doesn't need a real-time response, you're leaving a 50% discount on the table.

What is batch processing?

Instead of sending requests one at a time and waiting for each response, you submit a batch of requests and collect results within 24 hours. Both OpenAI and Anthropic offer this as a first-class API feature - and both offer the same deal: 50% off, no strings attached.

The OpenAI Batch API

Submit a JSONL file of requests. OpenAI processes them asynchronously within a 24-hour window (most batches complete in 1–4 hours). Every token in the batch is billed at half the standard rate.

  • GPT-4o standard: $5.00/MTok input → Batch: $2.50/MTok input
  • GPT-4o standard: $15.00/MTok output → Batch: $7.50/MTok output
  • Supports up to 50,000 requests per batch and 200MB input files

When it works (and when it doesn't)

Use batching for:

  • Nightly report generation
  • Bulk data enrichment and classification
  • Content backfills for a CMS
  • Evaluation pipelines and test suite generation
  • Any background processing where users aren't waiting

Don't use batching for:

  • Real-time user-facing chat
  • Anything with a sub-second latency requirement
  • Live customer support interactions
  • Streaming responses

The rule is simple: if a human is waiting for the response, don't batch it. If a cron job is waiting, batch everything.

Quick implementation checklist

  • Identify all non-real-time LLM calls in your stack (reports, enrichment, evals)
  • Estimate what percentage of your monthly spend they represent
  • Migrate those calls to the Batch API (OpenAI: JSONL file upload; Anthropic: client.batches.create())
  • Set up a polling mechanism or webhook to collect results
  • Stack with prompt caching - batch + cached prefix = up to 95% savings on repeated content

Stack All 4 Methods - What the Math Looks Like

These methods compound. Each one reduces the base that the next one works on. Here's what a $1,000/mo LLM bill looks like after applying each method sequentially:

Scenario Monthly Cost Savings vs. Previous
Baseline (no optimization) $1,000 -
+ Prompt Caching ~$550 45%
+ Model Routing ~$220 60%
+ Prompt Compression ~$150 32%
+ Batching ~$75 50%
Combined ~$75 92%

A $1,000/mo bill becomes $75/mo. That's not a rounding error - that's a structural change in your unit economics. (At enterprise scale, see enterprise-scale cost optimization.)

The order matters. Start with model routing (highest ROI, lowest effort). Add prompt caching second (especially if you have long system prompts). Layer in compression third. Apply batching to everything that can tolerate async delivery.

You don't need all four on day one. Model routing + prompt caching alone typically delivers 50–65% reduction - which is exactly the headline promise, and it's achievable in a single sprint.


Key Takeaways

  • LLM cost reduction starts with model selection. Routing simple tasks to GPT-4o Mini ($0.15/MTok) instead of GPT-4o ($5.00/MTok) is a 97% input cost reduction on those tasks.
  • Prompt caching is the fastest win. On OpenAI it's automatic. On Anthropic, one flag activates it. Either way, you're looking at 41–81% savings on repeated context.
  • Token optimization compounds. Every token you remove from a system prompt is removed from every future request. The savings aren't linear - they accumulate.
  • The Batch API is free money for async workloads. 50% off, same models, same quality, 24-hour SLA. There's no downside for non-real-time tasks.
  • Stack the methods. Each one reduces the base for the next. Four methods applied together can cut a $1,000/mo bill to $75/mo - a 92% reduction.
  • Start with routing. It has the highest ROI with the lowest implementation effort. One classification layer, no prompt changes, 40–70% savings.

FAQ

How much can I realistically save by optimizing my LLM API costs?

Most developers see a 30–50% reduction from prompt optimization and caching alone. Stack model routing and batching on top, and 70–92% total reduction is achievable. The exact number depends on your workload - apps with repeated system prompts and async tasks see the biggest gains.

What is the fastest way to reduce LLM API spend?

Enable prompt caching first. On OpenAI, it's automatic for prompts over 1,024 tokens - no code changes required. On Anthropic, add "cache_control": {"type": "ephemeral"} to your static prompt blocks. Most teams see measurable savings within 24 hours.

Does model routing hurt output quality?

Not on simple tasks. Classification, tagging, formatting, and short-form extraction on GPT-4o Mini or Gemini 2.0 Flash produce near-identical results to GPT-4o at a fraction of the cost. RouteLLM research (ICLR 2025) found that routing only 14–26% of requests to the expensive model preserved 95% of GPT-4 performance overall.

What is prompt compression and is it safe to use in production?

Prompt compression removes redundant tokens from your inputs - filler words, verbose instructions, excess conversation history - without changing the model's effective input. At a 2–3x compression ratio, research shows roughly 80% cost reduction with less than 5% accuracy impact. Start conservative (2x) and monitor quality metrics before pushing further.

When should I use the OpenAI Batch API?

Use it for any workload where users aren't waiting for a real-time response: nightly reports, bulk data enrichment, content generation pipelines, evaluation runs, and background classification. The Batch API delivers a flat 50% discount with a 24-hour completion window. Stacked with prompt caching, you can hit 95% savings on the cached portion of batch requests.

How do I know which optimization to implement first?

Start with model routing - it has the highest ROI and lowest implementation effort. Then add prompt caching (especially if your system prompt is over 500 tokens). Layer in context trimming and compression third. Apply batching last, to all eligible async workloads. This sequence typically delivers 50–65% savings within the first sprint.

Does prompt caching work across different sessions and users?

On OpenAI, caching is automatic and applies across requests that share the same prompt prefix - including across different users if they share the same system prompt. On Anthropic, cached content persists for 5 minutes by default (extendable to 1 hour at a higher write premium). For shared system prompts in multi-tenant apps, this means one cache write can serve thousands of users.


Useful Sources