From 6fa5099fc38c4ae50149de85722b5ad63d8e30c9 Mon Sep 17 00:00:00 2001 From: "Ethan T." Date: Fri, 13 Mar 2026 13:44:06 +0800 Subject: [PATCH] fix(vertex_ai): add gemini-embedding model name fallback in routing Add fallback check in vertex_ai embedding routing: if get_model_info fails to find uses_embed_content flag, models with 'gemini-embedding' prefix are still routed to GoogleBatchEmbeddings handler instead of falling through to the legacy :predict handler. Fixes BerriAI/litellm#23508 --- litellm/main.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/litellm/main.py b/litellm/main.py index f2ce894ba38..011df5ad6a2 100644 --- a/litellm/main.py +++ b/litellm/main.py @@ -5204,6 +5204,12 @@ def embedding( # noqa: PLR0915 except Exception: uses_embed_content = False + # Fallback: models with "gemini-embedding" prefix use the + # embedContent API, not the legacy :predict endpoint. This + # ensures correct routing even when model info lookup fails. + if not uses_embed_content and model.startswith("gemini-embedding"): + uses_embed_content = True + if uses_embed_content: response = google_batch_embeddings.batch_embeddings( # type: ignore model=model,