Skip to content
Merged
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
11 changes: 9 additions & 2 deletions rust/src/core/cost_pricing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -620,11 +620,18 @@ impl CostUsagePricing {
return Self::CODEX_UNATTRIBUTED_MODEL.to_string();
}

// Remove "openai/" prefix
if let Some(rest) = trimmed.strip_prefix("openai/") {
// Remove the provider-qualified OpenAI prefix.
if let Some((prefix, rest)) = trimmed.split_once('/')
&& prefix.eq_ignore_ascii_case("openai")
{
trimmed = rest.to_string();
}

// Codex uses this alias for the Luna reserve quota bucket.
if trimmed.eq_ignore_ascii_case("gpt-reserve") {
return "gpt-5.6-luna".to_string();
}

// Check if base model (without -codex suffix) exists in pricing
if let Some(idx) = trimmed.find("-codex") {
let base = &trimmed[..idx];
Expand Down
40 changes: 40 additions & 0 deletions rust/src/core/cost_pricing_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,30 @@ fn test_normalize_codex_model() {
CostUsagePricing::normalize_codex_model("unknown"),
CostUsagePricing::CODEX_UNATTRIBUTED_MODEL
);
assert_eq!(
CostUsagePricing::normalize_codex_model("gpt-reserve"),
"gpt-5.6-luna"
);
assert_eq!(
CostUsagePricing::normalize_codex_model(" GPT-RESERVE "),
"gpt-5.6-luna"
);
assert_eq!(
CostUsagePricing::normalize_codex_model("openai/gpt-reserve"),
"gpt-5.6-luna"
);
assert_eq!(
CostUsagePricing::normalize_codex_model("OPENAI/GPT-RESERVE"),
"gpt-5.6-luna"
);
assert_eq!(
CostUsagePricing::normalize_codex_model("gpt-reserve-preview"),
"gpt-reserve-preview"
);
assert_eq!(
CostUsagePricing::normalize_codex_model("my-gpt-reserve"),
"my-gpt-reserve"
);
}

#[test]
Expand Down Expand Up @@ -168,6 +192,22 @@ fn test_gpt56_standard_pricing() {
}
}

#[test]
fn gpt_reserve_alias_uses_luna_pricing() {
let luna =
CostUsagePricing::codex_cost_usd("gpt-5.6-luna", 1_000, 400, 1_000).expect("Luna pricing");
for model in [
"gpt-reserve",
" GPT-RESERVE ",
"openai/gpt-reserve",
"OPENAI/GPT-RESERVE",
] {
let reserve =
CostUsagePricing::codex_cost_usd(model, 1_000, 400, 1_000).expect("reserve pricing");
assert!((reserve - luna).abs() < 1e-10, "{model}");
}
}

#[test]
fn test_gpt56_long_context_pricing() {
for (model, expected) in [
Expand Down