Mintplex-Labs/anything-llm · critical · Error
No Mistral API key was set.
Error message
No Mistral API key was set.
What it means
Constructor guard mirroring Minimax: MistralLLM throws at construction if process.env.MISTRAL_API_KEY is absent. The key feeds the OpenAI-compatible client at https://api.mistral.ai/v1. (The later `?? null` on the apiKey is moot since the constructor already guaranteed presence.)
Source
Thrown at server/utils/AiProviders/mistral/index.js:13
const { NativeEmbedder } = require("../../EmbeddingEngines/native");
const {
LLMPerformanceMonitor,
} = require("../../helpers/chat/LLMPerformanceMonitor");
const {
handleDefaultStreamResponseV2,
formatChatHistory,
} = require("../../helpers/chat/responses");
class MistralLLM {
constructor(embedder = null, modelPreference = null) {
if (!process.env.MISTRAL_API_KEY)
throw new Error("No Mistral API key was set.");
this.className = "MistralLLM";
const { OpenAI: OpenAIApi } = require("openai");
this.openai = new OpenAIApi({
baseURL: "https://api.mistral.ai/v1",
apiKey: process.env.MISTRAL_API_KEY ?? null,
});
this.model =
modelPreference || process.env.MISTRAL_MODEL_PREF || "mistral-tiny";
this.limits = {
history: this.promptWindowLimit() * 0.15,
system: this.promptWindowLimit() * 0.15,
user: this.promptWindowLimit() * 0.7,
};
this.embedder = embedder ?? new NativeEmbedder();
this.defaultTemp = 0.0;
this.log("Initialized with model:", this.model);View on GitHub (pinned to 526360e320)
Solutions
- Add MISTRAL_API_KEY to server/.env with a valid key from console.mistral.ai.
- Restart the server to reload env.
- Confirm process.env.MISTRAL_API_KEY is populated in the running process.
- For containerized deploys, inject the env var into the container spec.
Example fix
// server/.env MISTRAL_API_KEY=your_key_here MISTRAL_MODEL_PREF=mistral-tiny
Defensive patterns
Strategy: validation
Validate before calling
if (!process.env.MISTRAL_API_KEY) {
throw new Error('MISTRAL_API_KEY missing — set it before enabling Mistral.');
} Try / catch
try {
const llm = new MistralLLM(embedder, modelPref);
} catch (e) {
if (/No Mistral API key/i.test(e.message)) {
// config error — guide user to set MISTRAL_API_KEY
}
} Prevention
- Validate Mistral credentials in the provider factory before construction.
- Run a startup env check for every enabled provider's key.
- Keep the admin credential form and provider selector coupled.
When it happens
Trigger: Instantiating `new MistralLLM(...)` when MISTRAL_API_KEY is unset/empty. AnythingLLM hits this when the workspace provider is set to Mistral but credentials are missing.
Common situations: Mistral provider selected without configuring the key; .env not reloaded after editing; typo (MISTRAL_APIKEY, MISTRAL_KEY); secret dropped from the deployment env.
Related errors
- No Minimax API key was set.
- No Moonshot AI API key was set.
- No Novita API key was set.
- No Perplexity API key was set.
- No PPIO API key was set.
AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13).
Data as JSON: /api/errors/4bf492818fd73cb0.
Report an issue: GitHub.