{"record":{"id":"592e633589a071fb","repo":"mem0ai/mem0","slug":"failed-to-extract-embedding-values-from-response","errorCode":null,"errorMessage":"Failed to extract embedding values from response","messagePattern":"Failed to extract embedding values from response","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"mem0-ts/src/oss/src/embeddings/vertexai.ts","lineNumber":183,"sourceCode":"\n    const instance = this.formatInstance(text, embeddingType);\n    const parameters = {\n      outputDimensionality: this.embeddingDims,\n    };\n\n    const [response] = await this.client.predict({\n      endpoint: this.endpoint(),\n      instances: [this.helpers.toValue(instance) as any],\n      parameters: this.helpers.toValue(parameters) as any,\n    });\n\n    if (!response.predictions || response.predictions.length === 0) {\n      throw new Error(\"No predictions returned from Vertex AI\");\n    }\n\n    const decoded = this.helpers.fromValue(response.predictions[0] as any);\n    if (!isValidEmbedding(decoded)) {\n      throw new Error(\"Failed to extract embedding values from response\");\n    }\n\n    return decoded.embeddings.values;\n  }\n\n  async embedBatch(\n    texts: string[],\n    memoryAction: \"add\" | \"update\" | \"search\" = \"add\",\n  ): Promise<number[][]> {\n    if (!texts || texts.length === 0) {\n      return [];\n    }\n\n    await this.initClient();\n    if (!this.client || !this.helpers) {\n      throw new Error(\"Client not initialized\");\n    }\n","sourceCodeStart":165,"sourceCodeEnd":201,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/mem0-ts/src/oss/src/embeddings/vertexai.ts#L165-L201","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nnew VertexAIEmbedder({ model: \"gemini-1.5-pro\" }); // generative model\n\n// after\nnew VertexAIEmbedder({ model: \"text-embedding-005\" });","handlingStrategy":"validation","validationCode":"const EMBEDDING_MODEL = /^text-(embedding|multilingual-embedding)/;\nif (!EMBEDDING_MODEL.test(modelId)) {\n  throw new Error(`'${modelId}' does not look like a Vertex text-embedding model`);\n}","typeGuard":"function isExtractEmbeddingError(err: unknown): boolean {\n  return err instanceof Error && err.message === \"Failed to extract embedding values from response\";\n}","tryCatchPattern":"try { return await embedder.embed(text); }\ncatch (err) {\n  if (err instanceof Error && err.message === \"Failed to extract embedding values from response\") {\n    throw new Error(`Model '${modelId}' returned a non-embedding prediction - use a text-embedding model`);\n  }\n  throw err;\n}","preventionTips":["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"],"tags":["vertexai","embeddings","response-shape","typescript"],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}