REST Resource: projects.locations.cachedContents

Resource: CachedContent

A resource used in LLM queries for users to explicitly specify what to cache and how to cache.

Fields
name string

Immutable. Identifier. The server-generated resource name of the cached content Format: projects/{project}/locations/{location}/cachedContents/{cachedContent}

displayName string

Optional. Immutable. The user-generated meaningful display name of the cached content.

model string

Immutable. The name of the Model to use for cached content. Currently, only the published Gemini base models are supported, in form of projects/{PROJECT}/locations/{LOCATION}/publishers/google/models/{MODEL}

systemInstruction object (Content)

Optional. Input only. Immutable. Developer set system instruction. Currently, text only

contents[] object (Content)

Optional. Input only. Immutable. The content to cache

tools[] object (Tool)

Optional. Input only. Immutable. A list of Tools the model may use to generate the next response

toolConfig object (ToolConfig)

Optional. Input only. Immutable. Tool config. This config is shared for all tools

createTime string (Timestamp format)

Output only. Creation time of the cache entry.

Uses RFC 3339, where generated output will always be Z-normalized and use 0, 3, 6 or 9 fractional digits. Offsets other than "Z" are also accepted. Examples: "2014-10-02T15:01:23Z", "2014-10-02T15:01:23.045123456Z" or "2014-10-02T15:01:23+05:30".

updateTime string (Timestamp format)

Output only. When the cache entry was last updated in UTC time.

Uses RFC 3339, where generated output will always be Z-normalized and use 0, 3, 6 or 9 fractional digits. Offsets other than "Z" are also accepted. Examples: "2014-10-02T15:01:23Z", "2014-10-02T15:01:23.045123456Z" or "2014-10-02T15:01:23+05:30".

usageMetadata object (UsageMetadata)

Output only. metadata on the usage of the cached content.

encryptionSpec object (EncryptionSpec)

Input only. Immutable. Customer-managed encryption key spec for a CachedContent. If set, this CachedContent and all its sub-resources will be secured by this key.

expiration Union type
Expiration time of the cached content. expiration can be only one of the following:
expireTime string (Timestamp format)

timestamp of when this resource is considered expired. This is always provided on output, regardless of what was sent on input.

Uses RFC 3339, where generated output will always be Z-normalized and use 0, 3, 6 or 9 fractional digits. Offsets other than "Z" are also accepted. Examples: "2014-10-02T15:01:23Z", "2014-10-02T15:01:23.045123456Z" or "2014-10-02T15:01:23+05:30".

ttl string (Duration format)

Input only. The TTL for this resource. The expiration time is computed: now + TTL.

A duration in seconds with up to nine fractional digits, ending with 's'. Example: "3.5s".

JSON representation
{
  "name": string,
  "displayName": string,
  "model": string,
  "systemInstruction": {
    object (Content)
  },
  "contents": [
    {
      object (Content)
    }
  ],
  "tools": [
    {
      object (Tool)
    }
  ],
  "toolConfig": {
    object (ToolConfig)
  },
  "createTime": string,
  "updateTime": string,
  "usageMetadata": {
    object (UsageMetadata)
  },
  "encryptionSpec": {
    object (EncryptionSpec)
  },

  // expiration
  "expireTime": string,
  "ttl": string
  // Union type
}

ToolConfig

Tool config. This config is shared for all tools provided in the request.

Fields
functionCallingConfig object (FunctionCallingConfig)

Optional. Function calling config.

retrievalConfig object (RetrievalConfig)

Optional. Retrieval config.

JSON representation
{
  "functionCallingConfig": {
    object (FunctionCallingConfig)
  },
  "retrievalConfig": {
    object (RetrievalConfig)
  }
}

FunctionCallingConfig

Function calling config.

Fields
mode enum (Mode)

Optional. Function calling mode.

allowedFunctionNames[] string

Optional. Function names to call. Only set when the Mode is ANY. Function names should match [FunctionDeclaration.name]. With mode set to ANY, model will predict a function call from the set of function names provided.

JSON representation
{
  "mode": enum (Mode),
  "allowedFunctionNames": [
    string
  ]
}

Mode

Function calling mode.

Enums
MODE_UNSPECIFIED Unspecified function calling mode. This value should not be used.
AUTO Default model behavior, model decides to predict either function calls or natural language response.
ANY Model is constrained to always predicting function calls only. If "allowedFunctionNames" are set, the predicted function calls will be limited to any one of "allowedFunctionNames", else the predicted function calls will be any one of the provided "functionDeclarations".
NONE Model will not predict any function calls. Model behavior is same as when not passing any function declarations.
VALIDATED Model is constrained to predict either function calls or natural language response. If "allowedFunctionNames" are set, the predicted function calls will be limited to any one of "allowedFunctionNames", else the predicted function calls will be any one of the provided "functionDeclarations".

RetrievalConfig

Retrieval config.

Fields
latLng object (LatLng)

The location of the user.

languageCode string

The language code of the user.

JSON representation
{
  "latLng": {
    object (LatLng)
  },
  "languageCode": string
}

UsageMetadata

metadata on the usage of the cached content.

Fields
totalTokenCount integer

Total number of tokens that the cached content consumes.

textCount integer

Number of text characters.

imageCount integer

Number of images.

videoDurationSeconds integer

Duration of video in seconds.

audioDurationSeconds integer

Duration of audio in seconds.

JSON representation
{
  "totalTokenCount": integer,
  "textCount": integer,
  "imageCount": integer,
  "videoDurationSeconds": integer,
  "audioDurationSeconds": integer
}

Methods

create

Creates cached content, this call will initialize the cached content in the data storage, and users need to pay for the cache data storage.

delete

Deletes cached content

get

Gets cached content configurations

list

Lists cached contents in a project

patch

Updates cached content configurations