Mintplex-Labs/anything-llm · critical · Error
Anthropic API key must be provided to use agents.
Error message
Anthropic API key must be provided to use agents.
What it means
checkSetup() (index.js:134-137) throws for provider === "anthropic" when process.env.ANTHROPIC_API_KEY is falsy. The agent layer refuses to proceed rather than sending an unauthenticated request.
Source
Thrown at server/utils/agents/index.js:136
}
);
});
return agentHistory;
} catch (e) {
this.log("Error loading chat history", e.message);
return [];
}
}
checkSetup() {
switch (this.provider) {
case "openai":
if (!process.env.OPEN_AI_KEY)
throw new Error("OpenAI API key must be provided to use agents.");
break;
case "anthropic":
if (!process.env.ANTHROPIC_API_KEY)
throw new Error("Anthropic API key must be provided to use agents.");
break;
case "lmstudio":
if (!process.env.LMSTUDIO_BASE_PATH)
throw new Error("LMStudio base path must be provided to use agents.");
break;
case "ollama":
if (!process.env.OLLAMA_BASE_PATH)
throw new Error("Ollama base path must be provided to use agents.");
break;
case "groq":
if (!process.env.GROQ_API_KEY)
throw new Error("Groq API key must be provided to use agents.");
break;
case "togetherai":
if (!process.env.TOGETHER_AI_API_KEY)
throw new Error("TogetherAI API key must be provided to use agents.");
break;
case "azure":View on GitHub (pinned to 526360e320)
Solutions
- Set ANTHROPIC_API_KEY in .env to a valid Anthropic API key.
- Restart the server so the env is reloaded.
- For Docker, inject the key via the compose env block or -e.
- Confirm the key is active in the Anthropic console.
Example fix
# before (.env) # ANTHROPIC_API_KEY= # after (.env) ANTHROPIC_API_KEY=sk-ant-...validkey...
Defensive patterns
Strategy: validation
Validate before calling
function anthropicAgentReady() {
return Boolean(process.env.ANTHROPIC_API_KEY && process.env.ANTHROPIC_API_KEY.trim());
}
if (provider === "anthropic" && !anthropicAgentReady())
throw new Error("Set ANTHROPIC_API_KEY before enabling the anthropic agent."); Try / catch
try {
agent.checkSetup();
} catch (e) {
if (/ANTHROPIC_API_KEY|API key must be provided/i.test(e.message)) {
throw new Error("Anthropic agent is not configured: set ANTHROPIC_API_KEY in .env and restart.");
}
throw e;
} Prevention
- Call checkSetup() at boot to fail fast.
- Restart the server after setting the key.
- Inject secrets via Docker env, never bake them into images.
- Confirm the key is active in the Anthropic console.
When it happens
Trigger: Selecting the anthropic agent provider while ANTHROPIC_API_KEY is unset or empty in the server environment.
Common situations: Anthropic provider chosen without configuring the key, a renamed env var, or a deployment that didn't propagate the secret to the server container.
Related errors
- OpenAI API key must be provided to use agents.
- Groq API key must be provided to use agents.
- TogetherAI API key must be provided to use agents.
- No Anthropic API key was set.
- No xAI API key was set.
AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13).
Data as JSON: /api/errors/415cc66a3b08c589.
Report an issue: GitHub.