conductor-oss/conductor · error · RuntimeException
No embeddings returned from Gemini API
Error message
No embeddings returned from Gemini API
What it means
GeminiVertex.generateEmbeddings() throws this when the Gemini embedContent API returns a response whose embedding object or its values list is null. This means the API call succeeded (no IOException) but produced no usable embedding vector — the response shape indicates either the model cannot embed the input, or the API returned an empty/null result for an edge-case input.
Source
Thrown at ai/src/main/java/org/conductoross/conductor/ai/providers/gemini/GeminiVertex.java:88
public String getModelProvider() {
return NAME;
}
@Override
public List<String> getProviderAliases() {
return List.of(ALIAS);
}
@Override
public List<Float> generateEmbeddings(EmbeddingGenRequest embeddingGenRequest) {
try {
GeminiApi.EmbedContentResponse resp =
geminiApi.embedContent(
embeddingGenRequest.getModel(),
embeddingGenRequest.getText(),
embeddingGenRequest.getDimensions());
if (resp.embedding() == null || resp.embedding().values() == null) {
throw new RuntimeException("No embeddings returned from Gemini API");
}
return resp.embedding().values();
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
throw new RuntimeException("Gemini embedContent failed", e);
}
}
@Override
public ChatModel getChatModel() {
return new GeminiChatModel(geminiApi);
}
@Override
public ChatOptions getChatOptions(ChatCompletion input) {
return GeminiChatOptions.builder()
.model(input.getModel())View on GitHub (pinned to cf7c3e4a8a)
Solutions
- Verify the model name is a Gemini embedding model: 'text-embedding-004', 'gemini-embedding-001', or 'text-embedding-005'.
- Check the input text is non-empty and non-blank before calling generateEmbeddings.
- Log the raw API response to diagnose whether the embedding field is truly null vs. malformed.
- Verify the API key has access to the embeddings endpoint (separate from chat access).
Example fix
// before
String model = "gemini-2.5-flash"; // chat model — won't produce embeddings
List<Float> emb = vertex.generateEmbeddings(
new EmbeddingGenRequest(model, text, null));
// after
String model = "text-embedding-004";
List<Float> emb = vertex.generateEmbeddings(
new EmbeddingGenRequest(model, text, null)); Defensive patterns
Strategy: try-catch
Validate before calling
// Validate embedding model and input before calling
private static final Set<String> GEMINI_EMBEDDING_MODELS =
Set.of("text-embedding-004", "text-embedding-005", "gemini-embedding-001");
void validateEmbeddingRequest(String model, String text) {
if (text == null || text.isBlank()) {
throw new IllegalArgumentException("Embedding input text must be non-empty");
}
if (!GEMINI_EMBEDDING_MODELS.contains(model)) {
throw new IllegalArgumentException(
"Use a Gemini embedding model (text-embedding-004, gemini-embedding-001). Got: " + model);
}
} Try / catch
try {
return vertex.generateEmbeddings(request);
} catch (RuntimeException e) {
if (e.getMessage().equals("No embeddings returned from Gemini API")) {
throw new IllegalArgumentException(
"Gemini returned no embedding — verify model is an embedding model "
+ "(text-embedding-004) and input is non-empty", e);
}
throw e;
} Prevention
- Always use a Gemini embedding model name: text-embedding-004, text-embedding-005, or gemini-embedding-001.
- Validate input text is non-blank before calling generateEmbeddings.
- Verify the API key has embeddings endpoint access (separate from chat).
- Log the model name and response status when this occurs to distinguish model-mismatch from API issues.
When it happens
Trigger: Calling embedContent with a model that doesn't support embeddings (e.g. a chat-only or image-only model), passing empty or whitespace-only text, or hitting an API edge case where Google returns a valid HTTP 200 with a null embedding field.
Common situations: Using a chat model name (e.g. 'gemini-2.5-flash') for embeddings instead of an embedding model (e.g. 'text-embedding-004', 'gemini-embedding-001'). Empty input text. API key enabled for chat but not for the embeddings endpoint. Model deprecated or not available in the region.
Related errors
- Gemini embedContent failed
- Empty response downloading from {url}
- Empty response downloading image from {url}
- {"error":{errors},"response":{output}}
- Not supported
AI-assisted analysis of conductor-oss/conductor@cf7c3e4a8a (2026-08-14).
Data as JSON: /api/errors/1108ea139b96bc3b.
Report an issue: GitHub.