Mintplex-Labs/anything-llm · critical · Error
No Mistral API key was set.
Error message
No Mistral API key was set.
What it means
Thrown by the MistralEmbedder constructor when process.env.MISTRAL_API_KEY is falsy. Unlike the local embedders, Mistral's endpoint is hardcoded (api.mistral.ai/v1) so only the API key is required. The openai SDK is pointed at Mistral with the key; without it requests would 401, so construction aborts immediately.
Source
Thrown at server/utils/EmbeddingEngines/mistral/index.js:4
class MistralEmbedder {
constructor() {
if (!process.env.MISTRAL_API_KEY)
throw new Error("No Mistral API key was set.");
const { OpenAI: OpenAIApi } = require("openai");
this.openai = new OpenAIApi({
baseURL: "https://api.mistral.ai/v1",
apiKey: process.env.MISTRAL_API_KEY ?? null,
});
this.model = process.env.EMBEDDING_MODEL_PREF || "mistral-embed";
}
async embedTextInput(textInput) {
const result = await this.embedChunks(
Array.isArray(textInput) ? textInput : [textInput]
);
return result?.[0] || [];
}
async embedChunks(textChunks = []) {
try {View on GitHub (pinned to 526360e320)
Solutions
- Set MISTRAL_API_KEY in .env to a valid key from console.mistral.ai
- Restart AnythingLLM so the constructor re-reads env
- Confirm the key is valid with a direct curl to api.mistral.ai/v1/embeddings
Example fix
// before // MISTRAL_API_KEY unset // after MISTRAL_API_KEY=your-key-from-console.mistral.ai EMBEDDING_MODEL_PREF=mistral-embed
Defensive patterns
Strategy: validation
Validate before calling
function hasMistralKey(env = process.env) {
return typeof env.MISTRAL_API_KEY === 'string' &&
env.MISTRAL_API_KEY.trim().length > 0;
}
if (!hasMistralKey()) {
throw new Error('Missing MISTRAL_API_KEY.');
} Type guard
function isMistralKey(v) {
return typeof v === 'string' && /^[A-Za-z0-9_-]{20,}$/.test(v);
} Prevention
- Inject MISTRAL_API_KEY via the system settings, not a loose .env that can drift.
- Rotate keys on a schedule and update settings immediately.
- Validate presence at boot for the selected engine.
When it happens
Trigger: Selecting the Mistral embedding engine while MISTRAL_API_KEY is unset/empty; constructing `new MistralEmbedder()` before env load. The check on line 3 runs before the client is built.
Common situations: First-time Mistral setup; key rotated on the Mistral console but not in .env; key name typo (e.g. MISTRAL_KEY); secret not injected into the container/CI environment.
Related errors
- No OpenAI API key was set.
- No OpenRouter API key was set.
- LiteLLM must have a valid base path to use for the api.
- No embedding base path was set.
- No embedding model was set.
AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13).
Data as JSON: /api/errors/260068a13aa19266.
Report an issue: GitHub.