pub fn calculate_cost_optional_split(
model: &str,
input_tokens: u64,
output_tokens: u64,
cache_read: u64,
cache_creation: u64,
cache_creation_5m: Option<u64>,
cache_creation_1h: Option<u64>,
) -> f64Expand description
Split-aware cost for callers holding an aggregate plus an optional TTL
split (the shape of SessionEvent::Usage). When either split bucket is
present, preserve its known count and assign any aggregate remainder to
the conservative 1h rate. This is an estimate, not an inferred TTL. A split
sum exceeding the aggregate is malformed metadata: retain the larger split
sum rather than dropping known writes or lowering the request’s price tier.
Arithmetic saturates. When both are None, TTL is explicitly unknown and
the existing aggregate-at-5m estimate is retained (potentially underbilling).