Endpoint#
Endpoint
POST https://api.xpluse.plus/gemini/v1beta/cachedContents # Create
GET https://api.xpluse.plus/gemini/v1beta/cachedContents/{id} # Query
DELETE https://api.xpluse.plus/gemini/v1beta/cachedContents/{id} # Delete
POST https://api.xpluse.plus/gemini/v1beta/models/{model}:generateContent # Generate by referenceManage explicit context caches (cachedContents) through the Gemini native API: cache large context blocks as objects and reference them across requests for more deterministic hits and lower cost. Compatible with the Google GenAI SDK. See the full guide: Gemini Explicit cache.
ResourcesField#
| Field | Type | Description |
|---|---|---|
name | string (read-only) | Handle, such as cachedContents/{id} |
model | string (required, immutable) | such as google/gemini-3.1-pro-preview |
contents | array | Content to cache |
systemInstruction | object | System instruction (optional) |
ttl | string | Lifetime in seconds, such as "600s"; mutually exclusive with expireTime |
displayName | string (immutable) | Custom name (optional) |
TTL range: minimum/default 600s(10 minutes), maximum 3600s(1 hour).
Create cache#
cURL
curl "https://api.xpluse.plus/gemini/v1beta/cachedContents" \
-H "x-goog-api-key: $DATAMIND_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "google/gemini-3.1-pro-preview",
"contents": [{"role": "user", "parts": [{"text": "<large context to cache>"}]}],
"ttl": "600s"
}' Python
from google import genai
from google.genai import types
client = genai.Client(
api_key="<your DATAMIND_API_KEY>",
http_options={"api_version": "v1beta", "base_url": "https://api.xpluse.plus/gemini"},
)
cache = client.caches.create(
model="google/gemini-3.1-pro-preview",
config=types.CreateCachedContentConfig(
contents=[open("knowledge_base.txt").read()],
ttl="600s",
display_name="kb-v1",
),
)
print(cache.name)
print(cache.usage_metadata.total_token_count)Response example#
JSON
{
"name": "cachedContents/xxxxxxxx",
"model": "google/gemini-3.1-pro-preview",
"createTime": "2026-06-26T08:00:00Z",
"expireTime": "2026-06-26T08:10:00Z",
"displayName": "kb-v1",
"usageMetadata": {"totalTokenCount": 14407}
}Reference / query / delete#
Python
# Generate using the cache
response = client.models.generate_content(
model="google/gemini-3.1-pro-preview",
contents="Based on the docs above, summarize three key points",
config=types.GenerateContentConfig(cached_content=cache.name),
)
print(response.usage_metadata.cached_content_token_count)
# Query / delete (no need to pass model again)
info = client.caches.get(name=cache.name)
client.caches.delete(name=cache.name)Caches are region-bound. A handle can only be referenced, queried, or deleted by the API Key that created it (and the same ownership scope). Cross-account access returns 403.
Last updated on June 22, 2026