Quick Start
1
Simple Enable
Enable caching with defaults:
2
With Configuration
Configure caching behavior:
Configuration Options
What gets cached
- System block: instructions, tools, and memory prelude
- Stable conversation-history prefix (Anthropic only) — the two most recent messages stay uncached
Common Patterns
Pattern 1: Full Caching
Pattern 2: Auto-Detection with Memory
Even without explicitprompt_caching=True, the SDK auto-detects model support and arranges the prefix accordingly:
Pattern 3: Disable Caching
Best Practices
Enable Prompt Caching for Anthropic
Enable Prompt Caching for Anthropic
Anthropic Claude supports prompt caching for significant cost savings on repeated prompts.
Disable for Real-Time Data
Disable for Real-Time Data
Turn off caching when agents need fresh, real-time information.
Related
Performance
Performance optimization tips
ExecutionConfig
Execution limits configuration

