Skip to content
masterclass Buddy

LangChain · Class

AnthropicPromptCachingMiddleware

AnthropicPromptCachingMiddleware caches reusable prompt prefixes for Anthropic models. It can reduce repeated processing, but it does not persist conversation history.

Last updated

Since
v1.6

Syntax

AnthropicPromptCachingMiddleware(type="ephemeral", ttl="5m", min_messages_to_cache=0, unsupported_model_behavior="warn")

In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.

Subscribe
  • ChatAnthropic
  • create_agent
  • MemorySaver
  • cache_control

Source: Anthropic middleware integration. Checked 2026-11-03.