Mintplex-Labs/anything-llm · error · Error
Perplexity API key must be provided to use agents.
Error message
Perplexity API key must be provided to use agents.
What it means
Thrown by AgentHandler.checkSetup() (server/utils/agents/index.js:185) when the workspace agent provider is 'perplexity' but PERPLEXITY_API_KEY is unset/empty. Perplexity's online-API (Sonar models) requires this key, which is the only value the guard validates.
Source
Thrown at server/utils/agents/index.js:186
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;
case "fireworksai":
if (!process.env.FIREWORKS_AI_LLM_API_KEY)
throw new Error(
"FireworksAI API Key must be provided to use agents."
);
break;
case "deepseek":
if (!process.env.DEEPSEEK_API_KEY)View on GitHub (pinned to 526360e320)
Solutions
- Generate a key at https://www.perplexity.ai/settings/api and set PERPLEXITY_API_KEY in .env.
- Restart AnythingLLM to reload process.env.
- Verify with curl -H 'Authorization: Bearer $PERPLEXITY_API_KEY' https://api.perplexity.ai/chat/completions.
- Make sure the agent's chosen model is a Perplexity online model (e.g. sonar).
Example fix
// before (.env) // PERPLEXITY_API_KEY= // after (.env) PERPLEXITY_API_KEY=pplx-...your-key
Defensive patterns
Strategy: validation
Validate before calling
const key = process.env.PERPLEXITY_API_KEY;
if (!key || !key.startsWith('pplx-')) {
throw new Error(
'Cannot start Perplexity agent: set PERPLEXITY_API_KEY (from perplexity.ai/settings/api) in .env.'
);
} Try / catch
try {
await agentHandler.start();
} catch (e) {
if (/Perplexity API key must be provided/.test(e.message)) {
return respondConfigError('perplexity', ['PERPLEXITY_API_KEY']);
}
throw e;
} Prevention
- Create the key at perplexity.ai/settings/api and write it to .env immediately.
- Restart AnythingLLM so process.env reloads.
- Add a CI/startup assertion that PERPLEXITY_API_KEY is set when the provider is perplexity.
- Rotate revoked keys and keep .env out of version control.
When it happens
Trigger: An agent invocation runs with workspace.agentProvider === 'perplexity' while PERPLEXITY_API_KEY is absent from process.env. Path: #providerSetupAndCheck() -> checkSetup() at index.js:476.
Common situations: Perplexity selected in System > LLM Preference on a fresh install with no key; key created at perplexity.ai/settings/api but not added to .env; .env updated but the server not restarted; key invalidated after plan change.
Related errors
- OpenRouter API key must be provided to use agents.
- Mistral 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/232cb4f220c01f0d.
Report an issue: GitHub.