{"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":null,"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/3aec848f2885144aa8f1e53b9731a04310d5d558/server/utils/AiProviders/mistral/index.js#L94-L130","documentation":"Guard at the top of MistralLLM.getChatCompletion(): it awaits isValidChatCompletionModel(this.model) and throws if the check fails. The current implementation of isValidChatCompletionModel unconditionally returns true, so this error is effectively dead code unless a subclass overrides the validator or a modified provider version is deployed.","triggerScenarios":"Calling getChatCompletion with an overridden isValidChatCompletionModel that returns false for this.model; or a provider variant where the validator really queries the Mistral models endpoint and MISTRAL_MODEL_PREF names a model Mistral no longer serves (e.g. retired 'mistral-tiny').","commonSituations":"Forks/plugins adding strict model validation; Mistral deprecating a model id that remains in MISTRAL_MODEL_PREF; version skew after upgrading AnythingLLM.","solutions":["Confirm the model id exists: curl -H 'Authorization: Bearer $MISTRAL_API_KEY' https://api.mistral.ai/v1/models","Set MISTRAL_MODEL_PREF to a current id (e.g. mistral-small-latest) or re-select in the UI","Audit any isValidChatCompletionModel override in your codebase","git diff server/utils/AiProviders/mistral/index.js to rule out local modifications"],"exampleFix":"# before\nMISTRAL_MODEL_PREF=mistral-tiny\n# after\nMISTRAL_MODEL_PREF=mistral-small-latest","handlingStrategy":"try-catch","validationCode":"const valid = await llm.isValidChatCompletionModel(llm.model);\nif (!valid)\n  throw new Error(`Model ${llm.model} is not available on Mistral`);","typeGuard":null,"tryCatchPattern":"try {\n  await llm.getChatCompletion(messages);\n} catch (e) {\n  if (/Mistral chat: .* is not valid/.test(e.message)) {\n    // verify id via https://api.mistral.ai/v1/models and update MISTRAL_MODEL_PREF\n  }\n  throw e;\n}","preventionTips":["Use live model ids (e.g. mistral-small-latest) rather than pinned deprecated names","If overriding isValidChatCompletionModel, log why a model was rejected","Health-check the Mistral models endpoint when the provider is selected"],"tags":["mistral","anythingllm","model-validation","chat-completion"],"backgroundTag":"invalid-model-id","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"}