From 8ed7aa52ae707e9070e66d887922d5cc377601f0 Mon Sep 17 00:00:00 2001 From: PRABHU KIRAN VANDRANKI <72809214+VANDRANKI@users.noreply.github.com> Date: Fri, 17 Apr 2026 11:52:24 -0400 Subject: [PATCH] fix: raise RuntimeError with clear message when RedisSemanticCache vectorizer init fails --- litellm/caching/redis_semantic_cache.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/litellm/caching/redis_semantic_cache.py b/litellm/caching/redis_semantic_cache.py index c76f27377d8..3e25130233c 100644 --- a/litellm/caching/redis_semantic_cache.py +++ b/litellm/caching/redis_semantic_cache.py @@ -106,8 +106,21 @@ class RedisSemanticCache(BaseCache): print_verbose(f"Redis semantic-cache redis_url: {redis_url}") - # Initialize the Redis vectorizer and cache - cache_vectorizer = CustomTextVectorizer(self._get_embedding) + # Initialize the Redis vectorizer and cache. + # CustomTextVectorizer calls the embedding function during __init__ to + # validate it; if the embedding endpoint is unavailable (e.g. 429 rate + # limit, spend cap, network error), it raises ValueError. We surface a + # clear RuntimeError so the caller can decide whether to degrade + # gracefully or abort. + try: + cache_vectorizer = CustomTextVectorizer(self._get_embedding) + except Exception as e: + raise RuntimeError( + f"RedisSemanticCache: embedding model validation failed during " + f"initialisation ({type(e).__name__}: {e}). " + "Check that the configured embedding model is reachable and " + "that API credentials are valid." + ) from e self.llmcache = SemanticCache( name=index_name,