Skip to content

Chapter 6.4 — Caching, model routing and optimizations

🧠 Techniques

Technique Benefit Trade-off
Prompt caching Reduces cost and latency of prefixes; cache reads ≈0.1× the input price across the three large providers (checked on 2026-10-25) Requires a stable prefix and a per-model token minimum (512–4,096); writes may cost extra (1.25×/2×) or hourly storage, depending on the provider (Ch. 6.1)
Semantic cache Avoids recomputing similar responses Risk of a stale response
Model routing Uses a smaller model when possible Routing can err
Selective reranking Improves quality where it matters Additional cost
Streaming Improves latency perception Does not reduce total cost
Batch API −50% on token prices across the three large providers (checked on 2026-10-25); may combine with prompt caching, check per provider Completion window of up to 24 h; per-batch request and size limits; only for load that tolerates waiting
Context compaction Reduces tokens May lose evidence
Tool result compression Reduces context May hide details
Early exit Stops when confidence is high May stop too early

📚 References