Problem
The usage ledger estimates spend from token counts at a fixed rate (DEFAULT_USD_PER_MTOK). OpenRouter reports the real cost on each Decisions response as usage.cost in USD (docs), for example "usage": { "input_tokens": 275, "output_tokens": 20, "cost": 0.00003 }. The TypeSafe backend returns no cost.
Wanted
- When a response carries a valid
usage.cost, record it in the ledger, so maxUsdPerDay and status lines follow what was actually billed.
- Otherwise, keep the estimate.
- A missing or malformed
cost is ignored, never an error. Response validation keeps passing either way.
- Existing public types keep
estimatedUsd. New fields may be added.
Problem
The usage ledger estimates spend from token counts at a fixed rate (
DEFAULT_USD_PER_MTOK). OpenRouter reports the real cost on each Decisions response asusage.costin USD (docs), for example"usage": { "input_tokens": 275, "output_tokens": 20, "cost": 0.00003 }. The TypeSafe backend returns no cost.Wanted
usage.cost, record it in the ledger, somaxUsdPerDayand status lines follow what was actually billed.costis ignored, never an error. Response validation keeps passing either way.estimatedUsd. New fields may be added.