fix: also apply custom api_base/api_key to async embedding path

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.
This commit is contained in:
Petie Clark 2026-03-19 17:50:27 -04:00
parent 654664795f
commit fbf949c0d9

View file

@ -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"]