Reducing Token Usage in Production LLM Apps
Cut LLM token costs by optimizing prompts, caching responses, streaming outputs, and choosing the right model. Practical guide to reducing token usage.
By Pulkit Verma, Founder & CEO, WeaveAI
Research and drafting assisted by WeaveAI Cite.
Token costs scale directly with usage in production LLM applications. You can reduce token consumption by shortening prompts, implementing response caching for repeated queries, streaming outputs to avoid regeneration, using smaller models for routine tasks, and batching requests. These techniques typically cut token consumption by 30-70% depending on your application's query patterns and tolerance for latency.
Every token sent to an LLM and every token it returns counts toward your bill. A single verbose prompt repeated across thousands of daily queries turns into a meaningful line item. The approaches below address input tokens, output tokens, and redundant calls—the three places waste accumulates fastest.
What Are the Fastest Ways to Cut Token Costs?
Start with prompt compression and response caching because they require the least architectural change and deliver immediate savings.
Prompt compression means removing filler words, redundant instructions, and unnecessary examples from your system and user prompts. A 500-token prompt that drops to 300 tokens saves 200 input tokens per call. If your app handles 10,000 queries daily, that's 2 million input tokens saved per day.
Response caching stores the output for identical or semantically similar queries and serves it without calling the model. If 20% of your queries repeat, you eliminate 20% of your token spend with a simple cache layer. Semantic caching uses embeddings to match near-duplicate questions, extending coverage beyond exact string matches.
Both techniques integrate into existing codebases without rewriting your prompts or switching models. They reduce cost immediately and stack with every other optimization.
How Do You Choose Between Smaller Models and Prompt Optimization?
Smaller models cut cost per token but may reduce quality. Prompt optimization preserves quality while reducing token count. The right choice depends on whether your task tolerates a quality drop.
| Approach | Cost Reduction | Quality Impact | Engineering Effort |
|---|---|---|---|
| Smaller model (GPT-4 → GPT-3.5) | 10-20× per token | Moderate to high | Low (model swap) |
| Prompt compression | 20-50% tokens | None if done carefully | Medium (rewrite and test) |
| Semantic caching | 15-40% queries | None (serves exact matches) | Medium (cache + embedding layer) |
| Output length limits | 10-60% output tokens | Low to moderate | Low (add max_tokens param) |
| Batching requests | 0-10% overhead reduction | None | Medium to high (queue + routing) |
Use smaller models for classification, extraction, and other tasks with clear success criteria. Reserve larger models for open-ended generation, reasoning, or cases where quality directly affects user satisfaction. Many production systems route simple queries to a small model and escalate complex ones to a larger model, balancing cost and quality dynamically.
Prompt optimization works best when your prompts contain repeated boilerplate, verbose instructions, or examples that could be condensed. Test compressed prompts against a labeled evaluation set to confirm quality holds.
Should You Stream Outputs or Generate Complete Responses?
Stream outputs when users see results incrementally and you can stop generation early. Generate complete responses when you need the full output for downstream processing or logging.
Streaming sends tokens as the model produces them, letting you display partial results and cancel generation if the user navigates away or if you detect the answer is complete. This avoids paying for tokens the user never sees. Applications with chat interfaces, live previews, or interactive Q&A benefit most.
Complete generation makes sense when you need to parse, validate, or store the entire response before acting on it. If your workflow involves extracting structured data, running post-processing, or chaining multiple LLM calls, streaming adds complexity without saving tokens.
The cost difference appears in abandoned requests and redundant regeneration. If 10% of requests are abandoned mid-stream, streaming saves 5-10% of output tokens by stopping early. If your architecture requires regenerating responses that fail validation, streaming lets you catch errors sooner and retry with less waste.
Four Steps to Implement Token Reduction in Production
Follow this sequence to reduce token usage without breaking existing behavior or degrading quality.
1. Audit Current Token Consumption by Endpoint
Log input and output token counts for every API call, grouped by endpoint or query type. Identify which prompts consume the most tokens and which queries repeat most often. This baseline tells you where optimization delivers the highest return.
2. Compress High-Volume Prompts
Rewrite your top three prompts by removing filler, consolidating instructions, and replacing verbose examples with concise ones. Test each compressed version against a sample of real queries to confirm output quality remains acceptable. Deploy the compressed prompts and measure token savings.
3. Add Semantic Caching for Repeated Queries
Implement a cache that hashes user queries or embeds them into vectors and retrieves stored responses for near-matches. Set a similarity threshold (commonly 0.85-0.95 cosine similarity) that balances cache hit rate against false positives. Monitor cache hit rate and adjust the threshold if users report stale or incorrect answers.
4. Route Simple Queries to Smaller Models
Define criteria for "simple" queries—short inputs, single-step tasks, or requests that match known patterns. Route these to a smaller, cheaper model and send everything else to your primary model. Track quality metrics separately for each model to catch regressions early.
What Are the Hidden Costs of Token Reduction?
Token reduction trades engineering time, latency, and sometimes quality for lower per-query cost. Each technique carries a failure mode you need to monitor.
Prompt compression can remove context the model needs to produce correct answers. Over-compressed prompts lead to vague or incomplete responses. Test compressed prompts against edge cases and monitor output quality metrics after deployment.
Caching serves stale answers when underlying data changes or when semantically similar queries have different correct answers. A cache that matches "What's the weather in Seattle?" with "What's the weather in Portland?" saves tokens but frustrates users. Invalidate cache entries when source data updates and log cache misses to detect drift.
Smaller models fail on tasks that require reasoning, nuance, or domain knowledge. They may produce confident but incorrect answers, especially on queries outside their training distribution. Route only tasks with clear success criteria to small models and escalate failures automatically.
Streaming adds complexity to error handling, retries, and logging. Partial outputs are harder to debug and harder to store for audit trails. If your system requires complete responses for compliance or post-processing, streaming's cost savings may not justify the engineering overhead.
Frequently Asked Questions
How much can token reduction lower my LLM costs?
Token reduction typically lowers costs by 30-70% depending on the techniques you apply and your application's query patterns. Prompt compression alone often saves 20-40% of input tokens, while caching can eliminate 15-40% of redundant queries. Combining multiple approaches compounds the savings, but diminishing returns set in as you optimize further. The exact reduction depends on how much waste exists in your current prompts, how many queries repeat, and whether you can route tasks to smaller models without quality loss.
Does caching work for conversational apps with context?
Caching works for conversational apps if you hash the full conversation history along with the current user message. Exact-match caching captures repeated multi-turn conversations, though hit rates are lower than single-turn Q&A because conversations diverge quickly. Semantic caching can match similar conversation trajectories, but you must tune similarity thresholds carefully to avoid serving responses that ignore recent context. Many conversational apps cache only the first few turns or cache retrieval-augmented generation results separately from conversational responses to balance hit rate and correctness.
Can I reduce tokens without changing my prompts?
Yes, you can reduce tokens without changing prompts by implementing response caching, setting output length limits with the max_tokens parameter, and routing queries to smaller models. Caching eliminates redundant calls entirely, output limits cap generation length, and smaller models reduce cost per token. These changes happen outside your prompt text and require no rewriting. However, prompt compression typically delivers the largest single reduction, so avoiding it means leaving significant savings on the table if your prompts contain boilerplate or verbose instructions.
Start Reducing Token Costs in Production
Token usage compounds quickly at scale, but the techniques above let you cut costs without sacrificing quality or rewriting your application. Start with prompt compression and caching for immediate savings, then layer in model routing and streaming as your system matures.
WeaveAI builds production RAG systems and AI workflow agents that stay cost-efficient after deployment. If you need help optimizing token usage or building reliable LLM pipelines, reach out at weaveai.dev/products/seo.
Frequently asked questions
How much can token reduction lower my LLM costs?
Token reduction typically lowers costs by 30-70% depending on the techniques you apply and your application's query patterns. Prompt compression alone often saves 20-40% of input tokens, while caching can eliminate 15-40% of redundant queries. Combining multiple approaches compounds the savings, but diminishing returns set in as you optimize further. The exact reduction depends on how much waste exists in your current prompts, how many queries repeat, and whether you can route tasks to smaller models without quality loss.
Does caching work for conversational apps with context?
Caching works for conversational apps if you hash the full conversation history along with the current user message. Exact-match caching captures repeated multi-turn conversations, though hit rates are lower than single-turn Q&A because conversations diverge quickly. Semantic caching can match similar conversation trajectories, but you must tune similarity thresholds carefully to avoid serving responses that ignore recent context. Many conversational apps cache only the first few turns or cache retrieval-augmented generation results separately from conversational responses to balance hit rate and correctness.
Can I reduce tokens without changing my prompts?
Yes, you can reduce tokens without changing prompts by implementing response caching, setting output length limits with the max_tokens parameter, and routing queries to smaller models. Caching eliminates redundant calls entirely, output limits cap generation length, and smaller models reduce cost per token. These changes happen outside your prompt text and require no rewriting. However, prompt compression typically delivers the largest single reduction, so avoiding it means leaving significant savings on the table if your prompts contain boilerplate or verbose instructions.
WeaveAI Cite
Get your business named in AI answers.
Cite finds the questions people ask AI about what you do, then writes and publishes the articles that answer them, on autopilot.
Weekly digest
New articles, once a week
What we published on agent readiness, retrieval and evals, in one email on Mondays. Nothing in weeks with nothing to send.