Skip to main content

Module cost_calculator

Module cost_calculator 

Source

Structs§

CostBreakdown
Full cost breakdown for a single compute_cost call.
CostCalculator
Computes real-time USD cost with per-tool breakdown and cache discount.
ModelPricing
Per-model pricing rates.
PricingConfig
Top-level pricing configuration passed to CostCalculator::new.
SavedCostEstimate
Output of estimate_saved_cost.
SavingsAssumptions
Assumptions behind estimate_saved_cost. Token reduction is not the same thing as billed-cost reduction (arXiv:2607.12161): with provider prompt caching, a tool-output token is written to the cache once at a write premium and then re-read at a steep discount on every subsequent turn. A saved token therefore avoids one cache write plus N cache reads — not one list-price input token.
SessionCostSummary
Session-level cost summary.
TokenUsage
Token counts for a single request / tool call.
ToolCost
Per-tool cost record.

Functions§

estimate_saved_cost
Estimate the billed cost avoided by tokens_saved under a prompt-cached serving model. This deliberately models the caching-enabled case, which is the conservative one: without caching every re-read bills at full input price and the figure would be much larger. Direct token cost only — trajectory effects (extra agent turns caused by missing detail) are not modeled here; the regret metrics in sqz stats exist to watch for those.