pub struct CostTracker { /* private fields */ }Expand description
Tracks API costs across model invocations.
Implementations§
Source§impl CostTracker
impl CostTracker
Sourcepub fn estimate_cost(
&self,
model_name: &str,
input_tokens: u64,
output_tokens: u64,
) -> f64
pub fn estimate_cost( &self, model_name: &str, input_tokens: u64, output_tokens: u64, ) -> f64
Estimate the cost for a given model and token count.
Sourcepub fn record(
&self,
model_role: ModelRole,
model_name: &str,
input_tokens: u64,
output_tokens: u64,
)
pub fn record( &self, model_role: ModelRole, model_name: &str, input_tokens: u64, output_tokens: u64, )
Record an actual cost event.
Sourcepub fn total_cost(&self) -> f64
pub fn total_cost(&self) -> f64
Get total cost across all recorded events.
Sourcepub fn cost_by_role(&self) -> HashMap<ModelRole, f64>
pub fn cost_by_role(&self) -> HashMap<ModelRole, f64>
Get cost breakdown by model role.
Trait Implementations§
Source§impl Clone for CostTracker
impl Clone for CostTracker
Source§fn clone(&self) -> CostTracker
fn clone(&self) -> CostTracker
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for CostTracker
impl Debug for CostTracker
Auto Trait Implementations§
impl Freeze for CostTracker
impl RefUnwindSafe for CostTracker
impl Send for CostTracker
impl Sync for CostTracker
impl Unpin for CostTracker
impl UnsafeUnpin for CostTracker
impl UnwindSafe for CostTracker
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