API Cost OptimizationLLM Cost ReductionToken Optimization

LLM API Cost Optimization: 12 Ways to Cut Your Bill 90%

1 min read

A team in Berlin was paying $4,200 per month for LLM APIs. Same application. Same user volume. After implementing the strategies in this article: $340 per month. The quality of their output —measured by user satisfaction scores and task completion rates —did not change. The only thing that changed was which model handled which request.

Going from “$4,200/month and anxious” to “$340/month and comfortable” took roughly four hours of implementation work. This article covers the 12 strategies that produced those savings, organized by impact and effort. Every strategy includes real before/after cost data. Pick the ones that match your workload. Stack them for compound savings.

Tier 1: High Impact, Low Effort (Strategies 1–4)

These four strategies produce the majority of savings —typically 70–85% combined —and none takes more than an hour to implement.

Strategy 1: Right-Size Your Models.

The single biggest cost lever. You’re using GPT-5.5 at $30/M output to classify support tickets as “urgent” or “not urgent.” DeepSeek V4 Flash does this at $0.28/M —107x cheaper —with identical classification accuracy for this task.

The implementation is a simple classifier that routes tasks to the appropriate model tier. A 50-line Python function. Before: $875/month (all requests to GPT-5.5). After: $150/month (simple tasks to DeepSeek Flash, complex tasks to GPT-5.5). Savings: 83%.

The easiest place to start: audit your last 1,000 API requests. Categorize each by task complexity —simple (classification, extraction, simple Q&A), medium (coding, analysis, summarization), complex (multi-step reasoning, debugging, legal analysis). Check which model handled each. Count how many “simple” and “medium” requests went to $25–30/M models. Those are your savings candidates.

A support engineering team at a 40-person SaaS company ran exactly this audit. Their top three cost drivers told a clear story.

Ticket classification ate 32% of spend and needed 94%+ accuracy on a three-label task. DeepSeek V4 Flash hit 96% in testing —matching GPT-5.5. Documentation Q&A (18% of spend) pulled from a fixed knowledge base and the cheaper model handled it identically.

Response drafting was the 28% that mattered. The team tested DeepSeek Flash on drafting and found tone-deaf replies that required human rewrites. Those stayed on GPT-5.5.

Result: $3,100/month dropped to $380/month. Two model tiers covered 70% of requests. Accuracy regression across all tasks: zero.

The 30% that stayed on GPT-5.5 consumed 68% of the new budget —the team knew exactly where every dollar went. Implementation took one hour.

For a detailed breakdown of which model to use for which task —including benchmark scores and pricing —the cost comparison across providers breaks down. Token pricing fundamentals are explained in our Getting Started guide —the authority reference for how input/output/cache/context-window pricing works.

Strategy 2: Prompt Caching Everything Static.

Prompt caching slashes input costs for content that repeats across requests —Anthropic gives 90% off, OpenAI 50%, DeepSeek cache hits at $0.0036/M. For the full caching mechanics, TTL behavior, and provider-by-provider implementation guide, see our how prompt caching works.

Before: $500/month on input tokens for a 10,000-token system prompt at 500 requests/day (GPT-5.5). After: $95/month (cached system prompt + Claude Opus with 90% cache discount). Savings: 81%. Implementation: add a cache_control block to your system prompt —3 lines of code.

Strategy 3: Batch API for Non-Real-Time Work.

Every evaluation run. Every data processing pipeline. Every nightly report generation. Every dataset labeling job. These don’t need sub-second responses. They can wait hours. OpenAI, Anthropic, and Google offer ~50% discount for accepting 24-hour turnaround on batch requests.

Before: $200/month (real-time API for evaluation runs and data processing). After: $100/month (batch API for eligible workloads). Savings: 50%. Implementation: swap client.chat.completions.create() for the batch equivalent —OpenAI’s batch API uses JSONL files for requests and returns results within 24 hours. In our analysis, teams typically find 30–50% of their LLM volume is batch-eligible once they audit their workloads.

Strategy 4: Set Hard Budget Caps.

This doesn’t reduce costs —it prevents the catastrophic overrun that makes cost optimization irrelevant. A company lost $500M in one month from an API key with no spending limit. Set hard caps at three levels: provider dashboard (backstop), platform/application level (operational control), per-key (user/feature attribution). Alert at 80%. Hard-reject at 100%. Five minutes to configure. Priceless in prevention.

