{"record":{"id":"b15be9607dc858aa","repo":"Mintplex-Labs/anything-llm","slug":"mistral-failed-to-embed-error-message","errorCode":null,"errorMessage":"Mistral Failed to embed: ${error.message}","messagePattern":"Mistral Failed to embed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/utils/EmbeddingEngines/mistral/index.js","lineNumber":34,"sourceCode":"      Array.isArray(textInput) ? textInput : [textInput]\n    );\n    return result?.[0] || [];\n  }\n\n  async embedChunks(textChunks = []) {\n    try {\n      const response = await this.openai.embeddings.create({\n        model: this.model,\n        input: textChunks,\n        encoding_format: \"float\",\n      });\n      const embeddings = response?.data?.map((emb) => emb.embedding) || [];\n      if (embeddings.length === 0)\n        throw new Error(\"Mistral returned empty embeddings for batch\");\n      return embeddings;\n    } catch (error) {\n      console.error(\"Failed to get embeddings from Mistral.\", error.message);\n      throw new Error(`Mistral Failed to embed: ${error.message}`);\n    }\n  }\n}\n\nmodule.exports = {\n  MistralEmbedder,\n};\n","sourceCodeStart":16,"sourceCodeEnd":42,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/3aec848f2885144aa8f1e53b9731a04310d5d558/server/utils/EmbeddingEngines/mistral/index.js#L16-L42","documentation":"The catch-all thrown from MistralEmbedder.embedChunks: any failure of the embeddings.create call (or of the empty-batch guard, which is thrown inside the same try) is logged to console.error and re-thrown with the original error.message appended. The console line 'Failed to get embeddings from Mistral.' plus the message is the best diagnostic — it carries Mistral's own error text.","triggerScenarios":"401/403 with an invalid or revoked MISTRAL_API_KEY; 429 after exceeding the Mistral free-tier/plan rate limits during bulk embedding; 404/400 when EMBEDDING_MODEL_PREF is not a valid model id; batch exceeding Mistral's input limits (too many items or tokens per request); network/TLS failures reaching api.mistral.ai; the wrapped 'Mistral returned empty embeddings for batch' case.","commonSituations":"Bulk re-embedding a large workspace and hitting Mistral's per-minute quotas; keys rotated in the console but not updated in env; a typo'd model name that only fails at embed time (the constructor does not validate it).","solutions":["Check the server console — 'Failed to get embeddings from Mistral.' precedes the exact upstream message","For 401/403, verify MISTRAL_API_KEY in console.mistral.ai and rotate if needed","For 429, slow down or wait out the quota window, then re-embed remaining documents","Confirm EMBEDDING_MODEL_PREF is 'mistral-embed' or another valid embedding model for your account","Reduce batch pressure with EMBEDDING_MODEL_MAX_CHUNK_LENGTH if inputs are oversized"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Pre-flight: validate key + model with one cheap call before the real batch\nasync function mistralEmbedderHealthy(openai, model) {\n  try {\n    const res = await openai.embeddings.create({ model, input: [\"ping\"], encoding_format: \"float\" });\n    return Array.isArray(res?.data?.[0]?.embedding);\n  } catch (e) {\n    console.error(\"Mistral pre-flight failed:\", e.status, e.message);\n    return false;\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  const vectors = await embedder.embedTextInput(text);\n} catch (e) {\n  if (e.message.startsWith(\"Mistral Failed to embed:\")) {\n    const detail = e.message;\n    if (/401|403/i.test(detail)) { /* invalid MISTRAL_API_KEY — stop the job, fix the key */ }\n    else if (/429|quota/i.test(detail)) { /* rate-limited: exponential backoff, retry the batch */ }\n    else if (/empty embeddings/i.test(detail)) { /* batch-content problem — see empty-batch guard */ }\n    else throw e;\n  } else throw e;\n}","preventionTips":["Check the server console — the preceding 'Failed to get embeddings from Mistral.' line carries the original upstream message","Throttle bulk embeds to stay under Mistral plan rate limits instead of absorbing 429 storms","Remember this error wraps everything, including the empty-embeddings guard — classify before retrying"],"tags":["mistral","embeddings","api-error","rate-limit","api-key"],"backgroundTag":"embedding-api-request-failed","analyzedSha":"3aec848f2885144aa8f1e53b9731a04310d5d558","analyzedAt":"2026-08-18T10:02:21.017Z","contentChangedAt":"2026-08-18T10:02:21.017Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}