{"record":{"id":"1108ea139b96bc3b","repo":"conductor-oss/conductor","slug":"no-embeddings-returned-from-gemini-api","errorCode":null,"errorMessage":"No embeddings returned from Gemini API","messagePattern":"No embeddings returned from Gemini API","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"ai/src/main/java/org/conductoross/conductor/ai/providers/gemini/GeminiVertex.java","lineNumber":88,"sourceCode":"    public String getModelProvider() {\n        return NAME;\n    }\n\n    @Override\n    public List<String> getProviderAliases() {\n        return List.of(ALIAS);\n    }\n\n    @Override\n    public List<Float> generateEmbeddings(EmbeddingGenRequest embeddingGenRequest) {\n        try {\n            GeminiApi.EmbedContentResponse resp =\n                    geminiApi.embedContent(\n                            embeddingGenRequest.getModel(),\n                            embeddingGenRequest.getText(),\n                            embeddingGenRequest.getDimensions());\n            if (resp.embedding() == null || resp.embedding().values() == null) {\n                throw new RuntimeException(\"No embeddings returned from Gemini API\");\n            }\n            return resp.embedding().values();\n        } catch (RuntimeException e) {\n            throw e;\n        } catch (Exception e) {\n            throw new RuntimeException(\"Gemini embedContent failed\", e);\n        }\n    }\n\n    @Override\n    public ChatModel getChatModel() {\n        return new GeminiChatModel(geminiApi);\n    }\n\n    @Override\n    public ChatOptions getChatOptions(ChatCompletion input) {\n        return GeminiChatOptions.builder()\n                .model(input.getModel())","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/conductor-oss/conductor/blob/cf7c3e4a8adfb158be778ab1ec525323c363cd3a/ai/src/main/java/org/conductoross/conductor/ai/providers/gemini/GeminiVertex.java#L70-L106","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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)."],"exampleFix":"// before\nString model = \"gemini-2.5-flash\"; // chat model — won't produce embeddings\nList<Float> emb = vertex.generateEmbeddings(\n    new EmbeddingGenRequest(model, text, null));\n\n// after\nString model = \"text-embedding-004\";\nList<Float> emb = vertex.generateEmbeddings(\n    new EmbeddingGenRequest(model, text, null));","handlingStrategy":"try-catch","validationCode":"// Validate embedding model and input before calling\nprivate static final Set<String> GEMINI_EMBEDDING_MODELS =\n    Set.of(\"text-embedding-004\", \"text-embedding-005\", \"gemini-embedding-001\");\n\nvoid validateEmbeddingRequest(String model, String text) {\n    if (text == null || text.isBlank()) {\n        throw new IllegalArgumentException(\"Embedding input text must be non-empty\");\n    }\n    if (!GEMINI_EMBEDDING_MODELS.contains(model)) {\n        throw new IllegalArgumentException(\n            \"Use a Gemini embedding model (text-embedding-004, gemini-embedding-001). Got: \" + model);\n    }\n}","typeGuard":null,"tryCatchPattern":"try {\n    return vertex.generateEmbeddings(request);\n} catch (RuntimeException e) {\n    if (e.getMessage().equals(\"No embeddings returned from Gemini API\")) {\n        throw new IllegalArgumentException(\n            \"Gemini returned no embedding — verify model is an embedding model \"\n            + \"(text-embedding-004) and input is non-empty\", e);\n    }\n    throw e;\n}","preventionTips":["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."],"tags":["gemini","embeddings","empty-response","model-mismatch"],"backgroundTag":null,"analyzedSha":"cf7c3e4a8adfb158be778ab1ec525323c363cd3a","analyzedAt":"2026-08-14T03:33:19.897Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}