Skip to content

.Net: fix(vertex): use embedContent endpoint and Gemini schema for Vertex AI gemini embeddings - #14502

Open
Mayuri (mayuriphad) wants to merge 3 commits into
microsoft:mainfrom
mayuriphad:fix/vertexai-embeddings
Open

Mayuri (mayuriphad) wants to merge 3 commits into
microsoft:mainfrom
mayuriphad:fix/vertexai-embeddings

Conversation

@mayuriphad

Copy link
Copy Markdown

Fixes #14265

Google Vertex AI recently launched newer Gemini embedding models (such as gemini-embedding-2) that drop support for the legacy :predict endpoint (returning 400 FAILED_PRECONDITION). Instead, they require the :embedContent endpoint using the newer Gemini schema.

This PR updates the VertexAIEmbeddingClient to:

  1. Identify if the model uses the Gemini backend (modelId.StartsWith("gemini-")).
  2. Conditionally switch the endpoint to :embedContent instead of :predict for Gemini models.
  3. Serialize the request using the Gemini REST schema (GoogleAIEmbeddingRequest.RequestEmbeddingContent) rather than the legacy Vertex instances format.
  4. Issue sequential requests for batches because Vertex AI's :embedContent only embeds a single text input and does not support :batchEmbedContents.

For backward compatibility, all non-gemini embedding models on Vertex AI will continue to use :predict with batch instances.

Copilot AI balanced review requested due to automatic review settings September 29, 2026 06:05
@mayuriphad
Mayuri (mayuriphad) requested a review from a team as a code owner September 29, 2026 06:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@semantic-kernel-automation semantic-kernel-automation Bot added .NET Issue or Pull requests regarding .NET code kernel Issues or pull requests impacting the core kernel labels Oct 5, 2026
@github-actions github-actions Bot changed the title fix(vertex): use embedContent endpoint and Gemini schema for Vertex AI gemini embeddings .Net: fix(vertex): use embedContent endpoint and Gemini schema for Vertex AI gemini embeddings Oct 5, 2026
@mayuriphad

Copy link
Copy Markdown
Author

Hi maintainers, a gentle ping on this PR whenever you have a moment to review. I'm happy to make any changes or add tests if something needs adjusting. Thank you for your time!

This branch was previously deployed

1 inactive deployment
github-app-auth — 6ed92415 Deployed Oct 10, 2026 by mayuriphad via add_label #29310
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kernel Issues or pull requests impacting the core kernel .NET Issue or Pull requests regarding .NET code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: VertexAIEmbeddingGenerator hardcodes :predict, unusable with gemini-embedding models that only serve :embedContent

2 participants