gemini_createCache
Generates cached content resources for compatible Gemini models to reduce latency and costs for frequently reused prompts. Returns metadata detailing the created cache for efficient reuse.
Instructions
Creates a cached content resource for a compatible Gemini model. Caching can reduce latency and costs for prompts that are reused often. NOTE: Caching is only supported for specific models (e.g., gemini-1.5-flash, gemini-1.5-pro). Returns metadata about the created cache.
Input Schema
Name | Required | Description | Default |
---|---|---|---|
contents | Yes | Required. The content to cache, matching the SDK's Content structure (an array of Parts). | |
displayName | No | Optional. A human-readable name for the cache. | |
model | No | Optional. The name/ID of the model compatible with caching (e.g., 'gemini-1.5-flash'). If omitted, the server's default model (from GOOGLE_GEMINI_MODEL env var) will be used. | |
systemInstruction | No | Optional. System instructions to associate with the cache. | |
ttl | No | Optional. Time-to-live for the cache as a duration string (e.g., '3600s' for 1 hour). Max 48 hours. |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"contents": {
"description": "Required. The content to cache, matching the SDK's Content structure (an array of Parts).",
"items": {
"additionalProperties": false,
"properties": {
"parts": {
"items": {
"additionalProperties": false,
"properties": {
"fileData": {
"additionalProperties": false,
"properties": {
"fileUri": {
"format": "uri",
"type": "string"
},
"mimeType": {
"type": "string"
}
},
"required": [
"mimeType",
"fileUri"
],
"type": "object"
},
"functionCall": {
"additionalProperties": false,
"properties": {
"args": {
"additionalProperties": {},
"type": "object"
},
"id": {
"type": "string"
},
"name": {
"type": "string"
}
},
"required": [
"name",
"args"
],
"type": "object"
},
"functionResponse": {
"additionalProperties": false,
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
},
"response": {
"additionalProperties": {},
"type": "object"
}
},
"required": [
"name",
"response"
],
"type": "object"
},
"inlineData": {
"additionalProperties": false,
"properties": {
"data": {
"type": "string"
},
"mimeType": {
"type": "string"
}
},
"required": [
"mimeType",
"data"
],
"type": "object"
},
"text": {
"type": "string"
}
},
"type": "object"
},
"minItems": 1,
"type": "array"
},
"role": {
"enum": [
"user",
"model",
"function",
"tool"
],
"type": "string"
}
},
"required": [
"parts"
],
"type": "object"
},
"minItems": 1,
"type": "array"
},
"displayName": {
"description": "Optional. A human-readable name for the cache.",
"maxLength": 100,
"minLength": 1,
"type": "string"
},
"model": {
"description": "Optional. The name/ID of the model compatible with caching (e.g., 'gemini-1.5-flash'). If omitted, the server's default model (from GOOGLE_GEMINI_MODEL env var) will be used.",
"minLength": 1,
"type": "string"
},
"systemInstruction": {
"$ref": "#/properties/contents/items",
"description": "Optional. System instructions to associate with the cache."
},
"ttl": {
"description": "Optional. Time-to-live for the cache as a duration string (e.g., '3600s' for 1 hour). Max 48 hours.",
"pattern": "^\\d+(\\.\\d+)?s$",
"type": "string"
}
},
"required": [
"contents"
],
"type": "object"
}