pub struct CostCalculator { /* private fields */ }Expand description
Computes real-time USD cost with per-tool breakdown and cache discount.
Implementations§
Source§impl CostCalculator
impl CostCalculator
Sourcepub fn new(pricing_config: &PricingConfig) -> Self
pub fn new(pricing_config: &PricingConfig) -> Self
Create a new CostCalculator from the supplied pricing configuration.
Sourcepub fn with_defaults() -> Self
pub fn with_defaults() -> Self
Create a CostCalculator with the built-in default pricing.
Sourcepub fn compute_cost(
&self,
model: &ModelFamily,
tokens: &TokenUsage,
) -> CostBreakdown
pub fn compute_cost( &self, model: &ModelFamily, tokens: &TokenUsage, ) -> CostBreakdown
Compute the cost for a single TokenUsage against the given model.
If the model is not found in the pricing table the cost is zero.
Sourcepub fn session_summary(&self, session: &SessionState) -> SessionCostSummary
pub fn session_summary(&self, session: &SessionState) -> SessionCostSummary
Produce a session-level cost summary from a SessionState.
The session’s budget.model_family determines which pricing to use.
Per-tool costs are derived from session.tool_usage.
Auto Trait Implementations§
impl Freeze for CostCalculator
impl RefUnwindSafe for CostCalculator
impl Send for CostCalculator
impl Sync for CostCalculator
impl Unpin for CostCalculator
impl UnsafeUnpin for CostCalculator
impl UnwindSafe for CostCalculator
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more