Declaring a prompt cache breakpoint with the Anthropic SDK

CCDV-F Model Selection & Optimization Medium Question 104 of 105

A developer sends a 12,000-token API documentation reference on every request and wants to cache it with the Anthropic SDK.

How is the cache breakpoint declared in the request?

Show answer and explanation

CAttach a cache_control block of type ephemeral to that content block

Caching is requested by attaching cache_control with type ephemeral to a content block in tools, system or messages, up to four breakpoints per request. An HTTP Cache-Control header governs intermediary caching of the HTTP response and never reaches the tokenized prefix. The request-level control that does exist is a top-level cache_control field for automatic caching, not a cache boolean, so that option's name and shape are not real. And the Files API avoids re-uploading bytes, but the tokens are still processed on every request unless a breakpoint marks them.

Source: platform.claude.com/docs/en/build-with-claude/prompt-caching

Anonymous, no account needed. Your tally stays in this browser.

Next question Start 5 timed questions Browse all 105 original CCDV-F practice questions