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
namestring

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

displayNamestring

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

modelstring

Immutable. The name of theModel 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}

systemInstructionobject (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 ofTools the model may use to generate the next response

toolConfigobject (ToolConfig)

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

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

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

usageMetadataobject (UsageMetadata)

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

encryptionSpecobject (EncryptionSpec)

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

expirationUnion type
Expiration time of the cached content.expiration can be only one of the following:
expireTimestring (Timestamp format)

timestamp of when this resource is considered expired. This isalways 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".

ttlstring (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}

Tool

Tool details that the model may use to generate response.

ATool 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).

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 populatingFunctionCall in the response. user should provide aFunctionResponse for each function call in the next turn. Based on the function responses, Model will generate the final response back to the user. Maximum 512 function declarations can be provided.

retrievalobject (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.

googleSearchobject (GoogleSearch)

Optional. GoogleSearch tool type. Tool to support Google Search in Model. Powered by Google.

Optional. GoogleMaps tool type. Tool to support Google Maps in Model.

enterpriseWebSearchobject (EnterpriseWebSearch)

Optional. Tool to support searching public web data, powered by Vertex AI Search and Sec4 compliance.

codeExecutionobject (CodeExecution)

Optional. CodeExecution tool type. Enables the model to execute code as part of generation.

urlContextobject (UrlContext)

Optional. Tool to support URL context retrieval.

computerUseobject (ComputerUse)

Optional. Tool to support the model interacting directly with the computer. If enabled, it automatically populates computer-use specific Function Declarations.

JSON representation
{"functionDeclarations":[{object (FunctionDeclaration)}],"retrieval":{object (Retrieval)},"googleSearch":{object (GoogleSearch)},"googleSearchRetrieval":{object (GoogleSearchRetrieval)},"googleMaps":{object (GoogleMaps)},"enterpriseWebSearch":{object (EnterpriseWebSearch)},"codeExecution":{object (CodeExecution)},"urlContext":{object (UrlContext)},"computerUse":{object (ComputerUse)}}

FunctionDeclaration

Structured representation of a function declaration as defined by theOpenAPI 3.0 specification. Included in this declaration are the function name, description, parameters and response type. This FunctionDeclaration is a representation of a block of code that can be used as aTool by the model and executed by the client.

Fields
namestring

Required. The name of the function to call. Must start with a letter or an underscore. Must be a-z, A-Z, 0-9, or contain underscores, dots, colons and dashes, with a maximum length of 64.

descriptionstring

Optional. description and purpose of the function. Model uses it to decide how and whether to call the function.

parametersobject (Schema)

Optional. Describes the parameters to this function in JSON Schema Object format. Reflects the Open API 3.03 Parameter Object. string Key: the name of the parameter. Parameter names are case sensitive. Schema value: the Schema defining the type used for the parameter. For function with no parameters, this can be left unset. Parameter names must start with a letter or an underscore and must only contain chars a-z, A-Z, 0-9, or underscores with a maximum length of 64. Example with 1 required and 1 optional parameter: type: OBJECT properties: param1: type: STRING param2: type: INTEGER required: - param1

parametersJsonSchemavalue (Value format)

Optional. Describes the parameters to the function in JSON Schema format. The schema must describe an object where the properties are the parameters to the function. For example:

{  "type": "object",  "properties": {    "name": { "type": "string" },    "age": { "type": "integer" }  },  "additionalProperties": false,  "required": ["name", "age"],  "propertyOrdering": ["name", "age"]}

This field is mutually exclusive withparameters.

responseobject (Schema)

Optional. Describes the output from this function in JSON Schema format. Reflects the Open API 3.03 Response Object. The Schema defines the type used for the response value of the function.

responseJsonSchemavalue (Value format)

Optional. Describes the output from this function in JSON Schema format. The value specified by the schema is the response value of the function.

This field is mutually exclusive withresponse.

JSON representation
{"name":string,"description":string,"parameters":{object (Schema)},"parametersJsonSchema":value,"response":{object (Schema)},"responseJsonSchema":value}

Schema

Schema is used to define the format of input/output data. Represents a select subset of anOpenAPI 3.0 schema object. More fields may be added in the future as needed.

Fields
typeenum (Type)

Optional. The type of the data.

formatstring

Optional. The format of the data. Supported formats: for NUMBER type: "float", "double" for INTEGER type: "int32", "int64" for STRING type: "email", "byte", etc

titlestring

Optional. The title of the Schema.

descriptionstring

Optional. The description of the data.

nullableboolean

Optional. Indicates if the value may be null.

defaultvalue (Value format)

Optional. Default value of the data.

itemsobject (Schema)

Optional. SCHEMA FIELDS FOR TYPE ARRAY Schema of the elements of type.ARRAY.

minItemsstring (int64 format)

Optional. Minimum number of the elements for type.ARRAY.

maxItemsstring (int64 format)

Optional. Maximum number of the elements for type.ARRAY.

enum[]string

Optional. Possible values of the element of primitive type with enum format. Examples: 1. We can define direction as : {type:STRING, format:enum, enum:["EAST", NORTH", "SOUTH", "WEST"]} 2. We can define apartment number as : {type:INTEGER, format:enum, enum:["101", "201", "301"]}

propertiesmap (key: string, value: object (Schema))

Optional. SCHEMA FIELDS FOR TYPE OBJECT Properties of type.OBJECT.

propertyOrdering[]string

Optional. The order of the properties. Not a standard field in open api spec. Only used to support the order of the properties.

required[]string

Optional. Required properties of type.OBJECT.

minPropertiesstring (int64 format)

Optional. Minimum number of the properties for type.OBJECT.

maxPropertiesstring (int64 format)

Optional. Maximum number of the properties for type.OBJECT.

minimumnumber

Optional. SCHEMA FIELDS FOR TYPE INTEGER and NUMBER Minimum value of the type.INTEGER and type.NUMBER

maximumnumber

Optional. Maximum value of the type.INTEGER and type.NUMBER

minLengthstring (int64 format)

Optional. SCHEMA FIELDS FOR TYPE STRING Minimum length of the type.STRING

maxLengthstring (int64 format)

Optional. Maximum length of the type.STRING

patternstring

Optional. Pattern of the type.STRING to restrict a string to a regular expression.

examplevalue (Value format)

Optional. Example of the object. Will only populated when the object is the root.

anyOf[]object (Schema)

Optional. The value should be validated against any (one or more) of the subschemas in the list.

additionalPropertiesvalue (Value format)

Optional. Can either be a boolean or an object; controls the presence of additional properties.

refstring

Optional. Allows indirect references between schema nodes. The value should be a valid reference to a child of the rootdefs.

For example, the following schema defines a reference to a schema node named "Pet":

type: object properties: pet: ref: #/defs/Pet defs: Pet: type: object properties: name: type: string

The value of the "pet" property is a reference to the schema node named "Pet". See details inhttps://json-schema.org/understanding-json-schema/structuring

defsmap (key: string, value: object (Schema))

Optional. A map of definitions for use byref Only allowed at the root of the schema.

JSON representation
{"type":enum (Type),"format":string,"title":string,"description":string,"nullable":boolean,"default":value,"items":{object (Schema)},"minItems":string,"maxItems":string,"enum":[string],"properties":{string:{object (Schema)},...},"propertyOrdering":[string],"required":[string],"minProperties":string,"maxProperties":string,"minimum":number,"maximum":number,"minLength":string,"maxLength":string,"pattern":string,"example":value,"anyOf":[{object (Schema)}],"additionalProperties":value,"ref":string,"defs":{string:{object (Schema)},...}}

Type

type contains the list of OpenAPI data types as defined byhttps://swagger.io/docs/specification/data-models/data-types/

Enums
TYPE_UNSPECIFIEDNot specified, should not be used.
STRINGOpenAPI string type
NUMBEROpenAPI number type
INTEGEROpenAPI integer type
BOOLEANOpenAPI boolean type
ARRAYOpenAPI array type
OBJECTOpenAPI object type
NULLNull type

Retrieval

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

Fields
sourceUnion type
The source of the retrieval.source can be only one of the following:

Set to use data source powered by Vertex AI Search.

vertexRagStoreobject (VertexRagStore)

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

JSON representation
{"disableAttribution":boolean,// source"vertexAiSearch":{object (VertexAISearch)},"vertexRagStore":{object (VertexRagStore)}// Union type}

VertexAISearch

Retrieve from Vertex AI Search datastore or engine for grounding. datastore and engine are mutually exclusive. Seehttps://cloud.google.com/products/agent-builder

Fields
datastorestring

Optional. Fully-qualified Vertex AI Search data store resource id. Format:projects/{project}/locations/{location}/collections/{collection}/dataStores/{dataStore}

enginestring

Optional. Fully-qualified Vertex AI Search engine resource id. Format:projects/{project}/locations/{location}/collections/{collection}/engines/{engine}

maxResultsinteger

Optional. Number of search results to return per query. The default value is 10. The maximumm allowed value is 10.

filterstring

Optional. Filter strings to be passed to the search API.

dataStoreSpecs[]object (DataStoreSpec)

Specifications that define the specific DataStores to be searched, along with configurations for those data stores. This is only considered for Engines with multiple data stores. It should only be set if engine is used.

JSON representation
{"datastore":string,"engine":string,"maxResults":integer,"filter":string,"dataStoreSpecs":[{object (DataStoreSpec)}]}

DataStoreSpec

Define data stores within engine to filter on in a search call and configurations for those data stores. For more information, seehttps://cloud.google.com/generative-ai-app-builder/docs/reference/rpc/google.cloud.discoveryengine.v1#datastorespec

Fields
dataStorestring

Full resource name of DataStore, such as Format:projects/{project}/locations/{location}/collections/{collection}/dataStores/{dataStore}

filterstring

Optional. Filter specification to filter documents in the data store specified by dataStore field. For more information on filtering, seeFiltering

JSON representation
{"dataStore":string,"filter":string}

VertexRagStore

Retrieve from Vertex RAG Store for grounding.

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

ragRetrievalConfigobject (RagRetrievalConfig)

Optional. The retrieval config for the Rag query.

JSON representation
{"ragResources":[{object (RagResource)}],"ragRetrievalConfig":{object (RagRetrievalConfig)},"similarityTopK":integer,"vectorDistanceThreshold":number}

RagResource

RagRetrievalConfig

Specifies the context retrieval config.

Fields
topKinteger

Optional. The number of contexts to retrieve.

Optional. Config for filters.

rankingobject (Ranking)

Optional. Config for ranking and reranking.

JSON representation
{"topK":integer,"filter":{object (Filter)},"ranking":{object (Ranking)}}

Filter

Config for filters.

Fields
metadataFilterstring

Optional. String for metadata filtering.

vector_db_thresholdUnion type
Filter contexts retrieved from the vector DB based on either vector distance or vector similarity.vector_db_threshold can be only one of the following:
vectorDistanceThresholdnumber

Optional. Only returns contexts with vector distance smaller than the threshold.

vectorSimilarityThresholdnumber

Optional. Only returns contexts with vector similarity larger than the threshold.

JSON representation
{"metadataFilter":string,// vector_db_threshold"vectorDistanceThreshold":number,"vectorSimilarityThreshold":number// Union type}

Ranking

Config for ranking and reranking.

Fields
ranking_configUnion type
Config options for ranking. Currently only Rank Service is supported.ranking_config can be only one of the following:
rankServiceobject (RankService)

Optional. Config for Rank service.

llmRankerobject (LlmRanker)

Optional. Config for LlmRanker.

JSON representation
{// ranking_config"rankService":{object (RankService)},"llmRanker":{object (LlmRanker)}// Union type}

RankService

Config for Rank service.

Fields
modelNamestring

Optional. The model name of the rank service. Format:semantic-ranker-512@latest

JSON representation
{"modelName":string}

LlmRanker

Config for LlmRanker.

Fields
modelNamestring

Optional. The model name used for ranking. SeeSupported models.

JSON representation
{"modelName":string}

GoogleSearch

GoogleSearch tool type. Tool to support Google Search in Model. Powered by Google.

Fields
excludeDomains[]string

Optional. List of domains to be excluded from the search results. The default limit is 2000 domains. Example: ["amazon.com", "facebook.com"].

blockingConfidenceenum (PhishBlockThreshold)

Optional. Sites with confidence level chosen & above this value will be blocked from the search results.

JSON representation
{"excludeDomains":[string],"blockingConfidence":enum (PhishBlockThreshold)}

PhishBlockThreshold

These are available confidence level user can set to block malicious urls with chosen confidence and above. For understanding different confidence of webrisk, please refer tohttps://cloud.google.com/web-risk/docs/reference/rpc/google.cloud.webrisk.v1eap1#confidencelevel

Enums
PHISH_BLOCK_THRESHOLD_UNSPECIFIEDDefaults to unspecified.
BLOCK_LOW_AND_ABOVEBlocks Low and above confidence URL that is risky.
BLOCK_MEDIUM_AND_ABOVEBlocks Medium and above confidence URL that is risky.
BLOCK_HIGH_AND_ABOVEBlocks High and above confidence URL that is risky.
BLOCK_HIGHER_AND_ABOVEBlocks Higher and above confidence URL that is risky.
BLOCK_VERY_HIGH_AND_ABOVEBlocks Very high and above confidence URL that is risky.
BLOCK_ONLY_EXTREMELY_HIGHBlocks Extremely high confidence URL that is risky.

GoogleSearchRetrieval

Tool to retrieve public web data for grounding, powered by Google.

Fields
dynamicRetrievalConfigobject (DynamicRetrievalConfig)

Specifies the dynamic retrieval configuration for the given source.

JSON representation
{"dynamicRetrievalConfig":{object (DynamicRetrievalConfig)}}

DynamicRetrievalConfig

Describes the options to customize dynamic retrieval.

Fields
modeenum (Mode)

The mode of the predictor to be used in dynamic retrieval.

dynamicThresholdnumber

Optional. The threshold to be used in dynamic retrieval. If not set, a system default value is used.

JSON representation
{"mode":enum (Mode),"dynamicThreshold":number}

Mode

The mode of the predictor to be used in dynamic retrieval.

Enums
MODE_UNSPECIFIEDAlways trigger retrieval.
MODE_DYNAMICRun retrieval only when system decides it is necessary.

GoogleMaps

Tool to retrieve public maps data for grounding, powered by Google.

Fields
enableWidgetboolean

Optional. If true, include the widget context token in the response.

JSON representation
{"enableWidget":boolean}

EnterpriseWebSearch

Tool to search public web data, powered by Vertex AI Search and Sec4 compliance.

Fields
excludeDomains[]string

Optional. List of domains to be excluded from the search results. The default limit is 2000 domains.

blockingConfidenceenum (PhishBlockThreshold)

Optional. Sites with confidence level chosen & above this value will be blocked from the search results.

JSON representation
{"excludeDomains":[string],"blockingConfidence":enum (PhishBlockThreshold)}

CodeExecution

This type has no fields.

Tool that executes code generated by the model, and automatically returns the result to the model.

See also [ExecutableCode]and [CodeExecutionResult] which are input and output to this tool.

UrlContext

This type has no fields.

Tool to support URL context.

ComputerUse

Tool to support computer use.

Fields
environmentenum (Environment)

Required. The environment being operated.

excludedPredefinedFunctions[]string

Optional. By default,predefined functions are included in the final model call. Some of them can be explicitly excluded from being automatically included. This can serve two purposes: 1. Using a more restricted / different action space. 2. Improving the definitions / instructions of predefined functions.

JSON representation
{"environment":enum (Environment),"excludedPredefinedFunctions":[string]}

Environment

Represents the environment being operated, such as a web browser.

Enums
ENVIRONMENT_UNSPECIFIEDDefaults to browser.
ENVIRONMENT_BROWSEROperates in a web browser.

ToolConfig

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

Fields
functionCallingConfigobject (FunctionCallingConfig)

Optional. Function calling config.

retrievalConfigobject (RetrievalConfig)

Optional. Retrieval config.

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

FunctionCallingConfig

Function calling config.

Fields
modeenum (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.

streamFunctionCallArgumentsboolean

Optional. When set to true, arguments of a single function call will be streamed out in multiple parts/contents/responses. Partial parameter results will be returned in the [FunctionCall.partial_args] field.

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

Mode

Function calling mode.

Enums
MODE_UNSPECIFIEDUnspecified function calling mode. This value should not be used.
AUTODefault model behavior, model decides to predict either function calls or natural language response.
ANYModel 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".
NONEModel will not predict any function calls. Model behavior is same as when not passing any function declarations.

RetrievalConfig

Retrieval config.

Fields
latLngobject (LatLng)

The location of the user.

languageCodestring

The language code of the user.

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

UsageMetadata

metadata on the usage of the cached content.

Fields
totalTokenCountinteger

Total number of tokens that the cached content consumes.

textCountinteger

Number of text characters.

imageCountinteger

Number of images.

videoDurationSecondsinteger

Duration of video in seconds.

audioDurationSecondsinteger

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

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-02 UTC.