Bug Description
Batches.Get() returns an empty InlinedEmbedContentResponses slice for completed batch embedding jobs, even though the API successfully computed all embeddings.
Root Cause
The Gemini Developer API returns embedding results under output.inlinedResponses.inlinedResponses, but batchJobDestinationFromMldev in batches.go looks for them at output.inlinedEmbedContentResponses.inlinedResponses:
// batches.go – batchJobDestinationFromMldev
// Line 37-45: reads output.inlinedResponses.inlinedResponses
// and converts them through inlinedResponseFromMldev (generate content converter)
fromInlinedResponses := getValueByPath(fromObject, []string{"inlinedResponses", "inlinedResponses"})
// Line 47-50: reads output.inlinedEmbedContentResponses.inlinedResponses
// This path does NOT exist in the actual API response, so it's always nil
fromInlinedEmbedContentResponses := getValueByPath(fromObject, []string{"inlinedEmbedContentResponses", "inlinedResponses"})
The API does not use a separate inlinedEmbedContentResponses key — embedding batch results come back under the same inlinedResponses key as generate content results, just with embedding-specific inner structure. The SDK's path lookup for the embed field never matches, so BatchJobDestination.InlinedEmbedContentResponses is always nil.
Steps to Reproduce
ctx := context.Background()
client, _ := genai.NewClient(ctx, &genai.ClientConfig{
Backend: genai.BackendGeminiAPI,
APIKey: "...",
})
model := "gemini-embedding-001"
job, _ := client.Batches.CreateEmbeddings(ctx, &model, &genai.EmbeddingsBatchJobSource{
InlinedRequests: &genai.EmbedContentBatch{
Contents: []*genai.Content{
genai.NewContentFromText("hello world", ""),
genai.NewContentFromText("test embedding", ""),
},
},
}, nil)
// Poll until SUCCEEDED...
for {
job, _ = client.Batches.Get(ctx, job.Name, nil)
if job.State == genai.JobStateSucceeded {
break
}
time.Sleep(10 * time.Second)
}
// BUG: InlinedEmbedContentResponses is nil despite job succeeding
fmt.Println(len(job.Dest.InlinedEmbedContentResponses)) // prints 0
Expected Behavior
job.Dest.InlinedEmbedContentResponses should contain the embedding vectors after a successful batch embedding job.
Actual Behavior
job.Dest.InlinedEmbedContentResponses is nil/empty. The embeddings are in the raw API response under metadata.output.inlinedResponses.inlinedResponses but the SDK never reads them into the InlinedEmbedContentResponses field.
Workaround
Make a raw HTTP GET to https://generativelanguage.googleapis.com/v1beta/{job.Name} and parse the JSON manually to extract embeddings from metadata.output.inlinedResponses.inlinedResponses[].response.embedding.values.
Environment
- SDK version: v1.49.0 (latest, also confirmed on
main)
- Go version: 1.24
- Backend:
BackendGeminiAPI (Gemini Developer API)
Bug Description
Batches.Get()returns an emptyInlinedEmbedContentResponsesslice for completed batch embedding jobs, even though the API successfully computed all embeddings.Root Cause
The Gemini Developer API returns embedding results under
output.inlinedResponses.inlinedResponses, butbatchJobDestinationFromMldevinbatches.golooks for them atoutput.inlinedEmbedContentResponses.inlinedResponses:The API does not use a separate
inlinedEmbedContentResponseskey — embedding batch results come back under the sameinlinedResponseskey as generate content results, just with embedding-specific inner structure. The SDK's path lookup for the embed field never matches, soBatchJobDestination.InlinedEmbedContentResponsesis always nil.Steps to Reproduce
Expected Behavior
job.Dest.InlinedEmbedContentResponsesshould contain the embedding vectors after a successful batch embedding job.Actual Behavior
job.Dest.InlinedEmbedContentResponsesis nil/empty. The embeddings are in the raw API response undermetadata.output.inlinedResponses.inlinedResponsesbut the SDK never reads them into theInlinedEmbedContentResponsesfield.Workaround
Make a raw HTTP GET to
https://generativelanguage.googleapis.com/v1beta/{job.Name}and parse the JSON manually to extract embeddings frommetadata.output.inlinedResponses.inlinedResponses[].response.embedding.values.Environment
main)BackendGeminiAPI(Gemini Developer API)