Pricing, metering & prompt caching
Per-token billing, cache-hit subsidies, and how to read usage.cost.
Per-token, per request
Billing is post-paid against a prepaid wallet: every request is metered on actual tokens used, and the response reports exactly what it cost.
cost = prompt_tokens_miss × prompt_rate
+ prompt_tokens_cached × input_cache_read_rate
+ completion_tokens × completion_rate
All rates are USD per 1M tokens, published live at GET /api/v1/models. Example
(glm-5.3-flash): 1,000 miss input tokens + 50,000 cached input tokens + 2,000 output
tokens:
0.001 × $0.15 = $0.00015
0.050 × $0.03 = $0.00150
0.002 × $0.50 = $0.00100
= $0.00265 total
How billing executes
Before your request runs, an estimate (prompt + worst-case max_tokens) is
reserved from your balance. When the stream completes, the reservation is settled
against actual usage and the difference is refunded automatically. If the request
fails upstream or you disconnect mid-stream, the reservation is refunded in full —
you are only ever charged for delivered tokens.
Prompt caching (the discount you get for free)
Models with prompt caching bill repeated identical prefixes at the subsidized
input_cache_read rate — up to 10× cheaper than a miss. The split is automatic and
reported per request:
"usage": {
"prompt_tokens": 51234,
"prompt_tokens_details": { "cached_tokens": 50176 },
"completion_tokens": 312,
"cost": 0.0192
}
To maximize hits: keep your system prompt (schemas, few-shots, RAG corpus) static and
byte-identical at the start of messages, and put variable content last. See the
blog post "Your prompts are cached" for patterns.
Reading your spend
usage.costin every response — per-request truthGET /api/v1/key— live balance + in-flight reservations- Console → Usage — per-model spend, latency percentiles, daily charts
- Console → Billing — full ledger (every charge, top-up, refund)