From 439d4b8c5cd85b0064c9cf8df4c61826af859da2 Mon Sep 17 00:00:00 2001 From: mateo-berri <277851410+mateo-berri@users.noreply.github.com> Date: Wed, 28 Oct 2026 06:05:25 -0700 Subject: [PATCH] perf(cost): check the exact cost-map row before generalization rules when picking the priced model --- litellm/cost_calculator.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/litellm/cost_calculator.py b/litellm/cost_calculator.py index bc7dbff47f9..43f86981707 100644 --- a/litellm/cost_calculator.py +++ b/litellm/cost_calculator.py @@ -1029,10 +1029,10 @@ def _cost_map_model_name(model: str, custom_llm_provider: str | None, region_nam def _resolves_to_rates(model: str, custom_llm_provider: str | None) -> bool: + if _declares_rates(_cost_map_model_info(model, custom_llm_provider)): + return True rule_info: Final = unmapped_model_generalization(model, custom_llm_provider) - if rule_info is not None: - return _cost_map_entry_prices_anything(rule_info) - return _declares_rates(_cost_map_model_info(model, custom_llm_provider)) + return rule_info is not None and _cost_map_entry_prices_anything(rule_info) def _served_or_priced_requested_model(served: str, requested: str | None, custom_llm_provider: str | None) -> str: