> ## AI Agent Context > Get the complete documentation index at: https://aistudio.google.com/llms.txt > Use this file to discover all available pages. > For the full documentation in a single file, fetch: https://aistudio.google.com/llms-full.txt # Getting cached content {% mark class="http-get" %}{% icon name="south_west" /%}`GET`{% /mark %} `https://generativelanguage.googleapis.com/v1beta/cachedContents/{id}` Reads CachedContent resource. {% two-column-layout %} {% left-column %} ## Parameters {% class="hide-from-toc" id="parameters" %} {% section class="api-ref-property-list" %} **id**: {% mark %}required{% /mark %} `string` The cached content ID. Forms the resource name `cachedContents/{id}`. {% /section %} {% /left-column %} {% right-column class="sticky" %} **Example request** {% class="example-heading" %} {% tabs %} {% tab label="REST" %} ```sh curl "https://generativelanguage.googleapis.com/v1beta/$CACHE_NAME?key=$GEMINI_API_KEY" ``` {% /tab %} {% tab label="Python" %} ```python from google import genai client = genai.Client(http_options={"api_version": "v1beta"}) document = client.files.upload(file=media / "a11.txt") model_name = "gemini-3.8-flash" cache = client.caches.create( model=model_name, config={ "contents": [document], "system_instruction": "You are an expert analyzing transcripts.", }, ) print(client.caches.get(name=cache.name)) ``` {% /tab %} {% tab label="JavaScript" %} ```javascript // Make sure to include the following import: // import {GoogleGenAI} from '@google/genai'; const ai = new GoogleGenAI({ apiKey: process.env.GEMINI_API_KEY, apiVersion: 'v1beta', }); const filePath = path.join(media, 'a11.txt'); const document = await ai.files.upload({ file: filePath, config: {mimeType: 'text/plain'}, }); console.log('Uploaded file name:', document.name); const modelName = 'gemini-3.8-flash'; const contents = [ createUserContent(createPartFromUri(document.uri, document.mimeType)), ]; const cache = await ai.caches.create({ model: modelName, config: { contents: contents, systemInstruction: 'You are an expert analyzing transcripts.', }, }); const retrievedCache = await ai.caches.get({name: cache.name}); console.log('Retrieved Cache:', retrievedCache); ``` {% /tab %} {% tab label="Go" %} ```go ctx := context.Background() client, err := genai.NewClient(ctx, &genai.ClientConfig{ APIKey: os.Getenv("GEMINI_API_KEY"), Backend: genai.BackendGeminiAPI, HTTPOptions: genai.HTTPOptions{APIVersion: "v1beta"}, }) if err != nil { log.Fatal(err) } modelName := "gemini-3.8-flash" document, err := client.Files.UploadFromPath( ctx, filepath.Join(getMedia(), "a11.txt"), &genai.UploadFileConfig{ MIMEType: "text/plain", }, ) if err != nil { log.Fatal(err) } parts := []*genai.Part{ genai.NewPartFromURI(document.URI, document.MIMEType), } contents := []*genai.Content{ genai.NewContentFromParts(parts, genai.RoleUser), } cache, err := client.Caches.Create(ctx, modelName, &genai.CreateCachedContentConfig{ Contents: contents, SystemInstruction: genai.NewContentFromText( "You are an expert analyzing transcripts.", genai.RoleUser, ), }) if err != nil { log.Fatal(err) } cache, err = client.Caches.Get(ctx, cache.Name, &genai.GetCachedContentConfig{}) if err != nil { log.Fatal(err) } fmt.Println("Retrieved cache:") fmt.Println(cache) ``` {% /tab %} {% /tabs %} {% /right-column %} {% /two-column-layout %} ## Response {% class="hide-from-toc" id="response" %} {% section class="api-ref-property-list" %} **model**: {% mark %}required{% /mark %} `string` Immutable. The name of the `Model` to use for cached content Format: `models/{model}` {% hr /%} {% details %} {% summary %} **expiration**: `Union type` Specifies when this resource will expire. {% /summary %} Union field `expiration` can be only one of the following: **expireTime**: `string` Timestamp in UTC of when this resource is considered expired. This is *always* provided on output, regardless of what was sent on input. {% /details %} {% hr /%} **name**: `string` Output only. Identifier. The resource name referring to the cached content. Format: `cachedContents/{id}` {% hr /%} **displayName**: `string` Optional. Immutable. The user-generated meaningful display name of the cached content. Maximum 128 Unicode characters. {% hr /%} **createTime**: `string` Output only. Creation time of the cache entry. {% hr /%} **updateTime**: `string` Output only. When the cache entry was last updated in UTC time. {% hr /%} {% details %} {% summary %} **usageMetadata**: `CachedContentUsageMetadata` Output only. Metadata on the usage of the cached content. {% /summary %} **totalTokenCount**: `integer` Total number of tokens that the cached content consumes. {% /details %} {% /section %}