Skip to main content
POST
Create Cached Content

Authorizations

x-goog-api-key
string
header
required

Tikway API Key. Passed through the x-goog-api-key request header according to the Gemini native protocol.

Body

application/json

Create a request body for cached content. The cached content is preprocessed and can be reused in subsequent build requests. The cache can only be used for the model specified when it was created.

model
string
required

The name of the model resource used to create and use this cache. The cache can only be used for the models specified here, in the format models/{model}. This field is required and cannot be modified after creation.

Pattern: ^models/[^/]+$
Examples:

"models/gemini-1.5-flash-001"

"models/gemini-2.5-flash"

contents
object[]

A list of content that needs to be cached. It can contain a single round of content, or it can contain multiple historical rounds of content in dialogue order. This field is for input only and cannot be modified after the cache is created.

Minimum array length: 1
tools
object[]

A list of tools that the model can use when subsequently generating content. This field is for input only and cannot be modified after the cache is created.

expireTime
string<date-time>

Absolute time of cache expiration, using RFC 3339 format. The server output will be normalized to UTC time. This field is mutually exclusive with ttl, at most one of them can be set.

Examples:

"2026-09-08T12:00:00Z"

"2026-09-08T12:00:00.123Z"

ttl
string

The relative validity period of the cache, in seconds, supports up to 9 decimal places, and ends with s. This field is for input only and is mutually exclusive with expireTime.

Pattern: ^[0-9]+(?:\.[0-9]{1,9})?s$
Examples:

"300s"

"3600s"

"3.5s"

displayName
string

A human-readable name set by the user for the cached content, containing up to 128 Unicode characters. This field cannot be modified after the cache is created.

Maximum string length: 128
systemInstruction
object

System commands set by the developer. Currently only plain text Parts are supported. This field is for input only and cannot be modified after the cache is created.

toolConfig
object

Tool call configuration. This configuration is shared by all tools and is only used for input. The cache cannot be modified after it is created.

Response

200 - application/json

The cached content resource returned after successful creation. The response mainly contains cache identification, model, creation time, update time, actual expiration time and token usage.

name
string
required

The unique resource name of cached content, generated by the server, in the format cachedContents/{id}.

Pattern: ^cachedContents/[^/]+$
Example:

"cachedContents/abc123def456"

model
string
required

The name of the model resource bound to this cache. Caching can only be used with this model.

Pattern: ^models/[^/]+$
Example:

"models/gemini-1.5-flash-001"

expireTime
string<date-time>
required

The absolute time at which the cache actually expires. Regardless of whether expireTime or ttl is used in the request, the server will return this field in the response.

Example:

"2026-09-08T11:00:00Z"

displayName
string

The human-readable name set when creating the cache. This field may not be returned when not set.

Maximum string length: 128
createTime
string<date-time>

The creation time of the cached resource, generated by the server, in RFC 3339 format and usually normalized to UTC time.

Example:

"2026-09-08T10:00:00Z"

updateTime
string<date-time>

The time when the cached resource was last updated, generated by the server, in RFC 3339 format and usually normalized to UTC time.

Example:

"2026-09-08T10:00:00Z"

usageMetadata
object

Token usage information for cached content.