{"record":{"id":"8bc617806bfd4e1d","repo":"Mintplex-Labs/anything-llm","slug":"mistral-chat-this-model-is-not-valid-for-chat","errorCode":null,"errorMessage":"Mistral chat: ${this.model} is not valid for chat completion!","messagePattern":"Mistral chat: (.+?) is not valid for chat completion!","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/utils/AiProviders/mistral/index.js","lineNumber":112,"sourceCode":"    attachments = [], // This is the specific attachment for only this prompt\n  }) {\n    const prompt = {\n      role: \"system\",\n      content: `${systemPrompt}${this.#appendContext(contextTexts)}`,\n    };\n    return [\n      prompt,\n      ...formatChatHistory(chatHistory, this.#generateContent),\n      {\n        role: \"user\",\n        content: this.#generateContent({ userPrompt, attachments }),\n      },\n    ];\n  }\n\n  async getChatCompletion(messages = null, { temperature = 0.7 }) {\n    if (!(await this.isValidChatCompletionModel(this.model)))\n      throw new Error(\n        `Mistral chat: ${this.model} is not valid for chat completion!`\n      );\n\n    const result = await LLMPerformanceMonitor.measureAsyncFunction(\n      this.openai.chat.completions\n        .create({\n          model: this.model,\n          messages,\n          temperature,\n        })\n        .catch((e) => {\n          throw new Error(e.message);\n        })\n    );\n\n    if (\n      !result.output.hasOwnProperty(\"choices\") ||\n      result.output.choices.length === 0","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/utils/AiProviders/mistral/index.js#L94-L130","documentation":"getChatCompletion validates this.model (default mistral-tiny or MISTRAL_MODEL_PREF) via isValidChatCompletionModel before calling Mistral. Throws with the 'Mistral chat:' prefix when the model id is not recognized as a Mistral chat model.","triggerScenarios":"getChatCompletion invoked with a this.model not in the resolved Mistral model catalog — typo, an embedding model (e.g. mistral-embed used for chat), or a deprecated model id.","commonSituations":"MISTRAL_MODEL_PREF set to a retired Mistral model; copy-pasted model id with wrong casing; embedding model used where a chat model is required; stale cached model list.","solutions":["Check the model id against Mistral's current model catalog (la plateforme).","Refresh the cached model list if AnythingLLM caches Mistral models locally.","Set MISTRAL_MODEL_PREF to a valid chat model (e.g. mistral-small-latest).","Avoid passing embedding model ids for chat."],"exampleFix":"// before\nMISTRAL_MODEL_PREF=mistral-embed  // embedding model, invalid for chat\n\n// after\nMISTRAL_MODEL_PREF=mistral-small-latest","handlingStrategy":"validation","validationCode":"const valid = await llm.isValidChatCompletionModel(llm.model);\nif (!valid) {\n  throw new Error(`Model '${llm.model}' not in Mistral chat catalog — fix MISTRAL_MODEL_PREF.`);\n}","typeGuard":"function isKnownMistralModel(model, catalog) {\n  return typeof model === 'string' && model.length > 0 && catalog.includes(model);\n}","tryCatchPattern":"try {\n  await llm.getChatCompletion(messages, { temperature });\n} catch (e) {\n  if (/Mistral chat:.*not valid for chat completion/i.test(e.message)) {\n    // reconfigure model\n  }\n}","preventionTips":["Do not reuse embedding model ids (e.g. mistral-embed) for chat.","Validate model ids in the admin UI before persisting.","Refresh the Mistral catalog periodically."],"tags":["mistral","model-validation","chat-completion","configuration"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}