anthropic ยท Anthropic Claude Docs
Claude Prompt caching
Teaches how to implement prompt caching using both automatic caching for multi-turn conversations and explicit cache breakpoints for fine-grained control over specific content blocks.
Derived skill
Files assembled from official documentation
Viewing SKILL.md
Claude Prompt caching
Teaches how to implement prompt caching using both automatic caching for multi-turn conversations and explicit cache breakpoints for fine-grained control over specific content blocks.
When To Use
Use when you need to reduce latency and token costs for repetitive prompts, large context windows, or long multi-turn conversations by reusing previously processed prompt prefixes.
Reference Files
| File | Contains | Use For |
|---|---|---|
SKILL.md | Entry point: scope, routing table, and workflow. | Start here. |
docs/claude-prompt-caching-workflow-guide.md | A guide explaining how prompt caching works, supported models, and the mechanics of automatic caching in multi-turn conversations. | Questions about a guide explaining how prompt caching works, supported models, and the mechanics of automatic caching in multi-turn c... |
examples/claude-prompt-caching-anthropic-claude-prompt-caching-curl-request.bash | A curl command demonstrating how to implement prompt caching using the anthropic-version 2023-06-01 API. | Exact payloads, commands, or snippets shown in A curl command demonstrating how to implement prompt caching using the anthropic-version 2023-06-01 API. |
examples/claude-prompt-caching-bash-usage.bash | A bash script demonstrating how to use the transform usage flag to inspect prompt caching metadata in an Anthropic API request. | Exact payloads, commands, or snippets shown in A bash script demonstrating how to use the transform usage flag to inspect prompt caching metadata in an Anthropic AP... |
examples/claude-prompt-caching-anthropic-claude-prompt-caching.python | A Python script demonstrating how to implement ephemeral prompt caching using the Anthropic client to optimize message creation. | Exact payloads, commands, or snippets shown in A Python script demonstrating how to implement ephemeral prompt caching using the Anthropic client to optimize messag... |
examples/claude-prompt-caching-anthropic-claude-prompt-caching.typescript | A TypeScript code example demonstrating how to implement ephemeral prompt caching using the Anthropic SDK. | Exact payloads, commands, or snippets shown in A TypeScript code example demonstrating how to implement ephemeral prompt caching using the Anthropic SDK. |
examples/claude-prompt-caching.csharp | A C# code example demonstrating how to implement ephemeral cache control within a Claude message request using the Anthropic client library. | Exact payloads, commands, or snippets shown in A C# code example demonstrating how to implement ephemeral cache control within a Claude message request using the An... |
examples/claude-prompt-caching-anthropic-claude-prompt-caching.go | A Go implementation demonstrating how to use ephemeral cache control parameters with the Anthropic SDK to cache prompt content. | Exact payloads, commands, or snippets shown in A Go implementation demonstrating how to use ephemeral cache control parameters with the Anthropic SDK to cache promp... |
examples/claude-prompt-caching.java | A Java implementation demonstrating how to use the Anthropic client to apply ephemeral cache control to a message request. | Exact payloads, commands, or snippets shown in A Java implementation demonstrating how to use the Anthropic client to apply ephemeral cache control to a message req... |
examples/claude-prompt-caching-anthropic-claude-prompt-caching.php | A PHP code example demonstrating how to implement ephemeral prompt caching using the Anthropic client library. | Exact payloads, commands, or snippets shown in A PHP code example demonstrating how to implement ephemeral prompt caching using the Anthropic client library. |
examples/claude-prompt-caching-anthropic-claude-prompt-caching.ruby | A Ruby script demonstrating how to implement ephemeral prompt caching using the Anthropic client library. | Exact payloads, commands, or snippets shown in A Ruby script demonstrating how to implement ephemeral prompt caching using the Anthropic client library. |
examples/claude-prompt-caching-anthropic-claude-prompt-caching-curl-request-2.bash | A curl command demonstrating how to implement prompt caching using the Anthropic Messages API. | Exact payloads, commands, or snippets shown in A curl command demonstrating how to implement prompt caching using the Anthropic Messages API. |
examples/claude-prompt-caching-anthropic-cli-usage.bash | A bash command demonstrating how to use the Anthropic CLI to create messages with ephemeral prompt caching enabled. | Exact payloads, commands, or snippets shown in A bash command demonstrating how to use the Anthropic CLI to create messages with ephemeral prompt caching enabled. |
examples/claude-prompt-caching-python-messages-api.python | A Python code example demonstrating how to implement prompt caching using the Anthropic Messages API with the cache_control parameter. | Exact payloads, commands, or snippets shown in A Python code example demonstrating how to implement prompt caching using the Anthropic Messages API with the cacheco... |
examples/claude-prompt-caching-anthropic-claude-prompt-caching-2.typescript | A TypeScript code example demonstrating how to implement ephemeral prompt caching using the Anthropic SDK. | Exact payloads, commands, or snippets shown in A TypeScript code example demonstrating how to implement ephemeral prompt caching using the Anthropic SDK. |
examples/claude-prompt-caching-2.csharp | A C# code example demonstrating how to implement ephemeral prompt caching using the Anthropic client library. | Exact payloads, commands, or snippets shown in A C# code example demonstrating how to implement ephemeral prompt caching using the Anthropic client library. |
examples/claude-prompt-caching-anthropic-claude-prompt-caching-2.go | A Go implementation demonstrating how to use ephemeral cache control parameters with the Anthropic SDK to implement prompt caching. | Exact payloads, commands, or snippets shown in A Go implementation demonstrating how to use ephemeral cache control parameters with the Anthropic SDK to implement p... |
examples/claude-prompt-caching-java-automatic-caching.java | A Java code example demonstrating how to implement automatic prompt caching using the Anthropic client library. | Exact payloads, commands, or snippets shown in A Java code example demonstrating how to implement automatic prompt caching using the Anthropic client library. |
examples/claude-prompt-caching.php | A PHP code example demonstrating how to implement prompt caching using the Anthropic client library. | Exact payloads, commands, or snippets shown in A PHP code example demonstrating how to implement prompt caching using the Anthropic client library. |
examples/claude-prompt-caching-anthropic-claude-prompt-caching-2.ruby | A Ruby script demonstrating how to implement ephemeral prompt caching using the Anthropic client library. | Exact payloads, commands, or snippets shown in A Ruby script demonstrating how to implement ephemeral prompt caching using the Anthropic client library. |
examples/claude-prompt-caching-json-cache-control-structure.json | A JSON object demonstrating the cache_control property with ephemeral type and TTL settings for Claude prompt caching. | Exact payloads, commands, or snippets shown in A JSON object demonstrating the cachecontrol property with ephemeral type and TTL settings for Claude prompt caching. |
examples/claude-prompt-caching-json-request.json | A JSON request body demonstrating the use of ephemeral cache control for system prompts and messages in the Anthropic API. | Exact payloads, commands, or snippets shown in A JSON request body demonstrating the use of ephemeral cache control for system prompts and messages in the Anthropic... |
examples/claude-prompt-caching-token-calculation-formula.text | A text representation of the mathematical formula used to calculate total input tokens when using prompt caching. | Exact payloads, commands, or snippets shown in A text representation of the mathematical formula used to calculate total input tokens when using prompt caching. |
examples/claude-prompt-caching-anthropic-claude-prompt-caching-request-sequence.text | A text-based sequence of user and assistant messages demonstrating how to apply cache breakpoints to request content in Claude API calls. | Exact payloads, commands, or snippets shown in A text-based sequence of user and assistant messages demonstrating how to apply cache breakpoints to request content... |
examples/claude-prompt-caching-json-cache-control.json | A JSON object demonstrating the cache_control parameter with ephemeral type and TTL settings for Claude prompt caching. | Exact payloads, commands, or snippets shown in A JSON object demonstrating the cachecontrol parameter with ephemeral type and TTL settings for Claude prompt caching. |
examples/claude-prompt-caching-usage-metrics.json | A JSON object displaying token usage metrics including cache read, cache creation, and ephemeral cache statistics for Claude prompt caching. | Exact payloads, commands, or snippets shown in A JSON object displaying token usage metrics including cache read, cache creation, and ephemeral cache statistics for... |
examples/claude-prompt-caching-anthropic-claude-messages-api-prompt-caching-curl.bash | A curl command demonstrating how to implement prompt caching using the Anthropic Messages API. | Exact payloads, commands, or snippets shown in A curl command demonstrating how to implement prompt caching using the Anthropic Messages API. |
examples/claude-prompt-caching-anthropic-cli-warmup.bash | A bash command demonstrating how to use the Anthropic CLI to create a message with ephemeral prompt caching enabled for a system prompt. | Exact payloads, commands, or snippets shown in A bash command demonstrating how to use the Anthropic CLI to create a message with ephemeral prompt caching enabled f... |
examples/claude-prompt-caching-python-prewarm.python | A Python script demonstrating how to prewarm the Claude system prompt cache using the Anthropic client. | Exact payloads, commands, or snippets shown in A Python script demonstrating how to prewarm the Claude system prompt cache using the Anthropic client. |
examples/claude-prompt-caching-anthropic-claude-prompt-caching-3.typescript | A TypeScript code example demonstrating how to implement ephemeral prompt caching using the Anthropic SDK. | Exact payloads, commands, or snippets shown in A TypeScript code example demonstrating how to implement ephemeral prompt caching using the Anthropic SDK. |
examples/claude-prompt-caching-3.csharp | A C# code example demonstrating how to implement prompt caching using the Anthropic client library. | Exact payloads, commands, or snippets shown in A C# code example demonstrating how to implement prompt caching using the Anthropic client library. |
examples/claude-prompt-caching-anthropic-claude-prompt-caching-3.go | A Go implementation demonstrating how to use the Anthropic SDK to implement prompt caching for Claude models. | Exact payloads, commands, or snippets shown in A Go implementation demonstrating how to use the Anthropic SDK to implement prompt caching for Claude models. |
examples/claude-prompt-caching-java-message-prewarm.java | A Java code example demonstrating how to prewarm the prompt cache by creating a message with cache control parameters using the Anthropic client. | Exact payloads, commands, or snippets shown in A Java code example demonstrating how to prewarm the prompt cache by creating a message with cache control parameters... |
examples/claude-prompt-caching-php-client.php | A PHP code example demonstrating how to implement prompt caching using the Anthropic client library. | Exact payloads, commands, or snippets shown in A PHP code example demonstrating how to implement prompt caching using the Anthropic client library. |
examples/claude-prompt-caching-anthropic-claude-prompt-caching-3.ruby | A Ruby script demonstrating how to implement prompt caching using the Anthropic client library. | Exact payloads, commands, or snippets shown in A Ruby script demonstrating how to implement prompt caching using the Anthropic client library. |
examples/claude-prompt-caching-usage-response.json | A JSON response object demonstrating the usage metadata for cache creation and cache read tokens in a Claude API call. | Exact payloads, commands, or snippets shown in A JSON response object demonstrating the usage metadata for cache creation and cache read tokens in a Claude API call. |
examples/claude-prompt-caching-python-implementation.python | A Python script demonstrating how to implement prompt caching using the Anthropic SDK by applying cache_control to a system prompt. | Exact payloads, commands, or snippets shown in A Python script demonstrating how to implement prompt caching using the Anthropic SDK by applying cachecontrol to a s... |
examples/claude-prompt-caching-anthropic-claude-messages-api-prompt-caching-curl-2.bash | A curl command demonstrating how to implement prompt caching using the Anthropic Messages API. | Exact payloads, commands, or snippets shown in A curl command demonstrating how to implement prompt caching using the Anthropic Messages API. |
examples/claude-prompt-caching-anthropic-cli.bash | A bash script demonstrating how to use the Anthropic CLI to create a message with ephemeral prompt caching for a large legal document. | Exact payloads, commands, or snippets shown in A bash script demonstrating how to use the Anthropic CLI to create a message with ephemeral prompt caching for a larg... |
examples/claude-prompt-caching.python | A Python code example demonstrating how to implement prompt caching using the Anthropic client for long context documents. | Exact payloads, commands, or snippets shown in A Python code example demonstrating how to implement prompt caching using the Anthropic client for long context docum... |
examples/claude-prompt-caching-anthropic-claude-prompt-caching-4.typescript | A TypeScript code example demonstrating how to implement prompt caching using the Anthropic SDK by adding cache_control metadata to system and user messages. | Exact payloads, commands, or snippets shown in A TypeScript code example demonstrating how to implement prompt caching using the Anthropic SDK by adding cachecontro... |
examples/claude-prompt-caching-4.csharp | A C# code example demonstrating how to implement prompt caching using the Anthropic client library. | Exact payloads, commands, or snippets shown in A C# code example demonstrating how to implement prompt caching using the Anthropic client library. |
examples/claude-prompt-caching.go | A Go implementation demonstrating how to use prompt caching with the Anthropic SDK. | Exact payloads, commands, or snippets shown in A Go implementation demonstrating how to use prompt caching with the Anthropic SDK. |
examples/claude-prompt-caching-java-legal-document-analysis.java | A Java implementation demonstrating how to use prompt caching for analyzing legal documents using the Anthropic client. | Exact payloads, commands, or snippets shown in A Java implementation demonstrating how to use prompt caching for analyzing legal documents using the Anthropic client. |
examples/claude-prompt-caching-2.php | A PHP code example demonstrating how to implement prompt caching using the Anthropic client library. | Exact payloads, commands, or snippets shown in A PHP code example demonstrating how to implement prompt caching using the Anthropic client library. |
examples/claude-prompt-caching-anthropic-claude-prompt-caching-4.ruby | A Ruby script demonstrating how to implement prompt caching using the Anthropic client library. | Exact payloads, commands, or snippets shown in A Ruby script demonstrating how to implement prompt caching using the Anthropic client library. |
examples/claude-prompt-caching-anthropic-claude-prompt-caching.json | A JSON object demonstrating the structure for implementing prompt caching with Claude models, including tool definitions and model parameters. | Exact payloads, commands, or snippets shown in A JSON object demonstrating the structure for implementing prompt caching with Claude models, including tool definiti... |
examples/claude-prompt-caching-anthropic-claude-prompt-caching-curl-request-3.bash | A curl command demonstrating how to implement ephemeral prompt caching in a Claude API messages request. | Exact payloads, commands, or snippets shown in A curl command demonstrating how to implement ephemeral prompt caching in a Claude API messages request. |
examples/claude-prompt-caching-anthropic-cli-2.bash | A bash script demonstrating how to use the Anthropic CLI to create a message with ephemeral prompt caching enabled for a long system prompt. | Exact payloads, commands, or snippets shown in A bash script demonstrating how to use the Anthropic CLI to create a message with ephemeral prompt caching enabled fo... |
examples/claude-prompt-caching-2.python | A Python script demonstrating how to implement ephemeral prompt caching using the Anthropic client for long system prompts and conversation history. | Exact payloads, commands, or snippets shown in A Python script demonstrating how to implement ephemeral prompt caching using the Anthropic client for long system pr... |
examples/claude-prompt-caching-anthropic-claude-prompt-caching-5.typescript | A TypeScript code example demonstrating how to implement ephemeral prompt caching using the Anthropic SDK. | Exact payloads, commands, or snippets shown in A TypeScript code example demonstrating how to implement ephemeral prompt caching using the Anthropic SDK. |
examples/claude-prompt-caching-anthropic-claude-prompt-caching.csharp | A C# code example demonstrating how to implement ephemeral prompt caching using the Anthropic client library. | Exact payloads, commands, or snippets shown in A C# code example demonstrating how to implement ephemeral prompt caching using the Anthropic client library. |
examples/claude-prompt-caching-anthropic-claude-prompt-caching-4.go | A Go implementation demonstrating how to apply cache control breakpoints to a system prompt using the Anthropic SDK. | Exact payloads, commands, or snippets shown in A Go implementation demonstrating how to apply cache control breakpoints to a system prompt using the Anthropic SDK. |
examples/claude-prompt-caching-anthropic-claude-prompt-caching-java-conversation.java | A Java implementation demonstrating how to use ephemeral cache control within a conversation using the Anthropic client. | Exact payloads, commands, or snippets shown in A Java implementation demonstrating how to use ephemeral cache control within a conversation using the Anthropic client. |
examples/claude-prompt-caching-anthropic-claude-prompt-caching-2.php | A PHP code example demonstrating how to implement prompt caching using the Anthropic client library. | Exact payloads, commands, or snippets shown in A PHP code example demonstrating how to implement prompt caching using the Anthropic client library. |
examples/claude-prompt-caching-anthropic-claude-prompt-caching-5.ruby | A Ruby script demonstrating how to implement ephemeral prompt caching using the Anthropic client library. | Exact payloads, commands, or snippets shown in A Ruby script demonstrating how to implement ephemeral prompt caching using the Anthropic client library. |
examples/claude-prompt-caching-anthropic-claude-prompt-caching-curl-request-4.bash | A curl command demonstrating how to implement prompt caching in an Anthropic Messages API request. | Exact payloads, commands, or snippets shown in A curl command demonstrating how to implement prompt caching in an Anthropic Messages API request. |
examples/claude-prompt-caching-bash-messages-create.bash | A bash script demonstrating how to use the Anthropic messages API to create a message with prompt caching enabled. | Exact payloads, commands, or snippets shown in A bash script demonstrating how to use the Anthropic messages API to create a message with prompt caching enabled. |
examples/claude-prompt-caching-anthropic-claude-prompt-caching-2.python | A Python script demonstrating how to implement prompt caching using the Anthropic client to optimize message creation. | Exact payloads, commands, or snippets shown in A Python script demonstrating how to implement prompt caching using the Anthropic client to optimize message creation. |
examples/claude-prompt-caching-anthropic-claude-prompt-caching-6.typescript | A TypeScript code example demonstrating how to implement prompt caching using the Anthropic SDK. | Exact payloads, commands, or snippets shown in A TypeScript code example demonstrating how to implement prompt caching using the Anthropic SDK. |
examples/claude-prompt-caching-5.csharp | A C# code example demonstrating how to implement prompt caching using the Anthropic client library. | Exact payloads, commands, or snippets shown in A C# code example demonstrating how to implement prompt caching using the Anthropic client library. |
examples/claude-prompt-caching-2.go | A Go implementation demonstrating how to use prompt caching with the Anthropic SDK. | Exact payloads, commands, or snippets shown in A Go implementation demonstrating how to use prompt caching with the Anthropic SDK. |
examples/claude-prompt-caching-anthropic-claude-docs-prompt-caching-multiple-brea.java | A Java implementation demonstrating how to use multiple cache breakpoints within a single Claude API request. | Exact payloads, commands, or snippets shown in A Java implementation demonstrating how to use multiple cache breakpoints within a single Claude API request. |
examples/claude-prompt-caching-anthropic-claude-prompt-caching-3.php | A PHP script demonstrating how to implement prompt caching using the Anthropic client library. | Exact payloads, commands, or snippets shown in A PHP script demonstrating how to implement prompt caching using the Anthropic client library. |
examples/claude-prompt-caching-anthropic-claude-prompt-caching-6.ruby | A Ruby code example demonstrating how to implement prompt caching using the Anthropic client library. | Exact payloads, commands, or snippets shown in A Ruby code example demonstrating how to implement prompt caching using the Anthropic client library. |
examples/claude-prompt-caching-anthropic-claude-prompt-caching-3.python | A Python code example demonstrating how to implement prompt caching using the Anthropic client beta messages creation method. | Exact payloads, commands, or snippets shown in A Python code example demonstrating how to implement prompt caching using the Anthropic client beta messages creation... |
examples/claude-prompt-caching-anthropic-claude-prompt-caching-7.typescript | A TypeScript code example demonstrating how to implement prompt caching using the Anthropic SDK by adding cache_control to the system prompt. | Exact payloads, commands, or snippets shown in A TypeScript code example demonstrating how to implement prompt caching using the Anthropic SDK by adding cachecontro... |
examples/claude-prompt-caching-anthropic-claude-prompt-caching-4.php | A PHP script demonstrating how to implement prompt caching using the Anthropic client library. | Exact payloads, commands, or snippets shown in A PHP script demonstrating how to implement prompt caching using the Anthropic client library. |
examples/claude-prompt-caching-anthropic-claude-prompt-caching-7.ruby | A Ruby script demonstrating how to implement prompt caching using the Anthropic client library. | Exact payloads, commands, or snippets shown in A Ruby script demonstrating how to implement prompt caching using the Anthropic client library. |
examples/claude-prompt-caching-anthropic-claude-prompt-caching-4.python | A Python code example demonstrating how to implement prompt caching using the Anthropic Claude API. | Exact payloads, commands, or snippets shown in A Python code example demonstrating how to implement prompt caching using the Anthropic Claude API. |
examples/claude-prompt-caching-anthropic-claude-prompt-caching-8.typescript | A TypeScript code example demonstrating how to implement ephemeral prompt caching using the Anthropic SDK. | Exact payloads, commands, or snippets shown in A TypeScript code example demonstrating how to implement ephemeral prompt caching using the Anthropic SDK. |
examples/claude-prompt-caching-3.php | A PHP script demonstrating how to implement ephemeral prompt caching using the Anthropic client library. | Exact payloads, commands, or snippets shown in A PHP script demonstrating how to implement ephemeral prompt caching using the Anthropic client library. |
examples/claude-prompt-caching-anthropic-claude-prompt-caching-8.ruby | A Ruby script demonstrating how to implement ephemeral prompt caching using the Anthropic client library. | Exact payloads, commands, or snippets shown in A Ruby script demonstrating how to implement ephemeral prompt caching using the Anthropic client library. |
examples/claude-prompt-caching-anthropic-claude-docs-typescript-prompt-caching-me.typescript | A TypeScript code example demonstrating how to use the client.beta.promptCaching.messages.create method to implement prompt caching. | Exact payloads, commands, or snippets shown in A TypeScript code example demonstrating how to use the client.beta.promptCaching.messages.create method to implement... |
examples/claude-prompt-caching-anthropic-claude-prompt-caching-9.typescript | A TypeScript code example demonstrating how to implement prompt caching using the Anthropic Claude API client. | Exact payloads, commands, or snippets shown in A TypeScript code example demonstrating how to implement prompt caching using the Anthropic Claude API client. |
What This Skill Covers
- When you send a request with prompt caching enabled:
- Main sections:
How prompt caching works,Supported models,Automatic caching,How automatic caching works in multi-turn conversations,TTL support.
Workflow
- Open the most relevant file under
docs/for the exact documented workflow and wording. - Open
schemas/files for exact structured contracts. - Open
examples/files for concrete requests, commands, snippets, and manifests. - Do not add behavior or configuration that is not present in the attached source files.
Canonical source: https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching
