Skip to content

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]

fix: also close sync clients on eviction from LLMClientCache

Ryan Crabbebfeed0e59006
diff --git a/litellm/caching/llm_caching_handler.py b/litellm/caching/llm_caching_handler.py
index 5df9a8e4cdd..5dc16a224c7 100644
--- a/litellm/caching/llm_caching_handler.py
+++ b/litellm/caching/llm_caching_handler.py
@@ -21,6 +21,11 @@ class LLMClientCache(InMemoryCache):
asyncio.get_running_loop().create_task(close_fn())
except RuntimeError:
pass
+ elif close_fn and callable(close_fn):
+ try:
+ close_fn()
+ except Exception:
+ pass
def update_cache_key_with_event_loop(self, key):
"""