The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
fix: cache cooldown key (#16954)
Alexsander Hamirf54201107672
diff --git a/litellm/router_utils/cooldown_cache.py b/litellm/router_utils/cooldown_cache.pyindex e92f114dd52..edbcacca277 100644--- a/litellm/router_utils/cooldown_cache.py+++ b/litellm/router_utils/cooldown_cache.py@@ -2,6 +2,7 @@Wrapper around router cache. Meant to handle model cooldown logic"""+import functoolsimport timefrom typing import TYPE_CHECKING, Any, List, Optional, Tuple, Union@@ -44,7 +45,7 @@ class CooldownCache:) -> Tuple[str, CooldownCacheValue]:try:current_time = time.time()- cooldown_key = f"deployment:{model_id}:cooldown"+ cooldown_key = CooldownCache.get_cooldown_cache_key(model_id)# Store the cooldown information for the deployment separatelycooldown_data = CooldownCacheValue(@@ -104,8 +105,9 @@ class CooldownCache:raise e@staticmethod+ @functools.lru_cache(maxsize=1024)def get_cooldown_cache_key(model_id: str) -> str:- return f"deployment:{model_id}:cooldown"+ return "deployment:" + model_id + ":cooldown"async def async_get_active_cooldowns(self, model_ids: List[str], parent_otel_span: Optional[Span]@@ -140,7 +142,7 @@ class CooldownCache:self, model_ids: List[str], parent_otel_span: Optional[Span]) -> List[Tuple[str, CooldownCacheValue]]:# Generate the keys for the deployments- keys = [f"deployment:{model_id}:cooldown" for model_id in model_ids]+ keys = [CooldownCache.get_cooldown_cache_key(model_id) for model_id in model_ids]# Retrieve the values for the keys using mgetresults = (self.cache.batch_get_cache(keys=keys, parent_otel_span=parent_otel_span)