Mintplex-Labs/anything-llm · error · Error
Mistral chat: ${this.model} is not valid for chat completion
Error message
Mistral chat: ${this.model} is not valid for chat completion! What it means
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.
Source
Thrown at server/utils/AiProviders/mistral/index.js:112
attachments = [], // This is the specific attachment for only this prompt
}) {
const prompt = {
role: "system",
content: `${systemPrompt}${this.#appendContext(contextTexts)}`,
};
return [
prompt,
...formatChatHistory(chatHistory, this.#generateContent),
{
role: "user",
content: this.#generateContent({ userPrompt, attachments }),
},
];
}
async getChatCompletion(messages = null, { temperature = 0.7 }) {
if (!(await this.isValidChatCompletionModel(this.model)))
throw new Error(
`Mistral chat: ${this.model} is not valid for chat completion!`
);
const result = await LLMPerformanceMonitor.measureAsyncFunction(
this.openai.chat.completions
.create({
model: this.model,
messages,
temperature,
})
.catch((e) => {
throw new Error(e.message);
})
);
if (
!result.output.hasOwnProperty("choices") ||
result.output.choices.length === 0View on GitHub (pinned to 526360e320)
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.
Example fix
// before MISTRAL_MODEL_PREF=mistral-embed // embedding model, invalid for chat // after MISTRAL_MODEL_PREF=mistral-small-latest
Defensive patterns
Strategy: validation
Validate before calling
const valid = await llm.isValidChatCompletionModel(llm.model);
if (!valid) {
throw new Error(`Model '${llm.model}' not in Mistral chat catalog — fix MISTRAL_MODEL_PREF.`);
} Type guard
function isKnownMistralModel(model, catalog) {
return typeof model === 'string' && model.length > 0 && catalog.includes(model);
} Try / catch
try {
await llm.getChatCompletion(messages, { temperature });
} catch (e) {
if (/Mistral chat:.*not valid for chat completion/i.test(e.message)) {
// reconfigure model
}
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Minimax chat: ${this.model} is not valid for chat completion
- Novita chat: ${this.model} is not valid for chat completion!
- DeepSeek chat: ${this.model} is not valid for chat completio
- Foundry chat: ${this.model} is not valid or defined model fo
- GroqAI:chatCompletion: ${this.model} is not valid for chat c
AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13).
Data as JSON: /api/errors/8bc617806bfd4e1d.
Report an issue: GitHub.