diff --git a/litellm/llms/vertex_ai/common_utils.py b/litellm/llms/vertex_ai/common_utils.py index 5895a91f3aa..71b3b2babcd 100644 --- a/litellm/llms/vertex_ai/common_utils.py +++ b/litellm/llms/vertex_ai/common_utils.py @@ -263,6 +263,11 @@ def _get_embedding_url( except Exception: uses_embed_content = False + # Fallback: all gemini-embedding-* models require the + # embedContent endpoint, not the legacy :predict endpoint. + if not uses_embed_content and model.startswith("gemini-embedding"): + uses_embed_content = True + endpoint = "embedContent" if uses_embed_content else "predict" base_url = get_vertex_base_url(vertex_location) diff --git a/litellm/main.py b/litellm/main.py index f2ce894ba38..ac7499ea415 100644 --- a/litellm/main.py +++ b/litellm/main.py @@ -5204,6 +5204,11 @@ def embedding( # noqa: PLR0915 except Exception: uses_embed_content = False + # Fallback: all gemini-embedding-* models require the + # embedContent endpoint, not the legacy :predict endpoint. + 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,