{"record":{"id":"260068a13aa19266","repo":"Mintplex-Labs/anything-llm","slug":"no-mistral-api-key-was-set-260068","errorCode":null,"errorMessage":"No Mistral API key was set.","messagePattern":"No Mistral API key was set\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"server/utils/EmbeddingEngines/mistral/index.js","lineNumber":10,"sourceCode":"const {\n  toChunks,\n  maximumChunkLength,\n  reportEmbeddingProgress,\n} = require(\"../../helpers\");\n\nclass MistralEmbedder {\n  constructor() {\n    if (!process.env.MISTRAL_API_KEY)\n      throw new Error(\"No Mistral API key was set.\");\n\n    const { OpenAI: OpenAIApi } = require(\"openai\");\n    this.className = \"MistralEmbedder\";\n    this.openai = new OpenAIApi({\n      baseURL: \"https://api.mistral.ai/v1\",\n      apiKey: process.env.MISTRAL_API_KEY ?? null,\n      fetch: MistralEmbedder.applyMistralFetch(),\n    });\n    this.model = process.env.EMBEDDING_MODEL_PREF || \"mistral-embed\";\n\n    // Mistral rejects a batch whose total token count is too large with\n    // 400 {\"code\":\"3210\",\"message\":\"Too many tokens overall, split into more batches.\"}.\n    // With 1000-char chunks, 200 inputs succeed and 300 fail, so 100 leaves headroom.\n    this.maxConcurrentChunks = 100;\n    this.embeddingMaxChunkLength = maximumChunkLength();\n    this.log(`Initialized ${this.model}`, {\n      maxConcurrentChunks: this.maxConcurrentChunks,\n      embeddingMaxChunkLength: this.embeddingMaxChunkLength,","sourceCodeStart":1,"sourceCodeEnd":28,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/f92433b4ea0598492a1e6645ea22addbb4dd1287/server/utils/EmbeddingEngines/mistral/index.js#L1-L28","documentation":"Thrown by the MistralEmbedder constructor when MISTRAL_API_KEY is unset. The class is the simplest engine here: it talks to https://api.mistral.ai/v1 with the OpenAI SDK and defaults to the mistral-embed model. Unlike most other engines it performs no other configuration checks, so this key is its single hard requirement.","triggerScenarios":"Selecting Mistral as the embedding engine without entering an API key; MISTRAL_API_KEY missing from docker-compose/.env; key defined only on the host but the process runs in the container; env file edited after startup without restart.","commonSituations":"Users who set MISTRAL_API_KEY for the LLM provider but selected the Mistral embedding engine before the key propagated; CI environments that never received the secret.","solutions":["Create a key at console.mistral.ai (API Keys page) and set MISTRAL_API_KEY to it","Add the variable to docker-compose environment (or -e flag) and recreate the container","Restart the server so the constructor sees the value","Check exact spelling — MISTRAL_API_KEY, not MISTRAL_EMBEDDING_API_KEY"],"exampleFix":"# before\nEMBEDDING_ENGINE=mistral\n\n# after\nEMBEDDING_ENGINE=mistral\nMISTRAL_API_KEY=...","handlingStrategy":"validation","validationCode":"function assertMistralEmbedderConfigured() {\n  if (!process.env.MISTRAL_API_KEY) {\n    throw new Error(\"Missing MISTRAL_API_KEY — create one at console.mistral.ai\");\n  }\n}\nassertMistralEmbedderConfigured();","typeGuard":null,"tryCatchPattern":"try {\n  const embedder = new MistralEmbedder();\n} catch (e) {\n  if (e.message === \"No Mistral API key was set.\") {\n    // deterministic config failure — surface a settings prompt, never a retry\n  }\n  throw e;\n}","preventionTips":["Store MISTRAL_API_KEY in the same secret manager slot used for the Mistral LLM provider","Assert required env vars in a startup preflight rather than discovering them at first embed","Rotate keys in the console first, then update env and restart in one maintenance step"],"tags":["mistral","api-key","env-var","configuration","constructor"],"backgroundTag":"missing-api-key","analyzedSha":"f92433b4ea0598492a1e6645ea22addbb4dd1287","analyzedAt":"2026-09-22T02:13:38.154Z","contentChangedAt":"2026-09-22T02:13:38.154Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}