How to Add Prompt Caching to an Anthropic SDK App and Measure the Hit Rate
Add prompt caching to a Python or TypeScript Anthropic SDK app, place cache_control breakpoints correctly, and read cache_read_input_tokens and cache_creation_input_tokens to compute a real hit rate. With pricing math for Claude Sonnet 4.6 and Opus 4.7.