---
title: "Create Gemini cached content"
method: POST
path: "/v1beta/cachedContents"
tags: ["Gemini Resources"]
---

# Create Gemini cached content

`POST /v1beta/cachedContents`

## Request

- Base URL: `https://api.tokenlab.sh`
- URL: `https://api.tokenlab.sh/v1beta/cachedContents`
- Auth: one of:
  - HTTP bearer
  - API key in header `x-goog-api-key`

Creates cached content for a current TokenLab Gemini model. Supported fields, resource references, and lifetime depend on the service and model; lowerCamelCase and the corresponding proto snake_case names are accepted. Resources can only be read, referenced, changed, or deleted in their owning Workspace. Missing, expired, or inaccessible resources return a Gemini-format error.

## Query parameters

- `key` string

## Headers

- `Idempotency-Key` string

## Request body

- GeminiCachedContentRequest
  - `model` string, required: Current TokenLab model ID that supports Gemini cached content.
  - `displayName` string: Human-readable cache name.
  - `ttl` string: Positive duration such as 3600s. Supported lifetime is validated by the service.
  - `expireTime` string, date-time: Requested expiration time; use ttl or expireTime as supported by the service.
  - `contents` Contents (unresolved $ref)
  - `systemInstruction` SystemInstruction (unresolved $ref)
  - `tools` Tools (unresolved $ref)
  - `toolConfig` ToolConfig (unresolved $ref)

## Response `200`

Success

- GeminiCachedContentResource: Cached content belonging to the current Workspace. Use the returned name as cachedContent in Gemini generation.
  - `name` string: Resource name such as cachedContents/{cacheId}.
  - `model` string: TokenLab model ID associated with the cached content.
  - `displayName` string: Human-readable cache name.
  - `createTime` string, date-time
  - `updateTime` string, date-time
  - `expireTime` string, date-time
  - `usageMetadata` object

## Other responses

- `400`: Gemini-format resource error
- `401`: Gemini-format resource error
- `403`: Gemini-format resource error
- `404`: Gemini-format resource error
- `409`: Gemini-format resource error
- `429`: Gemini-format resource error
- `502`: Gemini-format resource error
- `503`: Gemini-format resource error

---

[API](https://skmtc.dev/tokenlab/apis/tokenlab-ai-gateway.md) · [All operations](https://skmtc.dev/tokenlab/apis/tokenlab-ai-gateway/llms.txt) · [OpenAPI document](https://skmtc.dev/tokenlab/apis/tokenlab-ai-gateway/revisions/3208bfbcda22?raw)
