Mintplex-Labs/anything-llm · error
Mistral chat: is not valid for chat completion!
Error message
Mistral chat: ${this.model} is not valid for chat completion! What it means
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.
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
Example fix
# before MISTRAL_MODEL_PREF=mistral-tiny # after MISTRAL_MODEL_PREF=mistral-small-latest
Defensive patterns
Strategy: try-catch
Validate before calling
const valid = await llm.isValidChatCompletionModel(llm.model);
if (!valid)
throw new Error(`Model ${llm.model} is not available on Mistral`); Try / catch
try {
await llm.getChatCompletion(messages);
} catch (e) {
if (/Mistral chat: .* is not valid/.test(e.message)) {
// verify id via https://api.mistral.ai/v1/models and update MISTRAL_MODEL_PREF
}
throw e;
} Prevention
- 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
When it happens
Trigger: 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').
Common situations: Forks/plugins adding strict model validation; Mistral deprecating a model id that remains in MISTRAL_MODEL_PREF; version skew after upgrading AnythingLLM.
Related errors
- LocalAI chat: is not valid for chat completion!
- Minimax chat: is not valid for chat completion!
- Minimax stream: is not valid for chat completion!
- Novita chat: is not valid for chat completion!
- GroqAI:chatCompletion
AI-assisted analysis of Mintplex-Labs/anything-llm@3aec848f28 (2026-08-18).
Data as JSON: /api/errors/8bc617806bfd4e1d.
Report an issue: GitHub.
Appendix: 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 3aec848f28)