# How do I use caching to cut the energy of LLM calls?

> Two kinds of caching that cut LLM work: provider prompt caching for repeated context, and your own cache so identical questions aren't answered twice.

Source: https://greenai.guide/how-do-i/cache-llm-calls/  
Updated: 2026-11-19

## In short

Use two layers. Provider prompt caching reuses the processing of a fixed prefix, such as a long system prompt or shared document, so put stable content first. Your own response cache stores answers to identical requests so the model is not called again. Both cut computation, cost and latency, as long as you set sensible expiry times.

## Steps

1. Put stable content, such as instructions and reference text, at the start of every prompt.
2. Turn on or mark prompt caching as your provider's documentation describes.
3. Cache full responses for identical inputs in your own application.
4. Set expiry times that match how often the underlying answer changes.
5. Log cache hit rates and input tokens so you can see the saving.

**The cheapest model call is the one you don't make, and the next cheapest reuses work already done.** Caching does
both.

## What is prompt caching?

**The provider stores the processed form of the start of your prompt and reuses it on later calls.** Anthropic's
documentation says prompt caching "significantly reduces processing time and costs" for prompts with consistent
elements, prices cache reads at a tenth of normal input tokens, and keeps the cache for five minutes by default.
OpenAI enables prompt caching by default for supported models. Both work only on an identical prefix, so order
matters: stable instructions and documents first, the changing question last.

## What is response caching?

**You store the model's answer and return it when the same request comes in again.** It suits FAQs, classification
of repeated items, and agents that re-ask identical questions. The Green Software Foundation's pattern on agent
orchestration recommends cutting redundant model calls and repeated computation in exactly this way.

Some teams also use "semantic" caches that match similar rather than identical questions. These save more but can
return a wrong answer for a subtly different question, so test them carefully.

## Common mistakes

- **Putting timestamps or user names at the top** of the prompt, which breaks the prefix and the cache.
- **Caching for ever.** Set an expiry that fits how fast the answer goes stale.
- **Not measuring.** Without hit rates you won't know whether the cache helps.

For the wider idea of reusing rather than regenerating, read
[orchestration over generation](/articles/orchestration-over-generation/).

## Sources

- [Prompt caching](https://platform.claude.com/docs/en/build-with-claude/prompt-caching), Anthropic, Claude platform documentation (2026)
- [Prompt caching](https://developers.openai.com/api/docs/guides/prompt-caching), OpenAI API documentation (2026)
- [Optimize agent orchestration to reduce unnecessary model calls](https://github.com/Green-Software-Foundation/patterns/blob/main/docs/development/optimize-agent-orchestration-reduce-model-calls.md), Green Software Foundation, Green Software Patterns (2025)
