mem0ai/mem0 · error · Error
Failed to extract embedding values from response
Error message
Failed to extract embedding values from response
What it means
After decoding response.predictions[0] from Vertex's protobuf Value format via helpers.fromValue, the result must look like an embedding (isValidEmbedding checks the decoded.embeddings.values shape). If the decoded structure does not contain embeddings.values, this error is thrown, indicating the prediction payload had an unexpected structure (often an error payload or a model that returns a different output format).
Source
Thrown at mem0-ts/src/oss/src/embeddings/vertexai.ts:183
const instance = this.formatInstance(text, embeddingType);
const parameters = {
outputDimensionality: this.embeddingDims,
};
const [response] = await this.client.predict({
endpoint: this.endpoint(),
instances: [this.helpers.toValue(instance) as any],
parameters: this.helpers.toValue(parameters) as any,
});
if (!response.predictions || response.predictions.length === 0) {
throw new Error("No predictions returned from Vertex AI");
}
const decoded = this.helpers.fromValue(response.predictions[0] as any);
if (!isValidEmbedding(decoded)) {
throw new Error("Failed to extract embedding values from response");
}
return decoded.embeddings.values;
}
async embedBatch(
texts: string[],
memoryAction: "add" | "update" | "search" = "add",
): Promise<number[][]> {
if (!texts || texts.length === 0) {
return [];
}
await this.initClient();
if (!this.client || !this.helpers) {
throw new Error("Client not initialized");
}
View on GitHub (pinned to 001c235229)
Solutions
- Confirm the configured model is a Vertex text-embedding model (textembedding-gecko@latest, text-embedding-005, text-multilingual-embedding-002, etc.)
- Log the raw prediction (temporarily) to see what structure came back, and match the model id to one that returns embeddings.values
- Pin a matching, current version of @google-cloud/aiplatform as a peer dependency
- Retry once in case of a transient malformed response
Example fix
// before
new VertexAIEmbedder({ model: "gemini-1.5-pro" }); // generative model
// after
new VertexAIEmbedder({ model: "text-embedding-005" }); Defensive patterns
Strategy: validation
Validate before calling
const EMBEDDING_MODEL = /^text-(embedding|multilingual-embedding)/;
if (!EMBEDDING_MODEL.test(modelId)) {
throw new Error(`'${modelId}' does not look like a Vertex text-embedding model`);
} Type guard
function isExtractEmbeddingError(err: unknown): boolean {
return err instanceof Error && err.message === "Failed to extract embedding values from response";
} Try / catch
try { return await embedder.embed(text); }
catch (err) {
if (err instanceof Error && err.message === "Failed to extract embedding values from response") {
throw new Error(`Model '${modelId}' returned a non-embedding prediction - use a text-embedding model`);
}
throw err;
} Prevention
- Pin a stable embedding model id (text-embedding-005 / textembedding-gecko@latest)
- Keep @google-cloud/aiplatform version aligned with the SDK's peer range
- Add a boot-time self-embed of a short probe string to catch wrong-model configs early
When it happens
Trigger: Using a multimodal or generative Vertex model id where the prediction contains generated content instead of embedding values; model returns values under a different key for preview versions; fromValue decoding a nested error/status message.
Common situations: Model id typo pointing at a non-embedding model; new/preview embedding models with changed output envelopes; SDK's peer @google-cloud/aiplatform version mismatch changing Value decoding behavior.
Related errors
- Failed to extract embedding values from batch response
- Invalid memory action: ${memoryAction}
- No predictions returned from Vertex AI
- No predictions returned from Vertex AI batch request
- Vertex AI embedBatch() returned ${allEmbeddings.length} embe
AI-assisted analysis of mem0ai/mem0@001c235229 (2026-08-15).
Data as JSON: /api/errors/592e633589a071fb.
Report an issue: GitHub.