Expand description
Provider-normalized token usage and shared raw/cache-aware USD estimates.
Structs§
- Session
Cost Accumulator - Accumulates independently priced turns without repricing earlier model routes. Once a turn cannot be priced, a complete session total remains unknown.
- Session
Cost Estimate - Cache-aware and conservative session cost estimates in USD.
Constants§
- DEFAULT_
CACHE_ WRITE_ MULTIPLIER - Default cache-write multiplier versus uncached input (5m TTL).
- EXTENDED_
TTL_ CACHE_ WRITE_ MULTIPLIER - Anthropic 1h extended-TTL cache writes cost 2x base input.
Functions§
- cache_
write_ rate - Effective cache-write rate.
extended_ttlselects the 2x 1h multiplier when the catalog does not declare an explicit write rate. - estimate_
session_ costs - Resolve pricing for
provider/modeland estimate session costs from accumulated harness usage. ReturnsNonewhen the model cannot be resolved or pricing metadata is unavailable. - estimate_
session_ costs_ with_ pricing - Estimate session costs from an already-resolved
ModelPricing. - normalized_
turn_ usage - Build a per-turn harness
Usagesample from raw provider usage, applying the provider-specific normalization documented onprovider_reports_exclusive_inputsoinput_tokensalways represents the total prompt token count across every provider. - prompt_
tokens_ for_ rate_ limit - Prompt volume that counts toward provider TPM-style rate limits. Cached and cache-write tokens are cheaper but still consume provider capacity.
- provider_
reports_ exclusive_ input - Returns true when
providerreportsprompt_tokensexclusive of cache-read and cache-creation tokens. - require_
budget_ pricing - Reject a priced session budget when its selected route cannot be priced. Call before any inference, including automatic compaction.