pub fn calculate_cost(
model: &str,
input_tokens: u64,
output_tokens: u64,
cache_read: u64,
cache_creation: u64,
) -> f64Expand description
Calculate the USD cost of a single model turn (no cache-write TTL split).
Thin wrapper over calculate_cost_split: the aggregate cache_creation
count is billed at the 5m write rate (1.25×). When the user opted into 1h
caching but the TTL split didn’t arrive, this under-bills (fail-cheap, not
fail-expensive — cost display is informational, not invoiced).
§Arguments
model– Model identifier string (e.g."claude-sonnet-4-5").input_tokens– Uncached input tokens billed at full input rate.output_tokens– Output / generated tokens (includes adaptive thinking).cache_read– Tokens served from the prompt cache (0.10× input rate).cache_creation– Tokens written to the prompt cache (1.25× input rate).
§Returns
Cost in USD for this turn.