fix(billing): price Anthropic 1-hour cache writes separately - #1201
fix(billing): price Anthropic 1-hour cache writes separately#1201atirna wants to merge 1 commit into
Conversation
Signed-off-by: Atirna <288419661+atirna@users.noreply.github.com>
|
Thank you so much for this, @atirna — this is a genuinely valuable fix. The 1-hour tier was silently under-billed, and you threaded the split through every surface (extractor, translator sink, handover usage, stream cost writer, billing debit) with careful edge handling (clamping, aggregate-only fallback, the web_search remainder). Really nice work, and To match a couple of internal conventions I've re-opened it as #1203 with your code intact and you credited as co-author. This is not on you at all — these rules live in our
Everything else — production logic, tests, structure — is exactly as you wrote it. Thanks again, and please keep them coming! |
Summary
Why
The aggregate cache-creation count currently prices every write at the 5-minute rate, including the 1-hour tier.
Verification
main: 10 fresh tokens plus 1M 1-hour cache writes at $5/M calculated to $6.250050 instead of $10.000050.go test ./internal/router/catalog ./internal/observability/otel ./internal/translate ./internal/billing -count=1andgo test ./internal/proxy -count=1pass. The catalog test covers 1-hour, mixed-tier, aggregate-only, and inconsistent usage breakdowns.Fixes #867