flâneur — a map of the web's best reading

Prompt caching - Anthropic

docs.anthropic.com · 12 words · saved by 1 readers

Prompt caching is a powerful feature that optimizes your API usage by allowing resuming from specific prefixes in your prompts. This approach significantly reduces processing time and costs for repetitive tasks or prompts with consistent elements. Here’s an example of how to implement prompt caching with the Messages API using a cache_control block: In this example, the entire text of “Pride and Prejudice” is cached using the cache_control parameter. This enables reuse of this large text across multiple API calls without reprocessing it each time. Changing only the user message allows you to ask various questions about the book while utilizing the cached content, leading to faster responses and improved efficiency. When you send a request with prompt caching enabled: This is especially useful for: By default, the cache has a 5-minute lifetime. The cache is refreshed for no additional cost each time the cached content is used. Prompt caching caches the full prefix Prompt caching referen

Loading... Loading... Loading... Loading... Loading... Loading... Loading... Loading... Loading... Loading... Loading... Loading...

Explore this link on the map →

related reading