#1670

fix(report): price prompt-cache writes at their own rate

Openlxcxjxhxwants to merge intofrom

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):

caseexpected
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 ratethe 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

7
greptile-apps[bot]1d ago

Confidence Score: 4/5

[Medium impact] The change affects cost estimates in Strix usage reports.

The PR appears safe to merge, with a non-blocking documentation gap.

Findings

  1.  Cache-write price is undocumented ▶
Fix with agent prompt
### Issue 1
strix/config/settings.py:75-76
`docs/advanced/configuration.mdx` lists only the three older prices, so users following the guide cannot discover `STRIX_LLM_CACHED_INPUT_WRITE_COST_PER_MTOK`. Add it alongside those settings, including its USD-per-million unit and its fallback to the input price when unset.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

Adds a separate price for prompt-cache writes.

  • Usage reports can price prompt-cache writes separately.

Reviews (1) · Last reviewed commit: "fix(report): price prompt-cache writes a..." · Reviewed by Greptile

greptile-apps[bot]reviewed1d ago
mintlify[bot]1d 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.

Approve preview

lxcxjxhxreviewed1d ago