Skip to main content

apply_cache_control

Function apply_cache_control 

Source
pub fn apply_cache_control(messages: &mut [Value], config: &PromptCacheConfig)
Expand description

Modify the message JSON to add cache_control markers according to config.

For Anthropic, this adds "cache_control": {"type": "ephemeral"} (or the 1h variant) to the last content block of cached messages. For OpenAI and None providers this is a no-op: OpenAI performs automatic prefix caching and needs no client-side markers.