ai_lib/provider/
pricing.rs1use crate::client::Provider;
9#[cfg(feature = "routing_mvp")]
10use crate::provider::models::PricingInfo;
11
12#[cfg(not(feature = "routing_mvp"))]
13#[derive(Debug, Clone)]
14pub struct PricingInfo {
15 pub input_cost_per_1k: f64,
16 pub output_cost_per_1k: f64,
17}
18
19#[cfg(not(feature = "routing_mvp"))]
20impl PricingInfo {
21 pub fn new(input_cost_per_1k: f64, output_cost_per_1k: f64) -> Self {
22 Self { input_cost_per_1k, output_cost_per_1k }
23 }
24}
25
26pub fn get_pricing(provider: Provider, model: &str) -> Option<PricingInfo> {
29 let m = model.to_ascii_lowercase();
30 match provider {
31 Provider::OpenAI => match m.as_str() {
32 "gpt-3.5-turbo" => Some(PricingInfo::new(0.50, 1.50)),
34 "gpt-4o" => Some(PricingInfo::new(5.00, 15.00)),
35 _ => None,
36 },
37 Provider::Groq => match m.as_str() {
38 "llama-3.1-8b-instant" | "llama3-8b" => Some(PricingInfo::new(0.05, 0.08)),
39 _ => None,
40 },
41 Provider::DeepSeek => match m.as_str() {
42 "deepseek-chat" => Some(PricingInfo::new(0.27, 1.10)),
43 "deepseek-reasoner" => Some(PricingInfo::new(0.55, 2.20)),
44 _ => None,
45 },
46 Provider::Mistral => match m.as_str() {
47 "mistral-small" => Some(PricingInfo::new(0.20, 0.60)),
48 _ => None,
49 },
50 Provider::Cohere => match m.as_str() {
51 "command-r" => Some(PricingInfo::new(0.50, 1.50)),
52 _ => None,
53 },
54 Provider::Gemini => match m.as_str() {
55 "gemini-pro" | "gemini-1.5-flash" => Some(PricingInfo::new(0.10, 0.30)),
56 _ => None,
57 },
58 Provider::AzureOpenAI
59 | Provider::Anthropic
60 | Provider::HuggingFace
61 | Provider::TogetherAI
62 | Provider::OpenRouter
63 | Provider::Replicate
64 | Provider::ZhipuAI
65 | Provider::MiniMax
66 | Provider::Perplexity
67 | Provider::AI21
68 | Provider::Qwen
69 | Provider::BaiduWenxin
70 | Provider::TencentHunyuan
71 | Provider::IflytekSpark
72 | Provider::Moonshot
73 | Provider::Ollama
74 | Provider::XaiGrok => None,
75 }
76}