Cached input on GLM-5.2 is 80% off. Other open source models cache automatically too; their cached tokens currently bill at the regular input rate.
Reading cache hits
Every response reports how much of the prompt was served from cache:cached_tokens billed at the cached rate, the remainder of prompt_tokens at the input rate.
Getting hits

- Put stable content first: system prompt, then tool definitions, then history. Variable content (the user’s latest message, retrieved context) goes last.
- Keep the prefix byte-identical between turns. A timestamp or request ID in the system prompt kills every hit after it.
- Short prompts rarely hit. Caching operates on ~1k-token blocks, so a 300-token prompt has nothing to reuse.
Cache TTL
By default cached prefixes persist under LRU eviction, with no fixed expiry. To control retention per request, passcache_ttl:
Expiry is sliding, Anthropic-style: every cache hit refreshes the clock. Past the TTL the prefix stops hitting entirely (full recompute), and re-sending it caches it fresh. A prefix shared by multiple requests keeps the longest surviving TTL.
cache_ttl is rolling out now, GLM-5.2 first and Kimi K3 at launch. Requests that include it are accepted today; the field takes effect as each model’s rollout completes.- cURL
- Python
- TypeScript
- Invalid
cache_ttlvalues are rejected with a 400. Only the five tiers above are accepted. - Expiry granularity is ~30 seconds: treat a TTL as “at least this long, expired within ~30s after.”
- Omitting
cache_ttlkeeps the default behavior (LRU, no fixed expiry).
Pitfalls
cached_tokens is 0 on every request
cached_tokens is 0 on every request
Your prefix is changing between requests. Diff two consecutive prompts byte-for-byte; the first divergent token ends the cacheable prefix. Common culprits: timestamps, UUIDs, or shuffled tool order in the system prompt.
Hits stop after an edit mid-conversation
Hits stop after an edit mid-conversation
Editing an earlier message invalidates everything after it. Expected: caching is prefix-based, so append, don’t rewrite.
See Also
- Standby Requests — stack a 50% tier discount on top: cached standby input is $0.11/1M
- Open Source Models — the models this page prices
- Compact — shrink context before caching it