Skip to content

Commit 3f35031

Browse files
committed
fix(pricing): keep family alias tiers when upstream publishes the alias
LiteLLM now ships gpt-5.6 as its own entry. Exact matches win over the alias, so the bare family name stopped inheriting the Sol variant's long-context rates and Fast multiplier, and fell back to flat pricing at a 200K boundary. Resolve the alias inside the built-in long-context lookup and the Fast multiplier lookup instead of at individual call sites, so an alias bills at the variant it points to no matter where upstream data happens to cover it. That also removes the duplicate alias resolution long_context_split_threshold was doing.
1 parent eb82dbf commit 3f35031

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

‎rust/crates/ccusage/src/pricing.rs‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,11 @@ impl FastMultiplierOverrides {
213213
if let Some(multiplier) = self.exact.get(model) {
214214
return Some(*multiplier);
215215
}
216+
// A default family alias bills at the variant it points to, so it
217+
// shares that variant's Fast multiplier.
218+
if let Some(multiplier) = pricing_alias(model).and_then(|alias| self.exact.get(alias)) {
219+
return Some(*multiplier);
220+
}
216221
let normalized = model.replace(['.', '@'], "-");
217222
normalized.split(['/', ':']).find_map(|part| {
218223
self.normalized_prefix
@@ -1337,6 +1342,11 @@ fn builtin_long_context_rates(base_model: &str) -> Option<LongContextRates> {
13371342
cache_read,
13381343
}
13391344
};
1345+
// A default family alias bills at the variant it points to, so it must pick
1346+
// up that variant's tier rates. Upstream pricing data publishes the alias as
1347+
// its own entry without long-context rates, which would otherwise leave the
1348+
// alias on flat pricing.
1349+
let base_model = pricing_alias(base_model).unwrap_or(base_model);
13401350
match base_model {
13411351
"gpt-5.6-sol" => Some(openai(10e-6, 45e-6, Some(12.5e-6), Some(1e-6))),
13421352
"gpt-5.6-terra" => Some(openai(5e-6, 22.5e-6, Some(6.25e-6), Some(0.5e-6))),
@@ -1360,9 +1370,7 @@ fn builtin_long_context_rates(base_model: &str) -> Option<LongContextRates> {
13601370
/// `Pricing::long_context_threshold`, and falls back to the default 200K
13611371
/// boundary used for LiteLLM `*_above_200k_tokens` data.
13621372
pub(crate) fn long_context_split_threshold(model: &str) -> u64 {
1363-
let base_model = model_without_date_suffix(model);
1364-
let canonical_model = pricing_alias(base_model).unwrap_or(base_model);
1365-
builtin_long_context_rates(canonical_model)
1373+
builtin_long_context_rates(model_without_date_suffix(model))
13661374
.map(|rates| rates.threshold)
13671375
.unwrap_or(DEFAULT_LONG_CONTEXT_THRESHOLD_TOKENS)
13681376
}

0 commit comments

Comments
 (0)