From e33207a50e3a66d71d92ef1159dc3011b5fc8264 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Fri, 10 Jul 2026 07:40:00 +0000 Subject: [PATCH] fix(proxy): capture model cost map count before deployment re-registration --- litellm/proxy/proxy_server.py | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.py index 312fca2305a..4d476336e4b 100644 --- a/litellm/proxy/proxy_server.py +++ b/litellm/proxy/proxy_server.py @@ -6056,15 +6056,13 @@ class ProxyConfig: model_cost_map_url = litellm.model_cost_map_url new_model_cost_map = get_model_cost_map(url=model_cost_map_url) + models_count = len(new_model_cost_map) if new_model_cost_map else 0 litellm.model_cost = new_model_cost_map # Invalidate case-insensitive lookup map since model_cost was replaced _invalidate_model_cost_lowercase_map() # Repopulate provider model sets (e.g. litellm.anthropic_models) so that # wildcard patterns like "anthropic/*" include any newly added models. litellm.add_known_models(model_cost_map=new_model_cost_map) - # Replacing model_cost wholesale drops per-deployment overrides - # (custom pricing, mode, ...); replay them so e.g. a configured - # mode=responses isn't reverted to the built-in mode=chat. if llm_router is not None: llm_router.re_register_deployments_in_model_cost() @@ -6096,9 +6094,7 @@ class ProxyConfig: ) await invalidate_config_param("model_cost_map_reload_config") - verbose_proxy_logger.info( - f"Model cost map reloaded successfully. Models count: {len(new_model_cost_map) if new_model_cost_map else 0}" - ) + verbose_proxy_logger.info(f"Model cost map reloaded successfully. Models count: {models_count}") except Exception as e: verbose_proxy_logger.exception(f"Error in _check_and_reload_model_cost_map: {str(e)}") @@ -15130,15 +15126,13 @@ async def reload_model_cost_map( model_cost_map_url = litellm.model_cost_map_url new_model_cost_map = get_model_cost_map(url=model_cost_map_url) + models_count = len(new_model_cost_map) if new_model_cost_map else 0 litellm.model_cost = new_model_cost_map # Invalidate case-insensitive lookup map since model_cost was replaced _invalidate_model_cost_lowercase_map() # Repopulate provider model sets (e.g. litellm.anthropic_models) so that # wildcard patterns like "anthropic/*" include any newly added models. litellm.add_known_models(model_cost_map=new_model_cost_map) - # Replacing model_cost wholesale drops per-deployment overrides - # (custom pricing, mode, ...); replay them so e.g. a configured - # mode=responses isn't reverted to the built-in mode=chat. if llm_router is not None: llm_router.re_register_deployments_in_model_cost() @@ -15167,7 +15161,6 @@ async def reload_model_cost_map( ) await invalidate_config_param("model_cost_map_reload_config") - models_count = len(new_model_cost_map) if new_model_cost_map else 0 verbose_proxy_logger.info(f"Model cost map reloaded successfully in current pod. Models count: {models_count}") return {