curl --request PATCH \
--url https://direct.evolink.ai/v1beta/cachedContents/{id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"ttl": "7200s"
}'{
"name": "cachedContents/20261103012026348092000s1oTuB96",
"model": "models/gemini-3.8-flash",
"displayName": "product-manual-v3",
"createTime": "2026-11-03T01:20:27.311Z",
"updateTime": "2026-11-03T01:35:10.020Z",
"expireTime": "2026-11-03T03:35:10.000Z",
"usageMetadata": {
"totalTokenCount": 7525
}
}{
"error": {
"code": 400,
"message": "new expiry must be at least 60s in the future",
"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 extension",
"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": "cached content not found",
"status": "NOT_FOUND",
"details": [
{
"@type": "type.googleapis.com/google.rpc.ErrorInfo",
"reason": "CACHE_NOT_FOUND",
"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": "cached content is temporarily unavailable; please retry later",
"status": "UNAVAILABLE",
"details": [
{
"@type": "type.googleapis.com/google.rpc.ErrorInfo",
"reason": "CACHE_CHANNEL_UNAVAILABLE",
"domain": "evolink.ai"
}
]
}
}明示的コンテキストキャッシュ
Gemini 明示的コンテキストキャッシュ - 有効期間を延長・短縮
変更できるのは有効期間のみで、内容は変更できません。ttl(現在からの新しい期間、例:"7200s")または expireTime(新しい絶対有効期限)の一方を指定します。
- 新しい有効期限は現在から60秒以上168時間以内です。
ttlまたはexpireTimeのみ受け付け、両方または他のフィールドを指定すると400です。- 延長:追加期間の保存料金を秒単位で徴収し、1秒未満は1秒として計算します。短縮:徴収済みの保存料金は返金されません。
- 有料操作です。Key にモデルの利用権限が必要で、現在のユーザーグループの料金が適用されます。残高不足は402です。
- 同じ延長リクエストの再試行時は
Idempotency-Keyヘッダーで二重課金を防げます。
PATCH
/
v1beta
/
cachedContents
/
{id}
curl --request PATCH \
--url https://direct.evolink.ai/v1beta/cachedContents/{id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"ttl": "7200s"
}'{
"name": "cachedContents/20261103012026348092000s1oTuB96",
"model": "models/gemini-3.8-flash",
"displayName": "product-manual-v3",
"createTime": "2026-11-03T01:20:27.311Z",
"updateTime": "2026-11-03T01:35:10.020Z",
"expireTime": "2026-11-03T03:35:10.000Z",
"usageMetadata": {
"totalTokenCount": 7525
}
}{
"error": {
"code": 400,
"message": "new expiry must be at least 60s in the future",
"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 extension",
"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": "cached content not found",
"status": "NOT_FOUND",
"details": [
{
"@type": "type.googleapis.com/google.rpc.ErrorInfo",
"reason": "CACHE_NOT_FOUND",
"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": "cached content is temporarily unavailable; please retry later",
"status": "UNAVAILABLE",
"details": [
{
"@type": "type.googleapis.com/google.rpc.ErrorInfo",
"reason": "CACHE_CHANNEL_UNAVAILABLE",
"domain": "evolink.ai"
}
]
}
}BaseURL:デフォルトの BaseURL は
https://direct.evolink.ai で、テキストモデルへの対応が優れており、長時間接続をサポートします。https://api.evolink.ai はマルチモーダルの主力エンドポイントで、テキストモデルに対しては代替アドレスとして使用されます。変更できるのは有効期間のみで、リクエストボディには
ttl か expireTime のどちらかを指定します。延長時は追加期間分の保存料金を徴収し、短縮しても返金されません。承認
すべてのエンドポイントは Bearer Token 認証が必要です
API Key の取得:
API Key 管理で取得してください。
リクエストヘッダーに追加:
Authorization: Bearer YOUR_API_KEY
Gemini ネイティブ形式の x-goog-api-key: YOUR_API_KEY ヘッダー、または URL パラメータ ?key=YOUR_API_KEY も使用できます。
パスパラメータ
ボディ
application/json
レスポンス
更新後のメタデータ。expireTime が新しい有効期限です