#1670
fix(report): price prompt-cache writes at their own rate
Part of #1667 (the cache-write half; the ~1.33x token total is a separate question and is not touched here).
_configured_usage_cost read input_tokens and input_tokens_details.cached_tokens only, so prompt-cache writes were charged at the plain input rate — the SDK reports them apart as input_tokens_details.cache_write_tokens, and providers bill them above a normal input token.
- new setting
cached_input_write_cost_per_mtok/STRIX_LLM_CACHED_INPUT_WRITE_COST_PER_MTOK; - write tokens are taken out of the plainly-billed input and priced at that rate, so they cannot be charged twice;
- with no write rate configured they stay at the input rate — exactly what the function charged before, so existing configurations report the same total.
Validation (pytest tests/test_pricing.py -q -> 22 passed):
| case | expected |
|---|---|
| 1000 input = 400 plain + 500 reads + 100 writes, rates 2 / 8 / 0.25 / 2.5 per Mtok | (400·2 + 500·0.25 + 100·2.5 + 200·8)/1e6 |
| same usage with no write rate | the pre-change total (500·2 + 500·2 + 200·8)/1e6 |
Reverting the source change fails the first case and keeps the second passing, which is what pins the no-regression behaviour. ruff check + format clean.
Activity
7greptile-apps[bot]reviewed1d ago
Preview approval required
This pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit 6b88d77.
lxcxjxhxreviewed1d ago
[Medium impact] The change affects cost estimates in Strix usage reports.
The PR appears safe to merge, with a non-blocking documentation gap.
Findings
Fix with agent prompt
Summary
Adds a separate price for prompt-cache writes.
Reviews (1) · Last reviewed commit: "fix(report): price prompt-cache writes a..." · Reviewed by Greptile