Skip to main content

Module anthropic_cache

Module anthropic_cache 

Source
Expand description

Prompt caching strategy for the Anthropic Messages API.

Anthropic’s prompt caching allows reuse of previously processed prompt prefixes, reducing latency and cost. This module provides a configurable strategy that annotates request components with cache_control markers.

Cache breakpoints are placed on:

  • The last system prompt block (stable across turns)
  • The last tool definition (stable across turns)
  • Recent conversation turns (sliding window)

Structs§

CacheStrategy
Configuration for Anthropic prompt caching behavior.