Tier 2: Medium Impact, Medium Effort (Strategies 5–8)

These require more implementation work but compound with Tier 1 strategies for additional savings.

Strategy 5: Multi-Provider Cost Routing.

Different models dominate different price points. DeepSeek V4 Flash: $0.14/$0.28 —best for volume text tasks. DeepSeek V4 Pro: $0.44/$0.87 —best value coding. Claude Sonnet: $3/$15 —strong reasoning at manageable cost. Claude Opus: $5/$25 —maximum depth when needed.

A cost-based router classifies each request and sends it to the cheapest capable model. Before: $500/month (all Claude Sonnet). After: $120/month (DeepSeek Flash for 60% of requests, DeepSeek V4 Pro for 25%, Claude Sonnet for 15%). Savings: 76%. Implementation: 50 lines of Python —a complexity classifier + routing table. The multi-model routing setup has the complete code.

Strategy 6: Token Optimization.

Your prompts are longer than they need to be. Audit your system prompt —can you say it in 2,000 tokens instead of 5,000? Your few-shot examples —do you need five, or do three produce the same output quality? Your output length —are you setting max_tokens to a generous 4,000 when the average useful response is 800 tokens?

A 20–40% token reduction across all requests translates directly to a 20–40% cost reduction. Before: 2,500 tokens average per request. After: 1,600 tokens (prompt tuned + max_tokens tightened). Savings: 36% on tokens, proportional on cost. Implementation: audit, trim, test, deploy. One afternoon.

Strategy 7: Streaming + Early Stop.

Streaming doesn’t reduce per-token cost, but it reduces wasted tokens. When a user abandons a conversation mid-response —they got the answer they needed from the first two sentences —non-streaming mode has already generated (and billed for) the full response. Streaming lets you stop the stream when the user disconnects. For chatbot applications with 15–25% abandonment rates, this saves 15–25% on output tokens. Implementation: stream=True + track client disconnect.

Strategy 8: Application-Level Response Caching.

Cache identical or near-identical responses. A customer asks “what’s your return policy?” —the answer hasn’t changed since yesterday. Serve it from cache instead of calling the LLM. FAQ chatbots: 30–80% cache hit rate. Simple Redis implementation: hash the user query, check cache, return if hit, call LLM if miss. Cache TTL: 1–4 hours depending on how frequently the underlying information changes.

Tier 3: Lower Impact, Worth Doing (Strategies 9–12)

These produce smaller individual savings but add up and require minimal effort.

Strategy 9: Shorter Context Windows. Some providers charge more for long-context usage —Google’s Gemini pricing adds a surcharge above 200K tokens. If you’re sending 300K-token prompts routinely, audit whether you need the full context or can summarize/trim. Cutting from 300K to 150K on Gemini saves roughly 20% on input cost for those requests.

Strategy 10: Model-Specific Optimizations. Each provider has a cost-saving feature that’s underutilized. Anthropic: cache your system prompt + tool definitions for 90% off (most teams don’t). Google: context caching for repeated document queries (most teams don’t). OpenAI: shorter prompts reduce reasoning token consumption (reasoning tokens scale with prompt complexity). One optimization per provider. Compound effect.

Strategy 11: Negotiate Volume Discounts. Direct API: ask for committed-use discounts once you’re spending $5,000+/month. Aggregation platforms: volume pricing is built in —the platform pools demand from thousands of users and passes through rates below official retail. No negotiation required. No minimum spend.

Strategy 12: Eliminate Idle Deposits. Every direct provider account carries a minimum deposit —typically $10–20 —that sits idle, earns nothing, and ties up working capital. Five providers means $50–150 frozen across dashboards. This is not a per-token cost; it is a balance-sheet inefficiency that direct API pricing pages are designed to hide. Aggregation platforms collapse five idle balances into one working balance. Deposit $20. Route it across every model. Top up when it runs low. For a startup watching cash flow, recovering $150 in frozen deposits is meaningful. For a larger team, it is one less line item for finance to reconcile each month.

Cumulative Savings: How Strategies Stack

