| 365 | } |
| 366 | |
| 367 | fn infer_provider(model: &str) -> &'static str { |
| 368 | let model = model.to_ascii_lowercase(); |
| 369 | if model.starts_with("claude-") |
| 370 | || model.starts_with("anthropic/") |
| 371 | || model.starts_with("anthropic.") |
| 372 | { |
| 373 | "anthropic" |
| 374 | } else if model.starts_with("gpt-") |
| 375 | || model.starts_with("o1") |
| 376 | || model.starts_with("o3") |
| 377 | || model.starts_with("o4") |
| 378 | || model.starts_with("openai/") |
| 379 | { |
| 380 | "openai" |
| 381 | } else if model.starts_with("gemini") || model.starts_with("google/") { |
| 382 | "google" |
| 383 | } else if model.starts_with("grok") || model.starts_with("xai/") { |
| 384 | "xai" |
| 385 | } else if model.starts_with("openrouter/") { |
| 386 | "openrouter" |
| 387 | } else { |
| 388 | "unknown" |
| 389 | } |
| 390 | } |
| 391 | |
| 392 | pub(super) fn calculate_codebuff_cost(entry: &CodebuffEntry, pricing: &PricingMap) -> f64 { |
| 393 | let usage = TokenUsageRaw { |