{
"name": "cachedContents/20261103012026348092000s1oTuB96",
"model": "models/gemini-3.8-flash",
"displayName": "product-manual-v3",
"createTime": "2026-11-03T01:20:27.311Z",
"updateTime": "2026-11-03T01:20:27.311Z",
"expireTime": "2026-11-03T02:20:26.902Z",
"usageMetadata": {
"totalTokenCount": 7525
}
}{
"error": {
"code": 400,
"message": "ttl must not exceed 604800s (168h)",
"status": "INVALID_ARGUMENT",
"details": [
{
"@type": "type.googleapis.com/google.rpc.ErrorInfo",
"reason": "INVALID_ARGUMENT",
"domain": "evolink.ai"
}
]
}
}{
"error": {
"code": 401,
"message": "Invalid API key",
"status": "UNAUTHENTICATED"
}
}{
"error": {
"code": 402,
"message": "insufficient quota for cache storage prepayment",
"status": "RESOURCE_EXHAUSTED",
"details": [
{
"@type": "type.googleapis.com/google.rpc.ErrorInfo",
"reason": "INSUFFICIENT_QUOTA",
"domain": "evolink.ai"
}
]
}
}{
"error": {
"code": 403,
"message": "This key is not allowed to use model gemini-3.8-flash",
"status": "PERMISSION_DENIED"
}
}{
"error": {
"code": 404,
"message": "explicit context caching is not enabled",
"status": "NOT_FOUND",
"details": [
{
"@type": "type.googleapis.com/google.rpc.ErrorInfo",
"reason": "EXPLICIT_CACHE_DISABLED",
"domain": "evolink.ai"
}
]
}
}{
"error": {
"code": 413,
"message": "cache content exceeds 10485760 bytes; reference large files with fileData.fileUri instead",
"status": "INVALID_ARGUMENT",
"details": [
{
"@type": "type.googleapis.com/google.rpc.ErrorInfo",
"reason": "CACHE_CONTENT_TOO_LARGE",
"domain": "evolink.ai"
}
]
}
}{
"error": {
"code": 429,
"message": "Rate limit exceeded",
"status": "RESOURCE_EXHAUSTED"
}
}{
"error": {
"code": 502,
"message": "the request could not be completed due to a service authorization problem; please retry later or contact support",
"status": "INTERNAL",
"details": [
{
"@type": "type.googleapis.com/google.rpc.ErrorInfo",
"reason": "UPSTREAM_ERROR",
"domain": "evolink.ai"
}
]
}
}{
"error": {
"code": 503,
"message": "explicit context caching is temporarily unavailable",
"status": "UNAVAILABLE",
"details": [
{
"@type": "type.googleapis.com/google.rpc.ErrorInfo",
"reason": "INTERNAL",
"domain": "evolink.ai"
}
]
}
}Gemini Explicit Context Caching - Create a cache
Create a cache from at least one of contents, systemInstruction, or tools, optionally with toolConfig, and receive its name.
- Models:
modelaccepts eithermodels/gemini-3.8-flashorgemini-3.8-flash. Supported models:gemini-3.8-flash,gemini-3.7-flash,gemini-3.6-flash,gemini-3.5-flash,gemini-3.5-flash-lite,gemini-3-flash-preview,gemini-3.1-flash-lite-preview,gemini-3.1-pro-preview,gemini-3.1-pro-preview-customtools, andgemini-3-pro-preview. Gemini 4 models do not support explicit caching. - Lifetime: Provide either
ttl, such as"3600s", orexpireTime(RFC 3339), but not both. Defaults to 1 hour when neither is provided. Minimum 60 seconds, maximum 168 hours (604800s); deleted automatically on expiry. - Size: The request body must not exceed 10 MB. Content must meet the model’s minimum cache token count (for example, 4,096 tokens for
gemini-3.8-flash); otherwise, returns 400. - Fields: Only the documented fields are accepted; other fields return 400.
- tools: Only
googleSearch,codeExecution, andfunctionDeclarationsare accepted; other tools return 400. - Returned
name: Has the formcachedContents/<id>, where<id>is this request’s ID. Search for it on the dashboard’s Logs page to find the cache creation charge. - Billing: Creation charges a cache write fee (at the input rate) and the storage fee (per million tokens per hour) for the full lifetime upfront. When a cache is referenced, cached tokens are billed at the cache hit rate; if the cache declares
googleSearch, each search is billed separately. Shortening, deleting, or expiry does not refund storage fees; extensions charge for the added duration. See Pricing for per-model rates.
Authenticate with Authorization: Bearer; the x-goog-api-key header is also accepted.
{
"name": "cachedContents/20261103012026348092000s1oTuB96",
"model": "models/gemini-3.8-flash",
"displayName": "product-manual-v3",
"createTime": "2026-11-03T01:20:27.311Z",
"updateTime": "2026-11-03T01:20:27.311Z",
"expireTime": "2026-11-03T02:20:26.902Z",
"usageMetadata": {
"totalTokenCount": 7525
}
}{
"error": {
"code": 400,
"message": "ttl must not exceed 604800s (168h)",
"status": "INVALID_ARGUMENT",
"details": [
{
"@type": "type.googleapis.com/google.rpc.ErrorInfo",
"reason": "INVALID_ARGUMENT",
"domain": "evolink.ai"
}
]
}
}{
"error": {
"code": 401,
"message": "Invalid API key",
"status": "UNAUTHENTICATED"
}
}{
"error": {
"code": 402,
"message": "insufficient quota for cache storage prepayment",
"status": "RESOURCE_EXHAUSTED",
"details": [
{
"@type": "type.googleapis.com/google.rpc.ErrorInfo",
"reason": "INSUFFICIENT_QUOTA",
"domain": "evolink.ai"
}
]
}
}{
"error": {
"code": 403,
"message": "This key is not allowed to use model gemini-3.8-flash",
"status": "PERMISSION_DENIED"
}
}{
"error": {
"code": 404,
"message": "explicit context caching is not enabled",
"status": "NOT_FOUND",
"details": [
{
"@type": "type.googleapis.com/google.rpc.ErrorInfo",
"reason": "EXPLICIT_CACHE_DISABLED",
"domain": "evolink.ai"
}
]
}
}{
"error": {
"code": 413,
"message": "cache content exceeds 10485760 bytes; reference large files with fileData.fileUri instead",
"status": "INVALID_ARGUMENT",
"details": [
{
"@type": "type.googleapis.com/google.rpc.ErrorInfo",
"reason": "CACHE_CONTENT_TOO_LARGE",
"domain": "evolink.ai"
}
]
}
}{
"error": {
"code": 429,
"message": "Rate limit exceeded",
"status": "RESOURCE_EXHAUSTED"
}
}{
"error": {
"code": 502,
"message": "the request could not be completed due to a service authorization problem; please retry later or contact support",
"status": "INTERNAL",
"details": [
{
"@type": "type.googleapis.com/google.rpc.ErrorInfo",
"reason": "UPSTREAM_ERROR",
"domain": "evolink.ai"
}
]
}
}{
"error": {
"code": 503,
"message": "explicit context caching is temporarily unavailable",
"status": "UNAVAILABLE",
"details": [
{
"@type": "type.googleapis.com/google.rpc.ErrorInfo",
"reason": "INTERNAL",
"domain": "evolink.ai"
}
]
}
}https://direct.evolink.ai, which has better support for text models and long-lived connections. https://api.evolink.ai is the primary endpoint for multimodal services and serves as a fallback address for text models."cachedContent": "<name>" to the generateContent or streamGenerateContent request body and put only the new question in contents. Requests that reference a cache cannot include systemInstruction, tools, or toolConfig, and must use the same model as the cache.Authorizations
All endpoints require Bearer Token authentication
Get an API Key:
Visit API Key Management to get your API Key.
Add this request header:
Authorization: Bearer YOUR_API_KEY
The Gemini native format is also accepted: the x-goog-api-key: YOUR_API_KEY header or the ?key=YOUR_API_KEY URL parameter.
Body
Model; either models/gemini-3.8-flash or gemini-3.8-flash is accepted. Supported: gemini-3.8-flash, gemini-3.7-flash, gemini-3.6-flash, gemini-3.5-flash, gemini-3.5-flash-lite, gemini-3-flash-preview, gemini-3.1-flash-lite-preview, gemini-3.1-pro-preview, gemini-3.1-pro-preview-customtools, gemini-3-pro-preview
"models/gemini-3.8-flash"
Response
Cache created. usageMetadata.totalTokenCount is the cached token count used to calculate write and storage fees