Skip to content

Commit 43eacfe

Browse files
authored
Add pricing for GPT-5.4 nano and GPT-4.5 (#144)
1 parent 81e3efc commit 43eacfe

1 file changed

Lines changed: 64 additions & 0 deletions

File tree

src/models.rs

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,16 @@ static MODEL_INDEX: phf::Map<&'static str, ModelInfo> = phf_map! {
232232
caching: CachingSupport::None,
233233
is_estimated: false,
234234
},
235+
"gpt-4.5" => ModelInfo {
236+
pricing: PricingStructure::Flat {
237+
input_per_1m: 75.0,
238+
output_per_1m: 150.0,
239+
},
240+
caching: CachingSupport::OpenAI {
241+
cached_input_per_1m: 37.5,
242+
},
243+
is_estimated: false,
244+
},
235245
"gpt-5" => ModelInfo {
236246
pricing: PricingStructure::Flat {
237247
input_per_1m: 1.25,
@@ -420,6 +430,16 @@ static MODEL_INDEX: phf::Map<&'static str, ModelInfo> = phf_map! {
420430
},
421431
is_estimated: false,
422432
},
433+
"gpt-5.4-nano" => ModelInfo {
434+
pricing: PricingStructure::Flat {
435+
input_per_1m: 0.20,
436+
output_per_1m: 1.25,
437+
},
438+
caching: CachingSupport::OpenAI {
439+
cached_input_per_1m: 0.02,
440+
},
441+
is_estimated: false,
442+
},
423443

424444
// Anthropic Models
425445
"claude-opus-4-7" => ModelInfo {
@@ -1071,6 +1091,7 @@ static MODEL_ALIASES: phf::Map<&'static str, &'static str> = phf_map! {
10711091
"codex-mini-latest" => "codex-mini-latest",
10721092
"gpt-4-turbo" => "gpt-4-turbo",
10731093
"gpt-4-turbo-2024-04-09" => "gpt-4-turbo",
1094+
"gpt-4.5" => "gpt-4.5",
10741095
"gpt-5" => "gpt-5",
10751096
"gpt-5-codex" => "gpt-5",
10761097
"gpt-5-2025-08-07" => "gpt-5",
@@ -1191,6 +1212,7 @@ static MODEL_ALIASES: phf::Map<&'static str, &'static str> = phf_map! {
11911212
"gpt-5.4-mini" => "gpt-5.4-mini",
11921213
"gpt-5.4-mini-2026-03-17" => "gpt-5.4-mini",
11931214
"gpt-5.4-mini-2026-03-17." => "gpt-5.4-mini",
1215+
"gpt-5.4-nano" => "gpt-5.4-nano",
11941216

11951217
// MiniMax aliases
11961218
"minimax-m2.1" => "minimax-m2.1",
@@ -1592,4 +1614,46 @@ mod tests {
15921614
approx_eq(calculate_output_cost("auto", 1_000_000), 0.0);
15931615
approx_eq(calculate_cache_cost("auto", 1_000_000, 1_000_000), 0.0);
15941616
}
1617+
1618+
#[test]
1619+
fn gpt_5_4_nano_pricing_is_available() {
1620+
let model_info = get_model_info("gpt-5.4-nano").expect("model should exist");
1621+
assert!(!model_info.is_estimated);
1622+
1623+
let input_cost = calculate_input_cost("gpt-5.4-nano", 1_000_000);
1624+
let output_cost = calculate_output_cost("gpt-5.4-nano", 1_000_000);
1625+
let cache_cost = calculate_cache_cost("gpt-5.4-nano", 0, 1_000_000);
1626+
1627+
approx_eq(input_cost, 0.20);
1628+
approx_eq(output_cost, 1.25);
1629+
approx_eq(cache_cost, 0.02);
1630+
}
1631+
1632+
#[test]
1633+
fn gpt_4_5_pricing_is_available() {
1634+
let model_info = get_model_info("gpt-4.5").expect("model should exist");
1635+
assert!(!model_info.is_estimated);
1636+
1637+
let input_cost = calculate_input_cost("gpt-4.5", 1_000_000);
1638+
let output_cost = calculate_output_cost("gpt-4.5", 1_000_000);
1639+
let cache_cost = calculate_cache_cost("gpt-4.5", 0, 1_000_000);
1640+
1641+
approx_eq(input_cost, 75.0);
1642+
approx_eq(output_cost, 150.0);
1643+
approx_eq(cache_cost, 37.5);
1644+
}
1645+
1646+
#[test]
1647+
fn gpt_5_1_pricing_is_available() {
1648+
let model_info = get_model_info("gpt-5.1").expect("model should exist");
1649+
assert!(!model_info.is_estimated);
1650+
1651+
let input_cost = calculate_input_cost("gpt-5.1", 1_000_000);
1652+
let output_cost = calculate_output_cost("gpt-5.1", 1_000_000);
1653+
let cache_cost = calculate_cache_cost("gpt-5.1", 0, 1_000_000);
1654+
1655+
approx_eq(input_cost, 1.25);
1656+
approx_eq(output_cost, 10.0);
1657+
approx_eq(cache_cost, 0.125);
1658+
}
15951659
}

0 commit comments

Comments
 (0)