Part 2: Prompt Caching & Batch APIs — How to Cut LLM Input Costs by Up to 90%
In the first part of this series, we looked at how routing routine requests away from flagship models immediately slashes your monthly API spend. Even after you set up model routing, though, there is a second silent co
In the first part of this series, we looked at how routing routine requests away from flagship models immediately slashes your monthly API spend.
Even after you set up model routing, though, there is a second silent cost driver sitting inside almost every production LLM call: repeated input tokens. System prompts, tool schemas, few-shot examples, and reference docs get billed over and over on every single request.
Here is how to combine Prompt Caching and Batch APIs to cut those remaining input costs by 50% to 90%, along with the exact prompt layout rules that make caching actually trigger.
1. Why Input Tokens Quietly Dominate Production Bills
In real-world apps (RAG pipelines, coding assistants, agent loops), input tokens usually outnumber output tokens by 5:1 to 20:1.
Suppose your app sends 3,500 tokens of static system instructions + JSON tool definitions plus 500 tokens of dynamic user input on every request, at 50,000 requests/month:
-
Static Prefix Volume:
175,000,000 tokens(175M) -
Dynamic Query Volume:
25,000,000 tokens(25M) -
Output Volume (400 tokens/call):
20,000,000 tokens(20M)
You can plug your own input/output token counts into the PromptBill LLM API Pricing & Token Calculator to see what this ratio costs across OpenAI, Anthropic, Google Gemini, and DeepSeek models.
2. How Prompt Caching Changes the Math
OpenAI, Anthropic, and Google Gemini all support prefix-based prompt caching: when the beginning of your prompt matches a recently processed prefix, cached input tokens are billed at 75% to 95% less than standard input rates.
For example, on a mid-tier model priced at $2.00 / 1M input and $0.20 / 1M cached read:
- Without Prompt Caching (200M uncached input): $$200 \times \$2.00 = \$400.00/\text{month}$$
- With 90% Cache Hit Rate on Static Prefix (157.5M cached + 42.5M uncached): $$(157.5 \times \$0.20) + (42.5 \times \$2.00) = \$31.50 + \$85.00 = \$116.50/\text{month}$$
That saves $283.50/month on input tokens alone—without changing models or touching output quality. To compare cached vs. uncached rates across providers side by side, check the PromptBill Head-to-Head LLM Comparison tool.
The Golden Rule of Prompt Layout
Prompt caches match strictly from token #1 forward. A single changing variable near the top breaks the cache for everything after it.
Always structure your payload in this exact order:
text
1. [STATIC] Role & core system instructions
2. [STATIC] Tool definitions & JSON output schemas
3. [STATIC] Few-shot examples
4. [DYNAMIC] Current date/time, user metadata, retrieved context, user message
Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.