Skip to main content

cached_contents

Creates, updates, deletes, gets or lists a cached_contents resource.

Overview

Namecached_contents
TypeResource
Idgemini.cached_contents.cached_contents

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
namestringOutput only. Identifier. The resource name referring to the cached content. Format: `cachedContents/{id}`
contentsarrayOptional. Input only. Immutable. The content to cache.
createTimestring (google-datetime)Output only. Creation time of the cache entry.
displayNamestringOptional. Immutable. The user-generated meaningful display name of the cached content. Maximum 128 Unicode characters.
expireTimestring (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.
modelstringRequired. Immutable. The name of the `Model` to use for cached content Format: `models/{model}`
systemInstructionobjectThe 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.
toolConfigobjectOptional. Input only. Immutable. Tool config. This config is shared for all tools.
toolsarrayOptional. Input only. Immutable. A list of `Tools` the model may use to generate the next response
ttlstring (google-duration)Input only. New TTL for this resource, input only.
updateTimestring (google-datetime)Output only. When the cache entry was last updated in UTC time.
usageMetadataobjectOutput only. Metadata on the usage of the cached content.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectcachedContentsIdReads CachedContent resource.
listselectLists CachedContents.
createinsertCreates CachedContent resource.
patchupdatecachedContentsIdupdateMaskUpdates CachedContent resource (only expiration is updatable).
deletedeletecachedContentsIdDeletes 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.

NameDatatypeDescription
cachedContentsIdstring
updateMaskstring (google-fieldmask)The list of fields to update.

SELECT examples

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
;

INSERT examples

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
;

UPDATE examples

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

Deletes CachedContent resource.

DELETE FROM gemini.cached_contents.cached_contents
WHERE cachedContentsId = '{{ cachedContentsId }}' --required
;