cached_contents
Creates, updates, deletes, gets or lists a cached_contents resource.
Overview
| Name | cached_contents |
| Type | Resource |
| Id | gemini.cached_contents.cached_contents |
Fields
The following fields are returned by SELECT queries:
- get
- list
| Name | Datatype | Description |
|---|---|---|
name | string | Output only. Identifier. The resource name referring to the cached content. Format: `cachedContents/{id}` |
contents | array | Optional. Input only. Immutable. The content to cache. |
createTime | string (google-datetime) | Output only. Creation time of the cache entry. |
displayName | string | Optional. Immutable. The user-generated meaningful display name of the cached content. Maximum 128 Unicode characters. |
expireTime | string (google-datetime) | Timestamp in UTC of when this resource is considered expired. This is *always* provided on output, regardless of what was sent on input. |
model | string | Required. Immutable. The name of the `Model` to use for cached content Format: `models/{model}` |
systemInstruction | object | The base structured datatype containing multi-part content of a message. A `Content` includes a `role` field designating the producer of the `Content` and a `parts` field containing multi-part data that contains the content of the message turn. |
toolConfig | object | Optional. Input only. Immutable. Tool config. This config is shared for all tools. |
tools | array | Optional. Input only. Immutable. A list of `Tools` the model may use to generate the next response |
ttl | string (google-duration) | Input only. New TTL for this resource, input only. |
updateTime | string (google-datetime) | Output only. When the cache entry was last updated in UTC time. |
usageMetadata | object | Output only. Metadata on the usage of the cached content. |
| Name | Datatype | Description |
|---|---|---|
name | string | Output only. Identifier. The resource name referring to the cached content. Format: `cachedContents/{id}` |
contents | array | Optional. Input only. Immutable. The content to cache. |
createTime | string (google-datetime) | Output only. Creation time of the cache entry. |
displayName | string | Optional. Immutable. The user-generated meaningful display name of the cached content. Maximum 128 Unicode characters. |
expireTime | string (google-datetime) | Timestamp in UTC of when this resource is considered expired. This is *always* provided on output, regardless of what was sent on input. |
model | string | Required. Immutable. The name of the `Model` to use for cached content Format: `models/{model}` |
systemInstruction | object | The base structured datatype containing multi-part content of a message. A `Content` includes a `role` field designating the producer of the `Content` and a `parts` field containing multi-part data that contains the content of the message turn. |
toolConfig | object | Optional. Input only. Immutable. Tool config. This config is shared for all tools. |
tools | array | Optional. Input only. Immutable. A list of `Tools` the model may use to generate the next response |
ttl | string (google-duration) | Input only. New TTL for this resource, input only. |
updateTime | string (google-datetime) | Output only. When the cache entry was last updated in UTC time. |
usageMetadata | object | Output only. Metadata on the usage of the cached content. |
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
get | select | cachedContentsId | Reads CachedContent resource. | |
list | select | Lists CachedContents. | ||
create | insert | Creates CachedContent resource. | ||
patch | update | cachedContentsId | updateMask | Updates CachedContent resource (only expiration is updatable). |
delete | delete | cachedContentsId | Deletes CachedContent resource. |
Parameters
Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.
| Name | Datatype | Description |
|---|---|---|
cachedContentsId | string | |
updateMask | string (google-fieldmask) | The list of fields to update. |
SELECT examples
- get
- list
Reads CachedContent resource.
SELECT
name,
contents,
createTime,
displayName,
expireTime,
model,
systemInstruction,
toolConfig,
tools,
ttl,
updateTime,
usageMetadata
FROM gemini.cached_contents.cached_contents
WHERE cachedContentsId = '{{ cachedContentsId }}' -- required
;
Lists CachedContents.
SELECT
name,
contents,
createTime,
displayName,
expireTime,
model,
systemInstruction,
toolConfig,
tools,
ttl,
updateTime,
usageMetadata
FROM gemini.cached_contents.cached_contents
;
INSERT examples
- create
- Manifest
Creates CachedContent resource.
INSERT INTO gemini.cached_contents.cached_contents (
toolConfig,
model,
contents,
ttl,
systemInstruction,
tools,
expireTime,
displayName
)
SELECT
'{{ toolConfig }}',
'{{ model }}',
'{{ contents }}',
'{{ ttl }}',
'{{ systemInstruction }}',
'{{ tools }}',
'{{ expireTime }}',
'{{ displayName }}'
RETURNING
name,
contents,
createTime,
displayName,
expireTime,
model,
systemInstruction,
toolConfig,
tools,
ttl,
updateTime,
usageMetadata
;
# Description fields are for documentation purposes
- name: cached_contents
props:
- name: toolConfig
description: |
Optional. Input only. Immutable. Tool config. This config is shared for all tools.
value:
functionCallingConfig:
mode: "{{ mode }}"
allowedFunctionNames:
- "{{ allowedFunctionNames }}"
includeServerSideToolInvocations: {{ includeServerSideToolInvocations }}
retrievalConfig:
latLng:
longitude: {{ longitude }}
latitude: {{ latitude }}
languageCode: "{{ languageCode }}"
- name: model
value: "{{ model }}"
description: |
Required. Immutable. The name of the `Model` to use for cached content Format: `models/{model}`
- name: contents
description: |
Optional. Input only. Immutable. The content to cache.
value:
- parts: "{{ parts }}"
role: "{{ role }}"
- name: ttl
value: "{{ ttl }}"
description: |
Input only. New TTL for this resource, input only.
- name: systemInstruction
description: |
The base structured datatype containing multi-part content of a message. A `Content` includes a `role` field designating the producer of the `Content` and a `parts` field containing multi-part data that contains the content of the message turn.
value:
parts:
- codeExecutionResult:
outcome: "{{ outcome }}"
output: "{{ output }}"
id: "{{ id }}"
videoMetadata:
startOffset: "{{ startOffset }}"
endOffset: "{{ endOffset }}"
fps: {{ fps }}
partMetadata: "{{ partMetadata }}"
inlineData:
mimeType: "{{ mimeType }}"
data: "{{ data }}"
functionResponse:
willContinue: {{ willContinue }}
response: "{{ response }}"
parts:
- inlineData:
mimeType: "{{ mimeType }}"
data: "{{ data }}"
id: "{{ id }}"
scheduling: "{{ scheduling }}"
name: "{{ name }}"
executableCode:
id: "{{ id }}"
code: "{{ code }}"
language: "{{ language }}"
text: "{{ text }}"
functionCall:
name: "{{ name }}"
args: "{{ args }}"
id: "{{ id }}"
toolCall:
args: "{{ args }}"
id: "{{ id }}"
toolType: "{{ toolType }}"
toolResponse:
toolType: "{{ toolType }}"
response: "{{ response }}"
id: "{{ id }}"
thought: {{ thought }}
mediaResolution:
level: "{{ level }}"
thoughtSignature: "{{ thoughtSignature }}"
fileData:
mimeType: "{{ mimeType }}"
fileUri: "{{ fileUri }}"
role: "{{ role }}"
- name: tools
description: |
Optional. Input only. Immutable. A list of `Tools` the model may use to generate the next response
value:
- codeExecution: "{{ codeExecution }}"
googleSearch:
timeRangeFilter:
endTime: "{{ endTime }}"
startTime: "{{ startTime }}"
searchTypes:
webSearch: "{{ webSearch }}"
imageSearch: "{{ imageSearch }}"
googleMaps:
enableWidget: {{ enableWidget }}
computerUse:
excludedPredefinedFunctions:
- "{{ excludedPredefinedFunctions }}"
enablePromptInjectionDetection: {{ enablePromptInjectionDetection }}
environment: "{{ environment }}"
disabledSafetyPolicies:
- "{{ disabledSafetyPolicies }}"
functionDeclarations: "{{ functionDeclarations }}"
mcpServers: "{{ mcpServers }}"
urlContext: "{{ urlContext }}"
googleSearchRetrieval:
dynamicRetrievalConfig:
mode: "{{ mode }}"
dynamicThreshold: {{ dynamicThreshold }}
fileSearch:
fileSearchStoreNames:
- "{{ fileSearchStoreNames }}"
topK: {{ topK }}
metadataFilter: "{{ metadataFilter }}"
- name: expireTime
value: "{{ expireTime }}"
description: |
Timestamp in UTC of when this resource is considered expired. This is *always* provided on output, regardless of what was sent on input.
- name: displayName
value: "{{ displayName }}"
description: |
Optional. Immutable. The user-generated meaningful display name of the cached content. Maximum 128 Unicode characters.
UPDATE examples
- patch
Updates CachedContent resource (only expiration is updatable).
UPDATE gemini.cached_contents.cached_contents
SET
toolConfig = '{{ toolConfig }}',
model = '{{ model }}',
contents = '{{ contents }}',
ttl = '{{ ttl }}',
systemInstruction = '{{ systemInstruction }}',
tools = '{{ tools }}',
expireTime = '{{ expireTime }}',
displayName = '{{ displayName }}'
WHERE
cachedContentsId = '{{ cachedContentsId }}' --required
WHERE updateMask = '{{ updateMask}}'
RETURNING
name,
contents,
createTime,
displayName,
expireTime,
model,
systemInstruction,
toolConfig,
tools,
ttl,
updateTime,
usageMetadata;
DELETE examples
- delete
Deletes CachedContent resource.
DELETE FROM gemini.cached_contents.cached_contents
WHERE cachedContentsId = '{{ cachedContentsId }}' --required
;