Context caching allows you to save and reuse precomputed input tokens that you wish to use repeatedly, for example when asking different questions about the same media file. This can lead to cost and speed savings, depending on the usage. For a detailed introduction, see the Context caching guide.
Method: cachedContents.create
Creates CachedContent resource.
Endpoint
posthttps: / /generativelanguage.googleapis.com /v1beta /cachedContents
Request body
The request body contains an instance of CachedContent.
Optional. Input only. Immutable. The content to cache.
Optional. Input only. Immutable. A list of Tools the model may use to generate the next response
expirationUnion type
expiration can be only one of the following:Timestamp in UTC 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".
Input only. New TTL for this resource, input only.
A duration in seconds with up to nine fractional digits, ending with 's'. Example: "3.5s".
displayNamestring
Optional. Immutable. The user-generated meaningful display name of the cached content. Maximum 128 Unicode characters.
modelstring
Required. Immutable. The name of the Model to use for cached content Format: models/{model}
Optional. Input only. Immutable. Developer set system instruction. Currently text only.
Optional. Input only. Immutable. Tool config. This config is shared for all tools.
Example request
Basic
Python
Node.js
Go
Shell
From name
Python
Node.js
Go
From chat
Python
Node.js
Go
Response body
If successful, the response body contains a newly created instance of CachedContent.
Method: cachedContents.list
Lists CachedContents.
Endpoint
gethttps: / /generativelanguage.googleapis.com /v1beta /cachedContents
Query parameters
pageSizeinteger
Optional. The maximum number of cached contents to return. The service may return fewer than this value. If unspecified, some default (under maximum) number of items will be returned. The maximum value is 1000; values above 1000 will be coerced to 1000.
pageTokenstring
Optional. A page token, received from a previous cachedContents.list call. Provide this to retrieve the subsequent page.
When paginating, all other parameters provided to cachedContents.list must match the call that provided the page token.
Request body
The request body must be empty.
Response body
Response with CachedContents list.
If successful, the response body contains data with the following structure:
List of cached contents.
nextPageTokenstring
A token, which can be sent as pageToken to retrieve the next page. If this field is omitted, there are no subsequent pages.
| JSON representation |
|---|
{
"cachedContents": [
{
object ( |
Method: cachedContents.get
Reads CachedContent resource.
Endpoint
gethttps: / /generativelanguage.googleapis.com /v1beta /{name=cachedContents /*}
Path parameters
namestring
Required. The resource name referring to the content cache entry. Format: cachedContents/{id} It takes the form cachedContents/{cachedcontent}.
Request body
The request body must be empty.
Example request
Python
Node.js
Go
Shell
Response body
If successful, the response body contains an instance of CachedContent.
Method: cachedContents.patch
Updates CachedContent resource (only expiration is updatable).
Endpoint
patchhttps: / /generativelanguage.googleapis.com /v1beta /{cachedContent.name=cachedContents /*}
PATCH https://generativelanguage.googleapis.com/v1beta/{cachedContent.name=cachedContents/*}
Path parameters
cachedContent.namestring
Output only. Identifier. The resource name referring to the cached content. Format: cachedContents/{id} It takes the form cachedContents/{cachedcontent}.
Query parameters
The list of fields to update.
This is a comma-separated list of fully qualified names of fields. Example: "user.displayName,photo".
Request body
The request body contains an instance of CachedContent.
expirationUnion type
expiration can be only one of the following:Timestamp in UTC 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".
Input only. New TTL for this resource, input only.
A duration in seconds with up to nine fractional digits, ending with 's'. Example: "3.5s".
Example request
Python
Node.js
Go
Shell
Response body
If successful, the response body contains an instance of CachedContent.
Method: cachedContents.delete
Deletes CachedContent resource.
Endpoint
deletehttps: / /generativelanguage.googleapis.com /v1beta /{name=cachedContents /*}
Path parameters
namestring
Required. The resource name referring to the content cache entry Format: cachedContents/{id} It takes the form cachedContents/{cachedcontent}.
Request body
The request body must be empty.
Example request
Python
Node.js
Go
Shell
Response body
If successful, the response body is an empty JSON object.
REST Resource: cachedContents
- Resource: CachedContent
- Content
- Part
- Blob
- FunctionCall
- FunctionResponse
- FunctionResponsePart
- FunctionResponseBlob
- Scheduling
- FileData
- ExecutableCode
- Language
- CodeExecutionResult
- Outcome
- VideoMetadata
- Tool
- FunctionDeclaration
- Schema
- Type
- Behavior
- GoogleSearchRetrieval
- DynamicRetrievalConfig
- Mode
- CodeExecution
- GoogleSearch
- Interval
- ComputerUse
- Environment
- UrlContext
- FileSearch
- RetrievalResource
- RetrievalConfig
- GoogleMaps
- ToolConfig
- FunctionCallingConfig
- Mode
- RetrievalConfig
- LatLng
- UsageMetadata
- Methods
Resource: CachedContent
Content that has been preprocessed and can be used in subsequent request to GenerativeService.
Cached content can be only used with model it was created for.
Optional. Input only. Immutable. The content to cache.
Optional. Input only. Immutable. A list of Tools the model may use to generate the next response
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".
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".
Output only. Metadata on the usage of the cached content.
expirationUnion type
expiration can be only one of the following:Timestamp in UTC 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".
Input only. New TTL for this resource, input only.
A duration in seconds with up to nine fractional digits, ending with 's'. Example: "3.5s".
namestring
Output only. Identifier. The resource name referring to the cached content. Format: cachedContents/{id}
displayNamestring
Optional. Immutable. The user-generated meaningful display name of the cached content. Maximum 128 Unicode characters.
modelstring
Required. Immutable. The name of the Model to use for cached content Format: models/{model}
Optional. Input only. Immutable. Developer set system instruction. Currently text only.
Optional. Input only. Immutable. Tool config. This config is shared for all tools.
| JSON representation |
|---|
{ "contents": [ { object ( |
Content
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.
Ordered Parts that constitute a single message. Parts may have different MIME types.
rolestring
Optional. The producer of the content. Must be either 'user' or 'model'.
Useful to set for multi-turn conversations, otherwise can be left blank or unset.
| JSON representation |
|---|
{
"parts": [
{
object ( |
Part
A datatype containing media that is part of a multi-part Content message.
A Part consists of data which has an associated datatype. A Part can only contain one of the accepted types in Part.data.
A Part must have a fixed IANA MIME type identifying the type and subtype of the media if the inlineData field is filled with raw bytes.
thoughtboolean
Optional. Indicates if the part is thought from the model.
Optional. An opaque signature for the thought so it can be reused in subsequent requests.
A base64-encoded string.
Custom metadata associated with the Part. Agents using genai.Part as content representation may need to keep track of the additional information. For example it can be name of a file/source from which the Part originates or a way to multiplex multiple Part streams.
dataUnion type
data can be only one of the following:textstring
Inline text.
Inline media bytes.
A predicted FunctionCall returned from the model that contains a string representing the FunctionDeclaration.name with the arguments and their values.
The result output of a FunctionCall that contains a string representing the FunctionDeclaration.name and a structured JSON object containing any output from the function is used as context to the model.
URI based data.
Code generated by the model that is meant to be executed.
Result of executing the ExecutableCode.
metadataUnion type
metadata can be only one of the following:Optional. Video metadata. The metadata should only be specified while the video data is presented in inlineData or fileData.
| JSON representation |
|---|
{ "thought": boolean, "thoughtSignature": string, "partMetadata": { object }, // data "text": string, "inlineData": { object ( |
Blob
Raw media bytes.
Text should not be sent as raw bytes, use the 'text' field.
mimeTypestring
The IANA standard MIME type of the source data. Examples: - image/png - image/jpeg If an unsupported MIME type is provided, an error will be returned. For a complete list of supported types, see Supported file formats.
Raw bytes for media formats.
A base64-encoded string.
| JSON representation |
|---|
{ "mimeType": string, "data": string } |
FunctionCall
A predicted FunctionCall returned from the model that contains a string representing the FunctionDeclaration.name with the arguments and their values.
idstring
Optional. The unique id of the function call. If populated, the client to execute the functionCall and return the response with the matching id.
namestring
Required. The name of the function to call. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.
Optional. The function parameters and values in JSON object format.
| JSON representation |
|---|
{ "id": string, "name": string, "args": { object } } |
FunctionResponse
The result output from a FunctionCall that contains a string representing the FunctionDeclaration.name and a structured JSON object containing any output from the function is used as context to the model. This should contain the result of aFunctionCall made based on model prediction.
idstring
Optional. The id of the function call this response is for. Populated by the client to match the corresponding function call id.
namestring
Required. The name of the function to call. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.
Required. The function response in JSON object format. Callers can use any keys of their choice that fit the function's syntax to return the function output, e.g. "output", "result", etc. In particular, if the function call failed to execute, the response can have an "error" key to return error details to the model.
Optional. Ordered Parts that constitute a function response. Parts may have different IANA MIME types.
willContinueboolean
Optional. Signals that function call continues, and more responses will be returned, turning the function call into a generator. Is only applicable to NON_BLOCKING function calls, is ignored otherwise. If set to false, future responses will not be considered. It is allowed to return empty response with willContinue=False to signal that the function call is finished. This may still trigger the model generation. To avoid triggering the generation and finish the function call, additionally set scheduling to SILENT.
Optional. Specifies how the response should be scheduled in the conversation. Only applicable to NON_BLOCKING function calls, is ignored otherwise. Defaults to WHEN_IDLE.
| JSON representation |
|---|
{ "id": string, "name": string, "response": { object }, "parts": [ { object ( |
FunctionResponsePart
A datatype containing media that is part of a FunctionResponse message.
A FunctionResponsePart consists of data which has an associated datatype. A FunctionResponsePart can only contain one of the accepted types in FunctionResponsePart.data.
A FunctionResponsePart must have a fixed IANA MIME type identifying the type and subtype of the media if the inlineData field is filled with raw bytes.
dataUnion type
data can be only one of the following:Inline media bytes.
| JSON representation |
|---|
{
// data
"inlineData": {
object ( |
FunctionResponseBlob
Raw media bytes for function response.
Text should not be sent as raw bytes, use the 'FunctionResponse.response' field.
mimeTypestring
The IANA standard MIME type of the source data. Examples: - image/png - image/jpeg If an unsupported MIME type is provided, an error will be returned. For a complete list of supported types, see Supported file formats.
Raw bytes for media formats.
A base64-encoded string.
| JSON representation |
|---|
{ "mimeType": string, "data": string } |
Scheduling
Specifies how the response should be scheduled in the conversation.
| Enums | |
|---|---|
SCHEDULING_UNSPECIFIED |
This value is unused. |
SILENT |
Only add the result to the conversation context, do not interrupt or trigger generation. |
WHEN_IDLE |
Add the result to the conversation context, and prompt to generate output without interrupting ongoing generation. |
INTERRUPT |
Add the result to the conversation context, interrupt ongoing generation and prompt to generate output. |
FileData
URI based data.
mimeTypestring
Optional. The IANA standard MIME type of the source data.
fileUristring
Required. URI.
| JSON representation |
|---|
{ "mimeType": string, "fileUri": string } |
ExecutableCode
Code generated by the model that is meant to be executed, and the result returned to the model.
Only generated when using the CodeExecution tool, in which the code will be automatically executed, and a corresponding CodeExecutionResult will also be generated.
Required. Programming language of the code.
codestring
Required. The code to be executed.
| JSON representation |
|---|
{
"language": enum ( |
Language
Supported programming languages for the generated code.
| Enums | |
|---|---|
LANGUAGE_UNSPECIFIED |
Unspecified language. This value should not be used. |
PYTHON |
Python >= 3.10, with numpy and simpy available. |
CodeExecutionResult
Result of executing the ExecutableCode.
Only generated when using the CodeExecution, and always follows a part containing the ExecutableCode.
Required. Outcome of the code execution.
outputstring
Optional. Contains stdout when code execution is successful, stderr or other description otherwise.
| JSON representation |
|---|
{
"outcome": enum ( |
Outcome
Enumeration of possible outcomes of the code execution.
| Enums | |
|---|---|
OUTCOME_UNSPECIFIED |
Unspecified status. This value should not be used. |
OUTCOME_OK |
Code execution completed successfully. |
OUTCOME_FAILED |
Code execution finished but with a failure. stderr should contain the reason. |
OUTCOME_DEADLINE_EXCEEDED |
Code execution ran for too long, and was cancelled. There may or may not be a partial output present. |
VideoMetadata
Metadata describes the input video content.
Optional. The start offset of the video.
A duration in seconds with up to nine fractional digits, ending with 's'. Example: "3.5s".
Optional. The end offset of the video.
A duration in seconds with up to nine fractional digits, ending with 's'. Example: "3.5s".
fpsnumber
Optional. The frame rate of the video sent to the model. If not specified, the default value will be 1.0. The fps range is (0.0, 24.0].
| JSON representation |
|---|
{ "startOffset": string, "endOffset": string, "fps": number } |
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.
Next ID: 12
Optional. A list of FunctionDeclarations available to the model that can be used for function calling.
The model or system does not execute the function. Instead the defined function may be returned as a FunctionCall with arguments to the client side for execution. The model may decide to call a subset of these functions by populating FunctionCall in the response. The next conversation turn may contain a FunctionResponse with the Content.role "function" generation context for the next model turn.
Optional. Retrieval tool that is powered by Google search.
Optional. Enables the model to execute code as part of generation.
Optional. GoogleSearch tool type. Tool to support Google Search in Model. Powered by Google.
Optional. Tool to support the model interacting directly with the computer. If enabled, it automatically populates computer-use specific Function Declarations.
Optional. Tool to support URL context retrieval.
Optional. FileSearch tool type. Tool to retrieve knowledge from Semantic Retrieval corpora.
Optional. Tool that allows grounding the model's response with geospatial context related to the user's query.
| JSON representation |
|---|
{ "functionDeclarations": [ { object ( |
FunctionDeclaration
Structured representation of a function declaration as defined by the OpenAPI 3.03 specification. Included in this declaration are the function name and parameters. This FunctionDeclaration is a representation of a block of code that can be used as a Tool by the model and executed by the client.
namestring
Required. The name of the function. Must be a-z, A-Z, 0-9, or contain underscores, colons, dots, and dashes, with a maximum length of 64.
descriptionstring
Required. A brief description of the function.
Optional. Specifies the function Behavior. Currently only supported by the BidiGenerateContent method.
Optional. Describes the parameters to this function. 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.
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 with parameters.
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.
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 with response.
Schema
The Schema object allows the definition of input and output data types. These types can be objects, but also primitives and arrays. Represents a select subset of an OpenAPI 3.0 schema object.
Required. Data type.
formatstring
Optional. The format of the data. Any value is allowed, but most do not trigger any special functionality.
titlestring
Optional. The title of the schema.
descriptionstring
Optional. A brief description of the parameter. This could contain examples of use. Parameter description may be formatted as Markdown.
nullableboolean
Optional. Indicates if the value may be null.
enum[]string
Optional. Possible values of the element of Type.STRING with enum format. For example we can define an Enum Direction as : {type:STRING, format:enum, enum:["EAST", NORTH", "SOUTH", "WEST"]}
Optional. Maximum number of the elements for Type.ARRAY.
Optional. Minimum number of the elements for Type.ARRAY.
Optional. Properties of Type.OBJECT.
An object containing a list of "key": value pairs. Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.
required[]string
Optional. Required properties of Type.OBJECT.
Optional. Minimum number of the properties for Type.OBJECT.
Optional. Maximum number of the properties for Type.OBJECT.
Optional. SCHEMA FIELDS FOR TYPE STRING Minimum length of the Type.STRING
Optional. Maximum length of the Type.STRING
patternstring
Optional. Pattern of the Type.STRING to restrict a string to a regular expression.
Optional. Example of the object. Will only populated when the object is the root.
Optional. The value should be validated against any (one or more) of the subschemas in the list.
propertyOrdering[]string
Optional. The order of the properties. Not a standard field in open api spec. Used to determine the order of the properties in the response.
Optional. Default value of the field. Per JSON Schema, this field is intended for documentation generators and doesn't affect validation. Thus it's included here and ignored so that developers who send schemas with a default field don't get unknown-field errors.
Optional. Schema of the elements of Type.ARRAY.
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
| JSON representation |
|---|
{ "type": enum ( |
Type
Type contains the list of OpenAPI data types as defined by https://spec.openapis.org/oas/v3.0.3#data-types
| Enums | |
|---|---|
TYPE_UNSPECIFIED |
Not specified, should not be used. |
STRING |
String type. |
NUMBER |
Number type. |
INTEGER |
Integer type. |
BOOLEAN |
Boolean type. |
ARRAY |
Array type. |
OBJECT |
Object type. |
NULL |
Null type. |
Behavior
Defines the function behavior. Defaults to BLOCKING.
| Enums | |
|---|---|
UNSPECIFIED |
This value is unused. |
BLOCKING |
If set, the system will wait to receive the function response before continuing the conversation. |
NON_BLOCKING |
If set, the system will not wait to receive the function response. Instead, it will attempt to handle function responses as they become available while maintaining the conversation between the user and the model. |
GoogleSearchRetrieval
Tool to retrieve public web data for grounding, powered by Google.
Specifies the dynamic retrieval configuration for the given source.
| JSON representation |
|---|
{
"dynamicRetrievalConfig": {
object ( |
DynamicRetrievalConfig
Describes the options to customize dynamic retrieval.
The mode of the predictor to be used in dynamic retrieval.
dynamicThresholdnumber
The threshold to be used in dynamic retrieval. If not set, a system default value is used.
| JSON representation |
|---|
{
"mode": enum ( |
Mode
The mode of the predictor to be used in dynamic retrieval.
| Enums | |
|---|---|
MODE_UNSPECIFIED |
Always trigger retrieval. |
MODE_DYNAMIC |
Run retrieval only when system decides it is necessary. |
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 only generated when using this tool.
GoogleSearch
GoogleSearch tool type. Tool to support Google Search in Model. Powered by Google.
Optional. Filter search results to a specific time range. If customers set a start time, they must set an end time (and vice versa).
| JSON representation |
|---|
{
"timeRangeFilter": {
object ( |
Interval
Represents a time interval, encoded as a Timestamp start (inclusive) and a Timestamp end (exclusive).
The start must be less than or equal to the end. When the start equals the end, the interval is empty (matches no time). When both start and end are unspecified, the interval matches any time.
Optional. Inclusive start of the interval.
If specified, a Timestamp matching this interval will have to be the same or after the start.
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".
Optional. Exclusive end of the interval.
If specified, a Timestamp matching this interval will have to be before the end.
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".
| JSON representation |
|---|
{ "startTime": string, "endTime": string } |
ComputerUse
Computer Use tool type.
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
Represents the environment being operated, such as a web browser.
| Enums | |
|---|---|
ENVIRONMENT_UNSPECIFIED |
Defaults to browser. |
ENVIRONMENT_BROWSER |
Operates in a web browser. |
UrlContext
This type has no fields.
Tool to support URL context retrieval.
FileSearch
The FileSearch tool that retrieves knowledge from Semantic Retrieval corpora. Files are imported to Semantic Retrieval corpora using the ImportFile API.
Required. Semantic retrieval resources to retrieve from. Currently only supports one corpus. In the future we may open up multiple corpora support.
Optional. The configuration for the retrieval.
| JSON representation |
|---|
{ "retrievalResources": [ { object ( |
RetrievalResource
The semantic retrieval resource to retrieve from.
ragStoreNamestring
Required. The name of the semantic retrieval resource to retrieve from. Example: ragStores/my-rag-store-123
| JSON representation |
|---|
{ "ragStoreName": string } |
RetrievalConfig
Semantic retrieval configuration.
metadataFilterstring
Optional. Metadata filter to apply to the semantic retrieval documents and chunks.
topKinteger
Optional. The number of semantic retrieval chunks to retrieve.
| JSON representation |
|---|
{ "metadataFilter": string, "topK": integer } |
GoogleMaps
The GoogleMaps Tool that provides geospatial context for the user's query.
enableWidgetboolean
Optional. Whether to return a widget context token in the GroundingMetadata of the response. Developers can use the widget context token to render a Google Maps widget with geospatial context related to the places that the model references in the response.
| JSON representation |
|---|
{ "enableWidget": boolean } |
ToolConfig
The Tool configuration containing parameters for specifying Tool use in the request.
Optional. Function calling config.
Optional. Retrieval config.
| JSON representation |
|---|
{ "functionCallingConfig": { object ( |
FunctionCallingConfig
Configuration for specifying function calling behavior.
Optional. Specifies the mode in which function calling should execute. If unspecified, the default value will be set to AUTO.
allowedFunctionNames[]string
Optional. A set of function names that, when provided, limits the functions the model will call.
This should only be set when the Mode is ANY or VALIDATED. Function names should match [FunctionDeclaration.name]. When set, model will predict a function call from only allowed function names.
| JSON representation |
|---|
{
"mode": enum ( |
Mode
Defines the execution behavior for function calling by defining the execution 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 response. |
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. |
VALIDATED |
Model decides to predict either a function call or a natural language response, but will validate function calls with constrained decoding. 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". |
RetrievalConfig
LatLng
An object that represents a latitude/longitude pair. This is expressed as a pair of doubles to represent degrees latitude and degrees longitude. Unless specified otherwise, this object must conform to the WGS84 standard. Values must be within normalized ranges.
latitudenumber
The latitude in degrees. It must be in the range [-90.0, +90.0].
longitudenumber
The longitude in degrees. It must be in the range [-180.0, +180.0].
| JSON representation |
|---|
{ "latitude": number, "longitude": number } |
UsageMetadata
Metadata on the usage of the cached content.
totalTokenCountinteger
Total number of tokens that the cached content consumes.
| JSON representation |
|---|
{ "totalTokenCount": integer } |