> ## Documentation Index
> Fetch the complete documentation index at: https://evolink.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Gemini 显式上下文缓存 - 查询单个缓存

> 返回缓存的元数据（模型、token 数、创建 / 更新 / 到期时间）。不返回缓存内容本身。已过期的缓存与不存在一样返回 404。免费。

> [!NOTE]
>
> **BaseURL 说明**：默认 BaseURL 为 `https://direct.evolink.ai`，对文本模型支持更好，支持长连接；`https://api.evolink.ai` 是多模态主力地址，对文本模型作为备用地址使用。

> [!NOTE]
>
> 路径中的 `{id}` 是创建接口返回的 `name` 去掉 `cachedContents/` 前缀后的部分。只返回元数据，不返回缓存内容。查询免费。


## OpenAPI

````yaml cn/api-manual/language-series/gemini/cached-contents/cached-contents.json GET /v1beta/cachedContents/{id}
openapi: 3.1.0
info:
  title: Gemini 显式上下文缓存（cachedContents）
  description: >-
    把反复使用的长前缀（长文档、系统指令、工具定义）一次创建成缓存，后续生成请求只带缓存名和新问题；缓存部分按「缓存命中」单价计费。接口格式与 Gemini
    原生 cachedContents 接口一致。
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://direct.evolink.ai
    description: 生产环境（推荐）
  - url: https://api.evolink.ai
    description: 备用地址
security:
  - bearerAuth: []
tags:
  - name: 显式上下文缓存
    description: 创建、查询、延长、删除 Gemini 显式缓存
paths:
  /v1beta/cachedContents/{id}:
    get:
      tags:
        - 显式上下文缓存
      summary: 查询单个缓存
      description: 返回缓存的元数据（模型、token 数、创建 / 更新 / 到期时间）。不返回缓存内容本身。已过期的缓存与不存在一样返回 404。免费。
      operationId: geminiGetCachedContent
      parameters:
        - name: id
          in: path
          required: true
          description: >-
            缓存 id：创建接口返回的 `name` 去掉 `cachedContents/` 前缀后的部分。例如 `name` 为
            `cachedContents/20261103012026348092000s1oTuB96`，这里填
            `20261103012026348092000s1oTuB96`。
          schema:
            type: string
            example: 20261103012026348092000s1oTuB96
      responses:
        '200':
          description: 缓存元数据
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CachedContent'
              example:
                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
        '401':
          description: API Key 无效或缺失
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: 401
                  message: Invalid API key
                  status: UNAUTHENTICATED
        '403':
          description: Key 无权使用该模型，或来源 IP 不在 Key 的白名单内
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: 403
                  message: This key is not allowed to use model gemini-3.8-flash
                  status: PERMISSION_DENIED
        '404':
          description: 缓存不存在、已过期、已删除或不属于当前账号；或显式缓存功能未开放
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                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
        '429':
          description: 触发频率限制
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: 429
                  message: Rate limit exceeded
                  status: RESOURCE_EXHAUSTED
        '503':
          description: 服务暂时不可用，请稍后重试
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                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
components:
  schemas:
    CachedContent:
      type: object
      properties:
        name:
          type: string
          description: >-
            缓存名，形如 `cachedContents/<id>`。生成请求的 `cachedContent` 字段填它；`<id>`
            同时是创建请求的请求号
          example: cachedContents/20261103012026348092000s1oTuB96
        model:
          type: string
          description: 缓存绑定的模型，引用时生成请求的模型必须与之一致
          example: models/gemini-3.8-flash
        displayName:
          type: string
          description: 创建时给的名字，没给则不返回
        createTime:
          type: string
          format: date-time
          description: 创建时间（UTC）
        updateTime:
          type: string
          format: date-time
          description: 最近一次更新时间（UTC）
        expireTime:
          type: string
          format: date-time
          description: 到期时间（UTC），到期后自动删除
        usageMetadata:
          type: object
          properties:
            totalTokenCount:
              type: integer
              description: 缓存的 token 总数，缓存写入费与存储费按它计算
              example: 7525
    ErrorResponse:
      type: object
      description: >-
        Gemini 原生错误格式。`error.details[0].reason` 为原因码：`INVALID_ARGUMENT`
        参数错误；`EXPLICIT_CACHE_UNSUPPORTED`
        模型不支持显式缓存；`NO_AVAILABLE_CHANNEL`、`MODEL_PRICE_ERROR`
        当前用户组暂未开放；`CACHE_EXPIRED` 缓存已到期或剩余有效期过短；`CACHE_MODEL_MISMATCH`
        模型与缓存不一致；`INVALID_CACHED_CONTENT` `cachedContent`
        格式不正确；`INSUFFICIENT_QUOTA` 余额不足；`CACHE_NOT_FOUND`
        缓存不存在、已过期、已删除或不属于当前账号；`EXPLICIT_CACHE_DISABLED`
        功能暂未开放；`CACHE_CONTENT_TOO_LARGE` 请求体超过 10 MB；`UPSTREAM_ERROR` 请求未被接受，原因见
        `message`；`CACHE_CHANNEL_UNAVAILABLE`、`INTERNAL` 暂时不可用，请稍后重试。
      properties:
        error:
          type: object
          properties:
            code:
              type: integer
              description: HTTP 状态码
            message:
              type: string
            status:
              type: string
              description: 状态枚举，如 INVALID_ARGUMENT / NOT_FOUND / UNAVAILABLE
            details:
              type: array
              items:
                type: object
                properties:
                  '@type':
                    type: string
                    example: type.googleapis.com/google.rpc.ErrorInfo
                  reason:
                    type: string
                    example: CACHE_NOT_FOUND
                  domain:
                    type: string
                    example: evolink.ai
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        ##所有接口均需要使用 Bearer Token 进行认证##


        **获取 API Key：**


        访问 [API Key 管理页面](https://evolink.ai/dashboard/keys) 获取您的 API Key


        **使用时在请求头中添加：**

        ```

        Authorization: Bearer YOUR_API_KEY

        ```


        也接受 Gemini 原生写法：请求头 `x-goog-api-key: YOUR_API_KEY`，或 URL 参数
        `?key=YOUR_API_KEY`。

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.