Prompt Buddy logoPrompt Buddy

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.

Import to Prompt Buddy

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

FileContainsUse For
SKILL.mdEntry point: scope, routing table, and workflow.Start here.
docs/claude-prompt-caching-workflow-guide.mdA 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.bashA 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.bashA 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.pythonA 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.typescriptA 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.csharpA 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.goA 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.javaA 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.phpA 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.rubyA 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.bashA 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.bashA 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.pythonA 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.typescriptA 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.csharpA 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.goA 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.javaA 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.phpA 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.rubyA 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.jsonA 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.jsonA 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.textA 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.textA 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.jsonA 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.jsonA 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.bashA 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.bashA 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.pythonA 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.typescriptA 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.csharpA 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.goA 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.javaA 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.phpA 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.rubyA 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.jsonA 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.pythonA 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.bashA 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.bashA 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.pythonA 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.typescriptA 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.csharpA 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.goA 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.javaA 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.phpA 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.rubyA 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.jsonA 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.bashA 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.bashA 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.pythonA 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.typescriptA 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.csharpA 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.goA 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.javaA 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.phpA 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.rubyA 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.bashA 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.bashA 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.pythonA 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.typescriptA 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.csharpA 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.goA 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.javaA 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.phpA 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.rubyA 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.pythonA 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.typescriptA 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.phpA 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.rubyA 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.pythonA 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.typescriptA 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.phpA 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.rubyA 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.typescriptA 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.typescriptA 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

  1. Open the most relevant file under docs/ for the exact documented workflow and wording.
  2. Open schemas/ files for exact structured contracts.
  3. Open examples/ files for concrete requests, commands, snippets, and manifests.
  4. 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