Prompt Buddy logoPrompt Buddy

google · Google AI Docs

Google AI API Caching

Explains how to use context caching to save and reuse precomputed input tokens for repeated queries against the same media or large datasets to reduce latency and costs.

Import to Prompt Buddy

Derived skill

Files assembled from official documentation

Viewing SKILL.md

Google AI API Caching

Explains how to use context caching to save and reuse precomputed input tokens for repeated queries against the same media or large datasets to reduce latency and costs.

When To Use

Use when you need to reduce costs and latency when performing multiple different queries against the same large media file or extensive context window.

Reference Files

FileContainsUse For
SKILL.mdEntry point: scope, routing table, and workflow.Start here.
docs/google-ai-api-caching-workflow-guide.mdAn example request body and endpoint details for creating a cached content resource using the Google AI API.Questions about an example request body and endpoint details for creating a cached content resource using the Google AI API.
examples/google-ai-api-caching-google-ai-api-python-context-caching.textA Python code snippet demonstrating how to upload a file and create a cached content object using the Google GenAI SDK.Exact payloads, commands, or snippets shown in A Python code snippet demonstrating how to upload a file and create a cached content object using the Google GenAI SDK.
examples/google-ai-api-caching-google-ai-api-context-caching-nodejs.textA Node.js code example demonstrating how to upload a file and create a context cache using the Google AI SDK.Exact payloads, commands, or snippets shown in A Node.js code example demonstrating how to upload a file and create a context cache using the Google AI SDK.
examples/google-ai-api-caching-go-context-client-setup.textA Go code snippet demonstrating how to initialize a Gemini API client and prepare a context for content caching operations.Exact payloads, commands, or snippets shown in A Go code snippet demonstrating how to initialize a Gemini API client and prepare a context for content caching opera...
examples/google-ai-api-caching-context-caching-request-json.textA JSON request body demonstrating how to create a context cache for a Gemini model using inlined text data and system instructions.Exact payloads, commands, or snippets shown in A JSON request body demonstrating how to create a context cache for a Gemini model using inlined text data and system...
examples/google-ai-api-caching-google-ai-api-python-context-caching-2.textA Python code example demonstrating how to upload a file and create a cached content object using the Google GenAI SDK.Exact payloads, commands, or snippets shown in A Python code example demonstrating how to upload a file and create a cached content object using the Google GenAI SDK.
examples/google-ai-api-caching-nodejs-upload.textA Node.js code example demonstrating how to upload a file to the Google AI API to prepare for context caching.Exact payloads, commands, or snippets shown in A Node.js code example demonstrating how to upload a file to the Google AI API to prepare for context caching.
examples/google-ai-api-caching-go-context-client-initialization.textA Go code snippet demonstrating how to initialize a Gemini API client and prepare a context for content caching operations.Exact payloads, commands, or snippets shown in A Go code snippet demonstrating how to initialize a Gemini API client and prepare a context for content caching opera...
examples/google-ai-api-caching-python-client-setup.textA Python code example demonstrating how to initialize a GenAI client and create a chat session with system instructions for context caching.Exact payloads, commands, or snippets shown in A Python code example demonstrating how to initialize a GenAI client and create a chat session with system instructio...
examples/google-ai-api-caching-nodejs-context-caching.textA Node.js code example demonstrating how to implement context caching using the Google Generative AI SDK.Exact payloads, commands, or snippets shown in A Node.js code example demonstrating how to implement context caching using the Google Generative AI SDK.
examples/google-ai-api-caching-go-context-client-initialization-2.textA Go code snippet demonstrating how to initialize a Gemini API client with context and system instructions for content caching.Exact payloads, commands, or snippets shown in A Go code snippet demonstrating how to initialize a Gemini API client with context and system instructions for conten...
examples/google-ai-api-caching-python-client-create-cache.textA Python script demonstrating how to upload a file and create a context cache using the Google GenAI client.Exact payloads, commands, or snippets shown in A Python script demonstrating how to upload a file and create a context cache using the Google GenAI client.
examples/google-ai-api-caching-nodejs-upload-2.textA Node.js code example demonstrating how to upload a file using the Google AI SDK to prepare for context caching.Exact payloads, commands, or snippets shown in A Node.js code example demonstrating how to upload a file using the Google AI SDK to prepare for context caching.
examples/google-ai-api-caching-go-context-client-initialization-3.textA Go code snippet demonstrating how to initialize a Gemini API client and prepare a context for content caching operations.Exact payloads, commands, or snippets shown in A Go code snippet demonstrating how to initialize a Gemini API client and prepare a context for content caching opera...
examples/google-ai-api-caching-curl-request.textA curl command used to retrieve information about a specific Google AI API cache resource.Exact payloads, commands, or snippets shown in A curl command used to retrieve information about a specific Google AI API cache resource.
examples/google-ai-api-caching-google-ai-api-python-context-caching-3.textA Python code snippet demonstrating how to upload a file and create a context cache using the Google GenAI SDK.Exact payloads, commands, or snippets shown in A Python code snippet demonstrating how to upload a file and create a context cache using the Google GenAI SDK.
examples/google-ai-api-caching-nodejs-upload-3.textA Node.js code example demonstrating how to upload a file to the Google AI API for use with context caching.Exact payloads, commands, or snippets shown in A Node.js code example demonstrating how to upload a file to the Google AI API for use with context caching.
examples/google-ai-api-caching-go-context-setup.textA Go code snippet demonstrating client initialization and context setup for using the Google AI API caching feature.Exact payloads, commands, or snippets shown in A Go code snippet demonstrating client initialization and context setup for using the Google AI API caching feature.
examples/google-ai-api-caching-update-ttl-curl.textA curl command demonstrating how to update the time-to-live (TTL) setting for an existing Google AI API cache.Exact payloads, commands, or snippets shown in A curl command demonstrating how to update the time-to-live (TTL) setting for an existing Google AI API cache.
examples/google-ai-api-caching-python-create-delete-cache.textA Python script demonstrating how to upload a file, create a context cache with system instructions, and subsequently delete the cache using the Google GenAI SDK.Exact payloads, commands, or snippets shown in A Python script demonstrating how to upload a file, create a context cache with system instructions, and subsequently...
examples/google-ai-api-caching-nodejs-upload-4.textA Node.js code example demonstrating how to upload a file to the Google AI API for use with context caching.Exact payloads, commands, or snippets shown in A Node.js code example demonstrating how to upload a file to the Google AI API for use with context caching.
examples/google-ai-api-caching-delete-cache-curl.textA shell script using curl to delete a specific context cache from the Google AI API.Exact payloads, commands, or snippets shown in A shell script using curl to delete a specific context cache from the Google AI API.
examples/google-ai-api-caching-json.textA JSON schema object demonstrating the structure for Google AI API caching configurations.Exact payloads, commands, or snippets shown in A JSON schema object demonstrating the structure for Google AI API caching configurations.

What This Skill Covers

  • Context caching allows you to save and reuse precomputed input tokens that you wish to use repeatedly, for example when asking different questions about the...
  • Main sections: Method: cachedContents.create, Endpoint, Request body, Example request, Basic.

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://ai.google.dev/api/caching