The article analyzes the economics of KV prompt caching across Anthropic, DeepSeek, and Google, demonstrating how proper implementation can reduce input token costs by up to 90% for production LLM workloads. Anthropic charges a 25% write surcharge ($3.75/1M tokens) for a 5-minute TTL but offers an 80% read discount ($0.30/1M tokens), requiring a minimum 1,024-token threshold; break-even occurs at two reads within the TTL. DeepSeek V3 and R1 impose no write surcharge ($0.14/1M tokens) and provide a 90% read discount ($0.014/1M tokens), yielding immediate savings on any cache hit via automated prefix caching. Google Gemini charges a $1.00/1M tokens/hour storage fee with a 75% read discount ($0.025/1M tokens) and a high 32,768-token minimum threshold. In a standardized 10M token workload (7M input, 3M output) with a 60% cache hit ratio, DeepSeek V3 achieves the highest savings at 32.6% ($1.22 vs $1.81 uncached), followed by Gemini 2.0 Flash at 22.1%, Claude 3.5 Sonnet at 17.2%, OpenAI GPT-4o at 14.0%, and DeepSeek R1 at 8.4%. Key optimization strategies include ordering prompts by volatility—placing static system instructions and few-shot examples first—and standardizing system prompts to avoid dynamic elements that invalidate cache prefixes. The interactive ModelPricing.xyz simulator enables precise cost modeling for specific architectures.
Read original
dev.to