pub struct CostCalculator { /* private fields */ }Implementations§
Source§impl CostCalculator
impl CostCalculator
Sourcepub fn estimate_cost(
&self,
model_name: &str,
input_tokens: usize,
output_tokens: usize,
) -> Result<CostEstimate, CostError>
pub fn estimate_cost( &self, model_name: &str, input_tokens: usize, output_tokens: usize, ) -> Result<CostEstimate, CostError>
Estimate cost for a given model and token counts
Sourcepub fn estimate_cost_from_text(
&self,
model_name: &str,
input_text: &str,
estimated_output_tokens: usize,
) -> Result<CostEstimate, CostError>
pub fn estimate_cost_from_text( &self, model_name: &str, input_text: &str, estimated_output_tokens: usize, ) -> Result<CostEstimate, CostError>
Estimate cost from text (estimates tokens)
Sourcepub fn check_budget(&self, spent: f64, budget: f64) -> BudgetStatus
pub fn check_budget(&self, spent: f64, budget: f64) -> BudgetStatus
Check budget status
Sourcepub fn get_cheapest_model(
&self,
min_context_window: usize,
) -> Option<&ModelPricing>
pub fn get_cheapest_model( &self, min_context_window: usize, ) -> Option<&ModelPricing>
Get cheapest model for a given context size
Sourcepub fn get_models_under_cost(&self, max_cost_per_1k: f64) -> Vec<&ModelPricing>
pub fn get_models_under_cost(&self, max_cost_per_1k: f64) -> Vec<&ModelPricing>
Get all models under a cost threshold (per 1k tokens average)
Sourcepub fn get_models_by_provider(&self, provider: &str) -> Vec<&ModelPricing>
pub fn get_models_by_provider(&self, provider: &str) -> Vec<&ModelPricing>
Get models by provider
Sourcepub fn compare_models(
&self,
model_a: &str,
model_b: &str,
input_tokens: usize,
output_tokens: usize,
) -> Result<ModelComparison, CostError>
pub fn compare_models( &self, model_a: &str, model_b: &str, input_tokens: usize, output_tokens: usize, ) -> Result<ModelComparison, CostError>
Compare cost between two models for given usage
Sourcepub fn add_model(&mut self, pricing: ModelPricing)
pub fn add_model(&mut self, pricing: ModelPricing)
Add custom model pricing
Sourcepub fn remove_model(&mut self, model_name: &str) -> Option<ModelPricing>
pub fn remove_model(&mut self, model_name: &str) -> Option<ModelPricing>
Remove a model from pricing table
Sourcepub fn get_all_models(&self) -> Vec<&ModelPricing>
pub fn get_all_models(&self) -> Vec<&ModelPricing>
Get all available models
Sourcepub fn project_monthly_cost(
&self,
model_name: &str,
daily_input_tokens: usize,
daily_output_tokens: usize,
days_per_month: f64,
) -> Result<CostProjection, CostError>
pub fn project_monthly_cost( &self, model_name: &str, daily_input_tokens: usize, daily_output_tokens: usize, days_per_month: f64, ) -> Result<CostProjection, CostError>
Calculate monthly cost projection
Trait Implementations§
Auto Trait Implementations§
impl Freeze for CostCalculator
impl RefUnwindSafe for CostCalculator
impl Send for CostCalculator
impl Sync for CostCalculator
impl Unpin 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