Mintplex-Labs/anything-llm · error · Error
Mistral API key must be provided to use agents.
Error message
Mistral API key must be provided to use agents.
What it means
Thrown by AgentHandler.checkSetup() (server/utils/agents/index.js:177) when the workspace agent provider is 'mistral' but MISTRAL_API_KEY is unset/empty. Mistral AI exposes its La Plateforme API behind this single key, so AnythingLLM validates it before building the agent session.
Source
Thrown at server/utils/agents/index.js:178
case "koboldcpp":
if (!process.env.KOBOLD_CPP_BASE_PATH)
throw new Error(
"KoboldCPP must have a valid base path to use for the api."
);
break;
case "localai":
if (!process.env.LOCAL_AI_BASE_PATH)
throw new Error(
"LocalAI must have a valid base path to use for the api."
);
break;
case "openrouter":
if (!process.env.OPENROUTER_API_KEY)
throw new Error("OpenRouter API key must be provided to use agents.");
break;
case "mistral":
if (!process.env.MISTRAL_API_KEY)
throw new Error("Mistral API key must be provided to use agents.");
break;
case "generic-openai":
if (!process.env.GENERIC_OPEN_AI_BASE_PATH)
throw new Error("API base path must be provided to use agents.");
break;
case "perplexity":
if (!process.env.PERPLEXITY_API_KEY)
throw new Error("Perplexity API key must be provided to use agents.");
break;
case "textgenwebui":
if (!process.env.TEXT_GEN_WEB_UI_BASE_PATH)
throw new Error(
"TextWebGenUI API base path must be provided to use agents."
);
break;
case "bedrock":
// No validations since there are many possible authentication methods
break;View on GitHub (pinned to 526360e320)
Solutions
- Create an API key at https://console.mistral.ai/api-keys and set MISTRAL_API_KEY in .env.
- Restart AnythingLLM to reload process.env.
- Validate the key with curl -H 'Authorization: Bearer $MISTRAL_API_KEY' https://api.mistral.ai/v1/models.
- Ensure the workspace's agent model is one your Mistral plan allows.
Example fix
// before (.env) // MISTRAL_API_KEY= // after (.env) MISTRAL_API_KEY=...your-mistral-key
Defensive patterns
Strategy: validation
Validate before calling
const key = process.env.MISTRAL_API_KEY;
if (!key) {
throw new Error(
'Cannot start Mistral agent: set MISTRAL_API_KEY (from console.mistral.ai/api-keys) in .env.'
);
} Try / catch
try {
await agentHandler.start();
} catch (e) {
if (/Mistral API key must be provided/.test(e.message)) {
return respondConfigError('mistral', ['MISTRAL_API_KEY']);
}
throw e;
} Prevention
- Generate the key in Mistral console and paste it into .env in the same step.
- Restart the Node process / Docker container after editing .env.
- Add a startup config validator that maps each provider to its required env vars.
- Treat .env as a secret; restrict file permissions and exclude from VCS.
When it happens
Trigger: An agent invocation runs with workspace.agentProvider === 'mistral' while MISTRAL_API_KEY is absent from process.env. Path: #providerSetupAndCheck() -> checkSetup() at index.js:476.
Common situations: Mistral chosen in System > LLM Preference without a key; key generated at console.mistral.ai but never pasted into .env; .env edited on disk while the Node process kept the old env; key revoked after a quota/security rotation.
Related errors
- OpenRouter API key must be provided to use agents.
- Perplexity API key must be provided to use agents.
- FireworksAI API Key must be provided to use agents.
- DeepSeek API Key must be provided to use agents.
- ApiPie API Key must be provided to use agents.
AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13).
Data as JSON: /api/errors/a8c608e82c6c50ef.
Report an issue: GitHub.