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.

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

  // Union field expiration can be only one of the following:
  "expireTime": string,
  "ttl": string
  // End of list of possible types for union field expiration.
}
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 publisher model to use for cached content. Format: projects/{project}/locations/{location}/publishers/{publisher}/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. Creatation time of the cache entry.

A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z".

updateTime

string (Timestamp format)

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

A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z".

Union field expiration. 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.

A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z".

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".

Tool

Tool details that the model may use to generate response.

A Tool is a piece of code that enables the system to interact with external systems to perform an action, or set of actions, outside of knowledge and scope of the model. A Tool object should contain exactly one type of Tool (e.g FunctionDeclaration, Retrieval or GoogleSearchRetrieval).

JSON representation
{
  "functionDeclarations": [
    {
      object (FunctionDeclaration)
    }
  ],
  "retrieval": {
    object (Retrieval)
  }
}
Fields
functionDeclarations[]

object (FunctionDeclaration)

Optional. Function tool type. One or more function declarations to be passed to the model along with the current user query. Model may decide to call a subset of these functions by populating [FunctionCall][content.part.function_call] in the response. user should provide a [FunctionResponse][content.part.function_response] for each function call in the next turn. Based on the function responses, Model will generate the final response back to the user. Maximum 64 function declarations can be provided.

retrieval

object (Retrieval)

Optional. Retrieval tool type. System will always execute the provided retrieval tool(s) to get external knowledge to answer the prompt. Retrieval results are presented to the model for generation.

Retrieval

Defines a retrieval tool that model can call to access external knowledge.

JSON representation
{
  "disableAttribution": boolean,

  // Union field source can be only one of the following:
  "vertexAiSearch": {
    object (VertexAISearch)
  },
  "vertexRagStore": {
    object (VertexRagStore)
  }
  // End of list of possible types for union field source.
}
Fields
disableAttribution

boolean

Optional. Disable using the result from this tool in detecting grounding attribution. This does not affect how the result is given to the model for generation.

Union field source. The source of the retrieval. source can be only one of the following:
vertexRagStore

object (VertexRagStore)

Set to use data source powered by Vertex RAG store. user data is uploaded via the VertexRagDataService.

VertexAISearch

Retrieve from Vertex AI Search datastore for grounding. See https://cloud.google.com/vertex-ai-search-and-conversation

JSON representation
{
  "datastore": string
}
Fields
datastore

string

Required. Fully-qualified Vertex AI Search's datastore resource ID. Format: projects/{project}/locations/{location}/collections/{collection}/dataStores/{dataStore}

VertexRagStore

Retrieve from Vertex RAG Store for grounding.

JSON representation
{
  "ragCorpora": [
    string
  ],
  "ragResources": [
    {
      object (RagResource)
    }
  ],
  "similarityTopK": integer,
  "vectorDistanceThreshold": number
}
Fields
ragCorpora[]
(deprecated)

string

Optional. Deprecated. Please use ragResources instead.

ragResources[]

object (RagResource)

Optional. The representation of the rag source. It can be used to specify corpus only or ragfiles. Currently only support one corpus or multiple files from one corpus. In the future we may open up multiple corpora support.

similarityTopK

integer

Optional. Number of top k results to return from the selected corpora.

vectorDistanceThreshold

number

Optional. Only return results with vector distance smaller than the threshold.

RagResource

The definition of the Rag resource.

JSON representation
{
  "ragCorpus": string,
  "ragFileIds": [
    string
  ]
}
Fields
ragCorpus

string

Optional. RagCorpora resource name. Format: projects/{project}/locations/{location}/ragCorpora/{ragCorpus}

ragFileIds[]

string

Optional. ragFileId. The files should be in the same ragCorpus set in ragCorpus field.

ToolConfig

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

JSON representation
{
  "functionCallingConfig": {
    object (FunctionCallingConfig)
  }
}
Fields
functionCallingConfig

object (FunctionCallingConfig)

Optional. Function calling config.

FunctionCallingConfig

Function calling config.

JSON representation
{
  "mode": enum (Mode),
  "allowedFunctionNames": [
    string
  ]
}
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.

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 a function call or a natural language repspose.
ANY Model is constrained to always predicting a function call only. If "allowedFunctionNames" are set, the predicted function call will be limited to any one of "allowedFunctionNames", else the predicted function call will be any one of the provided "functionDeclarations".
NONE Model will not predict any function call. Model behavior is same as when not passing any function declarations.

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