Mintplex-Labs/anything-llm · error
No Mistral API key was set.
Error message
No Mistral API key was set.
What it means
MistralLLM's constructor throws when process.env.MISTRAL_API_KEY is falsy, before the OpenAI-compatible client for https://api.mistral.ai/v1 is built. Any attempt to instantiate the provider (selecting Mistral, sending a chat, embedding-adjacent flows that construct LLMs) fails until the key is set.
Solutions
- Add MISTRAL_API_KEY=<key from console.mistral.ai> to the server's .env
- Restart the AnythingLLM server or container
- In Docker, confirm the variable name reaches the container (name only, never the value)
- Check for whitespace/quotes around the value in compose files
Example fix
# before # (MISTRAL_API_KEY not set) # after MISTRAL_API_KEY=your-mistral-key
Defensive patterns
Strategy: validation
Validate before calling
if (!process.env.MISTRAL_API_KEY)
throw new Error('Mistral provider selected but MISTRAL_API_KEY is not configured');
const llm = new MistralLLM(embedder); Try / catch
try {
const llm = new MistralLLM(embedder);
} catch (e) {
if (e.message === 'No Mistral API key was set.')
return respondConfigError(e); // configure key, restart, do not retry
throw e;
} Prevention
- Set MISTRAL_API_KEY before selecting Mistral in the UI
- Restart after .env edits
- Use --env-file in Docker rather than ad-hoc -e flags
- Add a preflight config check per selected provider
When it happens
Trigger: Choosing Mistral as the LLM provider with MISTRAL_API_KEY unset, misspelled, or empty; editing .env without restarting; containerized deployments where the variable was not injected.
Common situations: Typo'd variable name (MISTRAL_KEY, MISTRALAPI_KEY); .env edited but process not restarted; docker run without -e/--env-file; CI environments without the key.
Understand the failure class
Background: "API key is required" / "API key not found" / "No API key was set": the missing-api-key error family across 16 libraries — this error's family across 16 libraries.
Related errors
- No Minimax API key was set.
- No Moonshot AI API key was set.
- No Novita API key was set.
- No Groq API key was set.
- No Mistral API key was set.
AI-assisted analysis of Mintplex-Labs/anything-llm@3aec848f28 (2026-08-18).
Data as JSON: /api/errors/4bf492818fd73cb0.
Report an issue: GitHub.
Appendix: 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 3aec848f28)