Enterprise AI inference costs are ballooning in 2026: China’s daily token consumption reached roughly 500 trillion in June, nearly 4x the figure from December 2025 (China Academy of Information and Communications Technology, CAICT); Tencent’s WorkBuddy alone burns over 100 trillion tokens per day; and Gartner predicts that by 2028 the inference cost per agent workflow will rise to more than 5x today’s level. Yet through six engineering levers — prefix caching, context trimming, model-tier routing, output length control, batch processing, and input compaction — most agent projects can cut their bill by 60%–90% without hurting quality. This guide explains the principle, quantified gains, and rollout steps for each method.
1. Why Is Your Token Bill Out of Control?
The bill is exploding not because models got more expensive, but because consumption is growing faster than compute is getting cheaper. Three structural forces keep pushing costs up: agents’ multi-turn reasoning doubles or triples calls per task, long contexts inflate every input, and output bloating makes the most expensive part of the bill run wild. Before optimizing, understand the cost structure.
Three Token Cost Types (they set your priority order)
| Token Type | What it is | Price level (relative) | Optimization room |
|---|---|---|---|
| Input tokens | Prompt, context, history sent to the model | Baseline | Large (context trimming, compaction, caching) |
| Output tokens | Model-generated reply, including reasoning | Most expensive, usually 3–6x input | Medium (length cap, structured output) |
| Cache-hit tokens | Input that hits the prefix cache | Cheapest, can be as low as 10% of input | — already optimal |
Sources: 51CTO “Agent Cost Reduction in Practice”, Volcano Ark pricing page, Tencent Cloud TokenHub. Key takeaway: output is the most expensive, input is the largest by volume, cache is the cheapest — so trim input first, cap output second, then discount input further with caching.
Three structural drivers of the bill
- Agent multi-turn reasoning: one agent task loops plan→tool→observe→re-plan 3–10 times, each loop a model call, so one task costs several times a single-turn query.
- Full context carried every turn: stuffing all history and all documents into each prompt makes input grow linearly (or worse) with conversation length.
- Output bloat: models tend to “oversay” — open-ended generation produces redundant reasoning and pleasantries, and output is exactly the most expensive part.
2. Method 1: Prefix Caching — the Highest Single-Item Return
Cache and reuse fixed prefixes — system prompts, tool definitions, few-shot examples — and the cached portion is billed far below standard input rates. Anthropic charges roughly 10% of standard input for cache reads, OpenAI about 50%, and domestic models even less (Volcano Ark charges ¥0.1 per million cache-hit tokens vs ¥3 for online input, a 1/30 discount). In long-running agents the system prompt and tool definitions are read repeatedly, so cache hits often account for a large share of consumption. This is the highest-return, lowest-effort single change.
How it works
Put all invariant content at the very front of the prompt. Providers cache identical prefixes; as long as the prefix is byte-for-byte identical across requests, later requests hit the cache and that portion is billed at the cache rate.
Quantified gains
- For tool-call-heavy agents, system prompt + tool definitions typically make up 30%–60% of each turn’s input; caching all of it cuts that portion to 10%–50% of the original cost.
- On Volcano Ark, the cache-hit rate (¥0.1) vs online input (¥3) saves about 97%; even at OpenAI’s 50% discount you save half.
Rollout steps
- Place all fixed content (system prompt, tool schema, few-shot) at the front and keep it byte-identical across requests — never inject timestamps, random numbers, or user IDs into the fixed prefix.
- Confirm your model/platform supports prefix caching (OpenAI, Anthropic, DeepSeek, Volcano Ark, Tencent Cloud TokenHub all do).
- Monitor the platform’s cache-hit-rate metric; target a steady 80%+.
- Put dynamic, user-specific content (history, retrieval results) after the prefix so it never breaks the cache.
Caveats
- Any change to the prefix invalidates the cache and falls back to full price — the fixed zone and dynamic zone must be physically separated.
- Some platforms impose a TTL on the cache (e.g., 5 minutes); high-frequency consecutive calls capture the most value.
3. Method 2: Context Trimming & Compression — cut 70%+ of input
Replace “carry full context every turn” with sliding windows, history summarization, and RAG on-demand retrieval. Long conversations are an agent cost black hole — carrying all history every turn is the most common waste. For most tasks the model only needs the last few turns plus a relevant summary; trimming irrelevant history typically cuts input by 70%+ with negligible quality impact.
Three trimming strategies
- Sliding window: keep only the last N turns (e.g., 6–10), discard older ones. Best for task-oriented, short-cycle conversations; simplest to implement.
- History summarization: use one small-model call to compress early conversation into a summary, then carry only the summary + recent verbatim turns. Best for long-cycle, memory-heavy scenarios; the summary costs a fraction of full history.
- RAG on-demand retrieval: don’t stuff the whole knowledge base into context — each turn retrieve only the 3–5 relevant chunks. Best for KB Q&A and document analysis; the biggest input-volume saver.
Quantified gains
- Sliding window: input down 60%–80% for long conversations (20+ turns).
- History summarization: early turns compressed to 1/10 of their length, overall input down 40%–60%.
- RAG retrieval: 50 pages of documents → 3 chunks, input down 90%+.
Rollout steps
- Measure average conversation turns and per-turn context length to find where “full carry” wastes the most.
- Start with sliding window for short tasks (smallest change); add summarization for long-memory scenarios; add RAG for knowledge bases.
- Validate with an effect regression set: confirm accuracy drops are within acceptable range (usually <2%) after trimming.
4. Method 3: Model-Tier Routing — cut the overall bill by 50%+
Send simple tasks (classification, extraction, format conversion) to small models, and reserve large models for complex tasks (reasoning, long-form generation). Haiku/Flash-class models cost 1/10 or less of flagship models, yet roughly 80% of an agent’s sub-tasks (tool-parameter validation, result summarization, intent classification) don’t need flagship capability. Adding a routing layer cuts the overall bill by 50%+ with almost no quality loss.
2026 mainstream model pricing tiers (online inference, ¥ per million tokens)
| Model | Provider | Input | Output | Cache hit | Best for |
|---|---|---|---|---|---|
| Claude Haiku 5.5 | Anthropic | ¥0.67 | ¥3.33 | ~¥0.07 | Classification, extraction, summarization, routing decisions |
| DeepSeek-V4.1-Flash | DeepSeek | comparable to Haiku | — | — | Everyday reasoning, tool calling |
| Doubao (Volcano Ark) | ByteDance | 3.0 | 9.0 | 0.1 | Chinese scenarios, enterprise KB |
| MiniMax M4 | MiniMax | 5.0 | 20.0 | 0.3 | Multimodal, long context |
| Claude Opus / GPT flagship | Anthropic / OpenAI | high | high | — | Complex reasoning, long-form generation (only when needed) |
Sources: LLMRates.ai, Volcano Ark official pricing, 36Kr “Silicon Valley LLMs stop pretending”, MiniMax M4 release. Note: prices move fast amid the price war — always check the latest official page before rollout.
Routing strategy
- Entry routing: use a small model for intent classification and complexity判断, deciding which tier handles the request.
- Task routing: tool calls, parameter extraction, and result formatting always use small models; only final generation and deep reasoning use large models.
- Fallback strategy: when the large model is overloaded or over budget, automatically degrade to a small model to maintain availability.
Quantified gains
- If 80% of calls go to a small model priced at 1/10 of flagship, overall cost ≈ 0.8×0.1 + 0.2×1 = 28%, i.e., a 72% reduction.
- Most projects see 50%–70% in practice.
5. Method 4: Output Length Control — cut 40% of output cost
Output tokens are the most expensive part (3–6x input). Capping with max_tokens, requiring structured output (JSON), and setting stop words can eliminate the model’s pointless “oversaying”. Making the model “speak plainly and briefly” typically cuts output cost by 40% without users noticing.
Four control levers
max_tokenshard cap: set 50 for classification, 300 for summarization, 2000 for long-form generation — cap per task type to prevent runaway output.- Structured output (JSON / Function Calling): require the model to return only fixed fields, no explanatory text. Output length becomes predictable and controllable.
- Stop words / end markers: set a clear end signal so the model stops when done, with no pleasantries or repetition.
- Prompt constraints: in the system prompt, explicitly instruct “answer concisely, do not repeat the question, do not output reasoning”, and lower the temperature.
Quantified gains
- Open-ended generation → structured output: output tokens down 30%–60%.
max_tokenscap: prevents occasional ultra-long outputs (these anomalies often dominate the bill).- Concise prompt constraints: everyday conversation output down 15%–25%.
Caveats
- Don’t set
max_tokensso low that normal answers get truncated — measure the safe ceiling per task type with a regression set. - Reasoning models’ (with thinking) reasoning chains also count as output tokens; disable or limit reasoning on simple tasks.
6. Method 5: Batch Processing (Batch API) — save 50% on non-real-time tasks
Route non-real-time tasks to batch inference, usually priced around half of online. On Volcano Ark, for example, batch input is ¥1.5/million (vs ¥3 online) and batch output ¥4.5 (vs ¥9 online) — exactly half price. Report generation, batch classification, offline data processing, and scheduled summaries that don’t need sub-second response should all go through batch.
Suitable vs. unsuitable scenarios
| Good for batch | Must stay online |
|---|---|
| Batch document summarization, classification | Real-time chat, customer service |
| Offline data analysis | Real-time decisions in tool calling |
| Scheduled report generation | Interactive requests where the user waits |
| Large-scale data labeling/cleaning | — |
Quantified gains
- Straight 50% off: online ¥3/9 → batch ¥1.5/4.5 (Volcano Ark).
- If 40% of a project’s calls can be batched, the overall bill drops ~20%; the higher the batch share, the bigger the saving.
Rollout steps
- Map the call chain and flag which tasks tolerate >a few minutes of latency.
- Switch those tasks to Batch API (OpenAI Batch, Anthropic Batch, and domestic platforms all support it).
- Build an async result-backfill mechanism so the main flow is unaffected.
7. Method 6: Input Compaction & Deduplication — another 15%–25%
On top of the optimizations above, slim down the input itself: remove duplicates, compress formatting, drop irrelevant fields. Input compaction usually saves another 15%–25% with zero quality impact — a low-cost finishing touch.
Specific techniques
- Deduplicate: keep only one copy of repeated system prompts and repeated document chunks in history.
- Compress formatting: collapse multi-line JSON to single line, strip meaningless whitespace and comments; use short codes instead of long field names where it doesn’t hurt comprehension.
- Field selection: for RAG-retrieved documents, fetch only the fields needed to answer, not the entire raw text.
- Templating: fill fixed phrases with variables instead of resending the full template every time.
- On-demand multimodal: in multimodal scenarios, send only the needed frames/pages, not every image in a document.
Quantified gains
- Typically 15%–25% on its own; marginal returns diminish when stacked with caching and trimming, but it’s nearly free.
8. Combined Gains & Rollout Roadmap
The six methods don’t simply add up — they have priority and dependency. Roll out in the order below; most agent projects see a measured 60%–90% bill reduction with <3% quality regression.
Estimated combined gains
| Stage | Methods | Cumulative bill cut (vs. baseline) | Effort | Time to effect |
|---|---|---|---|---|
| Stage 1 | Prefix caching + output length cap | 30%–50% | Low | Same day |
| Stage 2 | Context trimming + model-tier routing | 60%–80% | Medium | 1–2 weeks |
| Stage 3 | Batch processing + input compaction | 70%–90% | Medium | 2–4 weeks |
Estimates are based on public industry cases and our own deployment experience; actual cuts depend on your call structure. If output dominates your original bill (open-ended generation), output capping helps more; if contexts are very long, trimming helps more.
90-day rollout roadmap
- Week 1: deploy prefix caching (separate fixed/dynamic prefixes) + blanket
max_tokenscaps + concise prompt constraints. See the bill drop immediately. - Weeks 2–3: roll out sliding window and history summarization; build the model routing layer and move tool-call tasks to small models.
- Weeks 4–6: convert knowledge-base scenarios to RAG on-demand retrieval; identify and migrate batchable tasks.
- Weeks 7–12: fine-tune input compaction; build a cost monitoring dashboard (cost per 10k calls, cache hit rate, call share per model) and keep tuning.
9. Common Pitfalls (avoid these)
- Chasing unit price, ignoring volume: switching to a model 20% cheaper beats nothing — halving consumption beats it. Unit price cuts have a ceiling; volume cuts barely do.
- Stuffing dynamic content into the cached prefix: timestamps or user IDs mixed into the fixed prefix zero out the cache hit rate, making the caching optimization pointless.
- Trimming too hard → amnesia: a too-small sliding window or a summary losing key info degrades answer quality — always validate with a regression set.
- Routing complex tasks to small models by mistake: the routing decision itself must be accurate, or the small model fails and retries, costing more.
- One-size-fits-all
max_tokens: the same cap across all tasks either truncates normal answers or stays too wide for simple ones — set per task type.
Closing
Token cost isn’t an uncontrollable black box — it’s a clear bill that can be engineered down. Prefix caching, context trimming, model-tier routing, output length control, batch processing, and input compaction cover input, output, and scheduling; rolled out in priority order, a 60%–90% reduction is achievable for most projects.
If your AI application or agent project is struggling with its token bill, share your call structure and monthly spend with us — we can run a cost diagnosis and give you a targeted optimization plan.
Sources
- CAICT “Top 10 Keywords of the 2026 AI Industry” (500 trillion daily tokens, Gartner forecast)
- The Paper (澎湃) “AI Office Wars” (Tencent WorkBuddy 100 trillion tokens/day)
- Volcano Ark official pricing, Tencent Cloud TokenHub pricing
- LLMRates.ai LLM API price comparison
- 36Kr “Silicon Valley LLMs stop pretending: Claude cuts prices, GPT follows Doubao”
- 51CTO “Agent Cost Reduction in Practice: Six Axes to Cut the Token Bill by 90%”
- MiniMax M4 official release