Strategies compound. Start with Strategy 1 (right-size models, 83% savings). Add Strategy 2 (prompt caching, another 50% on remaining cost). Add Strategy 5 (multi-provider routing, another 20%). The math: $1,000 baseline —$170 after Strategy 1 —$85 after Strategy 2 —$68 after Strategy 5. Total: 93.2% reduction.

Three real scenarios:

  • Solo developer ($50/month baseline): Strategies 1 + 2 + 8 —~$8/month. Four hours of implementation. Two model-switching decisions.
  • Startup ($500/month baseline): Strategies 1 + 2 + 3 + 5 —~$65/month. One day of implementation. A tiered model strategy + prompt caching config.
  • Scale-up ($5,000/month baseline): Strategies 1–5 + 10 → ~$580/month. Two days of implementation. Custom routing + batch pipeline + provider-specific optimizations.

Implementation priority. Start top-left of the effort-impact matrix. Strategy 1 (right-size models) takes 10 minutes and saves 83%. Do it today. Strategy 4 (budget caps) takes 5 minutes and prevents catastrophe. Do it now. The rest you implement in order of impact when you have the time. Every strategy pays for its implementation time within the first month.

FAQ

Which strategy saves the most money fastest?

Strategy 1 —right-size your models. Switching simple tasks from GPT-5.5 ($30/M output) to DeepSeek V4 Flash ($0.28/M) is a 10-minute code change that typically saves 70–80% on total API spend. Audit your last 1,000 requests. Count the ones that didn’t need frontier capability. Move them.

Does prompt caching really save 90%?

Yes, on cached input tokens —with Anthropic. If 80% of your input tokens are cached (system prompt, few-shot examples, document context), your effective input cost drops ~72%. OpenAI offers 50% off (effective ~40% reduction). DeepSeek’s cache reads at $0.0036/M are even cheaper in absolute terms. For the complete caching strategy: Prompt Caching Explained.

Is batch API worth the 24-hour delay?

For evaluation runs, data processing pipelines, report generation, and any task where the output is consumed asynchronously: yes. 50% savings for accepting a 24-hour turnaround. Teams typically find 30–50% of their LLM volume is batch-eligible once they audit their workloads.

Will these strategies affect output quality?

Strategies 1 and 5 potentially —if you route complex tasks to models that can’t handle them. Mitigation: set a quality floor. The complexity classifier in Strategy 1 should be conservative —when in doubt, route up, not down. All other strategies (caching, batch, token optimization, budget caps) have zero quality impact.

How do aggregation platforms help with cost optimization?

Strategies 1, 4, 5, 11, and 12 are either built into the platform or dramatically simplified. Model tiering and cost-based routing are configuration settings. Budget caps are per-key parameters. Volume pricing is automatic. No idle deposits across providers. The platform handles the infrastructure; you focus on your application. For a detailed comparison of direct vs. aggregated total cost, see our Why Developers Switch analysis.

What separates a $4,200 API bill from a $340 API bill was not a different application, different users, or different models —just different routing decisions. The strategies in this article are the routing decisions. Every single one can be implemented in under an hour. Most take less than ten minutes. The teams that do this work today save themselves the meeting where someone from finance asks why the LLM line item is the fastest-growing cost in the company.

Implement them in priority order —your finance team will notice the difference within the first billing cycle.

But here is the deeper question: where is the price floor? DeepSeek V4 Flash already delivers GPT-4-class output at $0.14 per million input tokens. Open-source models from Meta and Mistral are improving monthly. Inference optimization companies are squeezing another 30-50% efficiency out of each hardware generation. If the trend holds, the cost of running a production chatbot will drop below $1 per month by the end of 2027. The real question is not “how do I cut my bill today?” It is “what do I build when the bill is effectively zero?”

The strategies in this article were measured on real production workloads —the Berlin team’s $4,200-to-$340 savings happened over a single afternoon. The teams that saw the largest reductions had one thing in common: they consolidated to a single endpoint where model tiering and cost routing were configuration settings rather than custom infrastructure. TokSpan’s pricing page shows per-model rates at pooled volume —worth comparing to what you are paying direct, especially on the Tier 2 and Tier 3 models that carry most production traffic.