Compute the USD cost for a pair of token counts. Uses [`COST_PER_M_INPUT`] and [`COST_PER_M_OUTPUT`] so every layer that touches token accounting produces identical values. # Example ``` use atomic_agent::provenance::detail::compute_cost; let cost = compute_cost(16_083, 3_746); let expected = (16_083.0 / 1_000_000.0) * 5.0 + (3_746.0 / 1_000_000.0) * 25.0; assert!((cost - expected).abs() < 1e-9
(input_tokens: u32, output_tokens: u32)
| 59 | /// assert!((cost - expected).abs() < 1e-9); |
| 60 | /// ``` |
| 61 | pub fn compute_cost(input_tokens: u32, output_tokens: u32) -> f64 { |
| 62 | (input_tokens as f64 / 1_000_000.0) * COST_PER_M_INPUT |
| 63 | + (output_tokens as f64 / 1_000_000.0) * COST_PER_M_OUTPUT |
| 64 | } |
| 65 | |
| 66 | // --------------------------------------------------------------------------- |
| 67 | // Shared sub-structs |
no outgoing calls