Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/cortex-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ uuid = { workspace = true }
toml = { workspace = true }
toml_edit = { workspace = true }
serde_yaml = "0.9"
llm-prices = "1.8.0"
serde = { workspace = true }
ctor = "0.5"
base64 = { workspace = true }
Expand Down
20 changes: 20 additions & 0 deletions src/cortex-cli/src/stats_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,16 @@ fn get_model_pricing(model: &str) -> ModelPricing {
}
}

// Dated, source-cited list prices for known model ids.
if let Some(p) = llm_prices::lookup(model) {
if let (Some(input), Some(output)) = (p.input, p.output) {
return ModelPricing {
input_per_million: input,
output_per_million: output,
};
}
}

// Fall back to default pricing (may be outdated - users can override via CORTEX_PRICING_*)
// Pricing per 1M tokens (as of late 2024/early 2025 - may change)
match model {
Expand Down Expand Up @@ -724,6 +734,16 @@ mod tests {
assert_eq!(infer_provider("deepseek-chat"), "deepseek");
}

#[test]
fn test_current_model_list_prices() {
// Opus 4.5 is $5/$25, not the Opus 4 rate of $15/$75.
let cost = calculate_cost("claude-opus-4-5", 1_000_000, 1_000_000);
assert!((cost - 30.0).abs() < 0.001);
// o3 is $2/$8.
let cost = calculate_cost("o3", 1_000_000, 1_000_000);
assert!((cost - 10.0).abs() < 0.001);
}

#[test]
fn test_calculate_cost() {
// Claude Sonnet 4: $3/$15 per 1M
Expand Down