Skip to content

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

Open

Description

Describe the bug
Using VertexAIEmbeddingGenerator with model "gemini-embedding-2" will result in 400 FAILED_PRECONDITION

To Reproduce
Run the VertexAIEmbeddingGenerator generation with the gemini-embedding-2 model:

#:package Microsoft.SemanticKernel.Connectors.Google@1.75.0-alpha
#:property NoWarn=SKEXP0001;SKEXP0070

using System.Net.Http.Json;
using System.Text.Json;
using Microsoft.Extensions.AI;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Connectors.Google;

const string ModelId = "gemini-embedding-2";
const int Dimensions = 768;

var token     = Require("GOOGLE_ACCESS_TOKEN");
var projectId = Require("GOOGLE_PROJECT_ID");
var location  = Environment.GetEnvironmentVariable("GOOGLE_LOCATION") is { Length: > 0 } l ? l : "us-central1";

Console.WriteLine($"model={ModelId} project={projectId} location={location} dimensions={Dimensions}");
Console.WriteLine($"SK Connectors.Google = {typeof(VertexAIEmbeddingGenerator).Assembly.GetName().Version}");
Console.WriteLine();

try
{
    IEmbeddingGenerator<string, Embedding<float>> generator = new VertexAIEmbeddingGenerator(
        modelId:    ModelId,
        bearerKey:  token,
        location:   location,
        projectId:  projectId,
        dimensions: Dimensions);

    var embeddings = await generator.GenerateAsync(["test"]);
    Console.WriteLine($"    UNEXPECTED SUCCESS: {embeddings[0].Vector.Length} floats");
}
catch (HttpOperationException ex)
{
    Console.WriteLine($"    FAILED  status={ex.StatusCode}");
    Console.WriteLine($"    message={ex.Message}");
    Console.WriteLine($"    body={Trim(ex.ResponseContent)}");
}
catch (Exception ex)
{
    Console.WriteLine($"    FAILED  {ex.GetType().Name}: {ex.Message}");
}

Expected behavior
VertexAIEmbeddingGenerator should correctly resolve to use the :embedContent endpoint in this case, as the :predict endpoint is no longer supported for gemini-embedding-2

Platform

  • Language: C#
  • Source: [email protected]
  • AI model: gemini-embedding-2
  • IDE: JetBrains Rider
  • OS: Windows

Additional context
:predict API is hardcoded here:

this._embeddingEndpoint = new Uri($"{baseUri}/{versionSubLink}/projects/{projectId}/locations/{location}/publishers/google/models/{this._embeddingModelId}:predict");

Similar problems raised in other repos:

Activity

  1. uuzzrm commented on Aug 11, 2026

    @uuzzrm

    I’m going to take a look at this. I’ll start with a regression test for endpoint selection, then wire the embedContent request/response shape for Gemini embedding models while keeping existing :predict models unchanged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions