use super::ModelPricing;
use crate::model::AiPrice;
use genai::ModelIden;
use genai::chat::Usage;
pub fn price_it(provider_type: &str, model_name: &str, usage: &Usage) -> Option<AiPrice> {
let ai_cost = aicost::compute(provider_type, model_name, usage).ok()?;
Some(AiPrice {
cost: ai_cost.total,
cost_cache_write: (ai_cost.input_cache_write > 0.0).then_some(ai_cost.input_cache_write),
cost_cache_saving: (ai_cost.input_cache_saving > 0.0).then_some(ai_cost.input_cache_saving),
})
}
pub fn model_pricing(model_iden: &ModelIden) -> Option<ModelPricing> {
let pricing = aicost::model_pricing(model_iden)?;
Some(ModelPricing {
name: pricing.name,
input_cached: pricing.input_cached,
input_normal: pricing.input_normal,
output_normal: pricing.output_normal,
output_reasoning: pricing.output_reasoning,
})
}