Method Signature
Parameters
string
required
The cached content resource name to retrieve.Format:
"cachedContents/abc123" or a full resource pathGetCachedContentConfig
Optional configuration for the request.Available options:
http_options: Custom HTTP request options
Returns
CachedContent
A CachedContent object containing:
name: The resource namemodel: The associated modeldisplay_name: Human-readable namecontents: The cached contentsystem_instruction: Cached system instructionstools: Cached tool configurationscreate_time: When the cache was createdupdate_time: Last update timestampexpire_time: When the cache will expireusage_metadata: Token count and usage information
Examples
Get Cache by Name
Check Cache Before Using
Inspect Cache Contents
Check System Instructions
Monitor Cache Usage
Get Multiple Caches
Async Get
Refresh Cache if Expiring Soon
Compare Cache Configurations
Extract Tools Configuration
Validate Cache Exists
Usage Metadata
The
usage_metadata field provides information about cached token counts:total_token_count: Total tokens in the cache
Error Handling
API Availability
This method is available in both Gemini API and Vertex AI.
Related Methods
- caches.create - Create a new cache
- caches.update - Update cache expiration
- caches.delete - Delete a cache
- caches.list - List all caches