Skip to main content
Prompt caching can help reducing processing time and costs. Consider it if you are using the same prompt multiple times in any flow. You can read more about prompt caching with Anthropic models here.

Usage

To use prompt caching in your Agno setup, pass the cache_system_prompt argument when initializing the Claude model:
Notice that for prompt caching to work, the prompt needs to be of a certain length. You can read more about this on Anthropic’s docs.

Extended cache

You can also use Anthropic’s extended cache beta feature. This updates the cache duration from 5 minutes to 1 hour. To activate it, pass the extended_cache_time argument and the following beta header:

Working example

cookbook/11_models/anthropic/prompt_caching_extended.py