Cut LLM API cost and latency with caching and batching
8 steps · about 2 h · Intermediate
- Know what you pay for: input, output and cached tokens (reference, Claude Docs, 10 min)
Lists per-token prices and the discounts for cache reads and batch jobs.
- Count tokens before you send a request (reference, Claude Docs, 10 min)
Estimate cost and stay under limits without making the call.
- See how much prompt caching saves (article, Anthropic, 10 min)
Gives measured cost and latency cuts for long, repeated prompts.
- Mark reusable prompt prefixes for caching (reference, Claude Docs, 25 min)
Where to put cache breakpoints, cache lifetime and how to read cache hits.
- Compare explicit and implicit context caching (reference, Google AI for Developers, 15 min)
A second provider's take on reusing long context across calls.
- Send non-urgent work as a discounted batch (reference, Claude Docs, 20 min)
Submit many requests at once and collect results later at lower cost.
- Stream tokens so users see answers sooner (reference, Claude Docs, 15 min)
Cuts perceived latency by showing output as it is generated.
- Reuse shared prefixes on a self-hosted server (reference, vLLM, 15 min)
The same caching idea applied to your own vLLM deployment.