{"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":"Error","httpStatus":null,"severity":"critical","filePath":"server/utils/EmbeddingEngines/mistral/index.js","lineNumber":4,"sourceCode":"class 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.openai = new OpenAIApi({\n      baseURL: \"https://api.mistral.ai/v1\",\n      apiKey: process.env.MISTRAL_API_KEY ?? null,\n    });\n    this.model = process.env.EMBEDDING_MODEL_PREF || \"mistral-embed\";\n  }\n\n  async embedTextInput(textInput) {\n    const result = await this.embedChunks(\n      Array.isArray(textInput) ? textInput : [textInput]\n    );\n    return result?.[0] || [];\n  }\n\n  async embedChunks(textChunks = []) {\n    try {","sourceCodeStart":1,"sourceCodeEnd":22,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/utils/EmbeddingEngines/mistral/index.js#L1-L22","documentation":"Thrown by the MistralEmbedder constructor when process.env.MISTRAL_API_KEY is falsy. Unlike the local embedders, Mistral's endpoint is hardcoded (api.mistral.ai/v1) so only the API key is required. The openai SDK is pointed at Mistral with the key; without it requests would 401, so construction aborts immediately.","triggerScenarios":"Selecting the Mistral embedding engine while MISTRAL_API_KEY is unset/empty; constructing `new MistralEmbedder()` before env load. The check on line 3 runs before the client is built.","commonSituations":"First-time Mistral setup; key rotated on the Mistral console but not in .env; key name typo (e.g. MISTRAL_KEY); secret not injected into the container/CI environment.","solutions":["Set MISTRAL_API_KEY in .env to a valid key from console.mistral.ai","Restart AnythingLLM so the constructor re-reads env","Confirm the key is valid with a direct curl to api.mistral.ai/v1/embeddings"],"exampleFix":"// before\n// MISTRAL_API_KEY unset\n\n// after\nMISTRAL_API_KEY=your-key-from-console.mistral.ai\nEMBEDDING_MODEL_PREF=mistral-embed","handlingStrategy":"validation","validationCode":"function hasMistralKey(env = process.env) {\n  return typeof env.MISTRAL_API_KEY === 'string' &&\n         env.MISTRAL_API_KEY.trim().length > 0;\n}\nif (!hasMistralKey()) {\n  throw new Error('Missing MISTRAL_API_KEY.');\n}","typeGuard":"function isMistralKey(v) {\n  return typeof v === 'string' && /^[A-Za-z0-9_-]{20,}$/.test(v);\n}","tryCatchPattern":null,"preventionTips":["Inject MISTRAL_API_KEY via the system settings, not a loose .env that can drift.","Rotate keys on a schedule and update settings immediately.","Validate presence at boot for the selected engine."],"tags":["mistral","embedding","config","env","auth","constructor"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}