From fbf949c0d939a7d7aafca8241ea5bae5f594ab73 Mon Sep 17 00:00:00 2001 From: Petie Clark Date: Thu, 19 Mar 2026 17:50:27 -0400 Subject: [PATCH] fix: also apply custom api_base/api_key to async embedding path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Greptile correctly identified that _get_async_embedding() had the same bug in its else branch — calling litellm.aembedding() without api_base or api_key when the model is not in the router model list. Apply the same kwargs pattern to the async fallback path. --- litellm/caching/redis_semantic_cache.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/litellm/caching/redis_semantic_cache.py b/litellm/caching/redis_semantic_cache.py index 56c9bd61621..90505f83ed6 100644 --- a/litellm/caching/redis_semantic_cache.py +++ b/litellm/caching/redis_semantic_cache.py @@ -313,11 +313,16 @@ class RedisSemanticCache(BaseCache): ) else: # Generate embedding directly - embedding_response = await litellm.aembedding( - model=self.embedding_model, - input=prompt, - cache={"no-store": True, "no-cache": True}, - ) + async_embed_kwargs: dict = { + "model": self.embedding_model, + "input": prompt, + "cache": {"no-store": True, "no-cache": True}, + } + if self.embedding_api_base is not None: + async_embed_kwargs["api_base"] = self.embedding_api_base + if self.embedding_api_key is not None: + async_embed_kwargs["api_key"] = self.embedding_api_key + embedding_response = await litellm.aembedding(**async_embed_kwargs) # Extract and return the embedding vector return embedding_response["data"][0]["embedding"]