How does LLM prompt caching change your real monthly API bill?
Prompt caching splits your input payload into a reusable static prefix (billed at 10%–25% of standard input rates on cache hits) and dynamic per-request user tokens (billed at 100%), often cutting agent and RAG input bills by 60% to 85%.
Most basic token calculators multiply requests * (input_tokens * input_price + output_tokens * output_price). In production AI apps built in 2026 (especially tool-calling agents, code assistants, and document Q&A pipelines) that naive formula overstates or understates your real invoice by 3x to 6x. Three mechanics dominate your actual monthly spend:
- Static Prefix vs. Dynamic User Payload: System instructions, JSON tool schemas, and retrieved reference documents frequently span 2,500 to 25,000 tokens per call, whereas the user's new question may be only 150 tokens. When that static prefix clears the provider's minimum threshold (1,024 tokens on OpenAI and Claude Sonnet/Opus 5.5; 2,048–4,096 tokens on Gemini), cache hits drop input pricing by up to 90% (for example, GPT-5 drops from $1.25 to $0.125 per 1M cached tokens, and Claude Sonnet 5.5 drops from $2.00 to $0.20 per 1M).
- Cache Write & TTL Initialization Overhead: Anthropic bills explicit cache writes at roughly 1.25x base input rate ($2.50/1M on Claude Sonnet 5.5 for a 5-minute TTL), while Google Gemini explicit context caching charges an hourly storage rate alongside discounted read rates. If your traffic is too sparse to hit the warm cache before eviction, or if a dynamic timestamp at the top of your system prompt invalidates the prefix on every call, you pay cache-write overhead with zero read savings.
- Multi-Turn Context Accumulation & Hidden Reasoning Tokens: Stateless chat completions re-transmit the entire conversation history on turn 2, turn 3, and turn
N. Without sliding-window truncation or high prefix cache hit rates, input token consumption grows quadratically (N * (N + 1) / 2). Meanwhile, reasoning models such aso4-minibill internal chain-of-thought tokens at the full output token rate, meaning a 300-token visible JSON response accompanied by 2,400 internal reasoning tokens actually bills 2,700 output tokens.
When should you switch from real-time inference to Batch API?
Move any asynchronous pipeline, nightly evaluations, dataset classification, document extraction, SEO metadata enrichment, or bulk embeddings, to the Batch API whenever latency under 24 hours is acceptable, locking in an immediate 50% discount on both input and output tokens.
Unlike prompt caching (which only discounts repeated input prefixes), Batch APIs cut output token costs in half as well. Because output tokens cost 4x to 8x more than input tokens across GPT-5 ($10.00 vs $1.25/1M), Claude Sonnet 5.5 ($10.00 vs $2.00/1M), and Gemini 3.1 Pro ($12.00 vs $2.00/1M), workloads that generate long structured reports or code diffs often save more money from Batch execution than from prompt caching alone. In addition, Batch queues use separate rate-limit pools, preventing background backfills from triggering 429 Too Many Requests errors on user-facing endpoints.
| Cost Lever | Discounts Input? | Discounts Output? | Typical Real-World Savings | Primary Gotcha |
|---|---|---|---|---|
| Prompt Caching | Yes (50%–90% off prefix) | No | 45%–80% on agent/RAG workloads | Dynamic variables before prefix bust cache to 0% |
| Batch API | Yes (50% off) | Yes (50% off) | Flat 50% across total job spend | Up to 24h turnaround; async webhook/polling required |
| Model Routing (Mini/Flash) | Yes (80%–95% lower tier) | Yes (75%–95% lower tier) | 70%–90% when routing 80% of simple turns | Needs confidence/complexity classifier guardrails |
| Output Schema Compression | Minor | Yes (20%–45% fewer tokens) | 15%–35% on high-volume JSON extraction | Overly terse keys can hurt zero-shot accuracy |
How do we verify token pricing in this calculator?
Every model rate in StackQuota is loaded directly from our versioned data/pricing/llm-models.json ledger, checked against official OpenAI, Anthropic, and Google AI pricing documentation, and stamped with its exact verification date.
Our simulator separates static cached prefix tokens from fresh dynamic input tokens and models cache misses as explicit write/full-price events:
Cached Read Cost = Requests * StaticPrefixTokens * CacheHitRate * CachedInputRateUncached Prefix Cost = Requests * StaticPrefixTokens * (1 - CacheHitRate) * CacheWriteOrBaseRateDynamic Input Cost = Requests * DynamicInputTokens * MultiTurnFactor * BaseInputRateOutput Cost = Requests * VisibleAndReasoningOutputTokens * BaseOutputRateBatch Adjustment = Total * 0.50(when Batch mode is toggled on)