Prompt caching
Enabling prompt caching lowers inference cost: input tokens served from the cache are billed at each model's cache rate, which is below the regular input rate. See Pricing for the exact numbers. GPT, Grok, Kimi, DeepSeek, and GLM cache automatically upstream with no change to the request; Claude only caches content marked with cache_control, and unmarked content is billed at the regular input rate; Gemini currently returns no cache fields. Moyi API passes the cache parameters through unchanged, and the usage fields in the response tell you whether the cache was hit.
Inspecting cache usage
The usage object in the response carries the number of tokens this request wrote to and read from the cache; on a miss they are 0 or absent. If both stay at 0, caching is not enabled or the content is shorter than the model's minimum cacheable length.
Usage object fields
| Protocol | Field | Meaning |
|---|---|---|
| Anthropic | usage.cache_creation_input_tokens |
Input tokens written to the cache by this request |
| Anthropic | usage.cache_read_input_tokens |
Input tokens read from the cache by this request |
| Anthropic | usage.cache_creation.ephemeral_5m_input_tokens / ephemeral_1h_input_tokens |
Cache writes split by cache lifetime |
| OpenAI | usage.prompt_tokens_details.cached_tokens |
Prompt tokens served from the cache |
On the billing side these map to cached_write_tokens and cached_read_tokens in Get request usage.
OpenAI
Caching for GPT models is handled upstream; the request needs no parameters. When the same content is sent again, usage.prompt_tokens_details.cached_tokens is greater than 0.
Grok
Automatic caching; the request needs no parameters. On a hit, usage.prompt_tokens_details.cached_tokens is greater than 0.
Moonshot Kimi
Automatic caching; the request needs no parameters. On a hit, usage.prompt_tokens_details.cached_tokens is greater than 0.
Anthropic Claude
Claude only caches content marked with cache_control. Add it to system or to a message content block, exactly as in the Anthropic format:
{
"model": "claude-sonnet-5",
"max_tokens": 256,
"system": [
{"type": "text", "text": "<a long system prompt>", "cache_control": {"type": "ephemeral"}}
],
"messages": [{"role": "user", "content": "Hello"}]
}
A request without cache_control always reports cache_creation_input_tokens and cache_read_input_tokens as 0, and all input is billed at the regular input rate.
Minimum token requirements
Short content is not cached: below the upstream model's minimum cacheable length, both cache_creation_input_tokens and cache_read_input_tokens are 0 and the request succeeds as usual.
DeepSeek
Automatic caching; the request needs no parameters. On a hit, usage.prompt_tokens_details.cached_tokens is greater than 0.
Z.AI GLM
Automatic caching; the request needs no parameters. On a hit, usage.prompt_tokens_details.cached_tokens is greater than 0; repeated requests to glm-5.3 and glm-5.2 hit the cache in our tests.
Google Gemini
Neither the Gemini native endpoint nor the OpenAI-compatible endpoint returns cache fields for Gemini; all input is billed at the regular input rate.