{"record":{"id":"232cb4f220c01f0d","repo":"Mintplex-Labs/anything-llm","slug":"perplexity-api-key-must-be-provided-to-use-agents","errorCode":null,"errorMessage":"Perplexity API key must be provided to use agents.","messagePattern":"Perplexity API key must be provided to use agents\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/utils/agents/index.js","lineNumber":186,"sourceCode":"          throw new Error(\n            \"LocalAI must have a valid base path to use for the api.\"\n          );\n        break;\n      case \"openrouter\":\n        if (!process.env.OPENROUTER_API_KEY)\n          throw new Error(\"OpenRouter API key must be provided to use agents.\");\n        break;\n      case \"mistral\":\n        if (!process.env.MISTRAL_API_KEY)\n          throw new Error(\"Mistral API key must be provided to use agents.\");\n        break;\n      case \"generic-openai\":\n        if (!process.env.GENERIC_OPEN_AI_BASE_PATH)\n          throw new Error(\"API base path must be provided to use agents.\");\n        break;\n      case \"perplexity\":\n        if (!process.env.PERPLEXITY_API_KEY)\n          throw new Error(\"Perplexity API key must be provided to use agents.\");\n        break;\n      case \"textgenwebui\":\n        if (!process.env.TEXT_GEN_WEB_UI_BASE_PATH)\n          throw new Error(\n            \"TextWebGenUI API base path must be provided to use agents.\"\n          );\n        break;\n      case \"bedrock\":\n        // No validations since there are many possible authentication methods\n        break;\n      case \"fireworksai\":\n        if (!process.env.FIREWORKS_AI_LLM_API_KEY)\n          throw new Error(\n            \"FireworksAI API Key must be provided to use agents.\"\n          );\n        break;\n      case \"deepseek\":\n        if (!process.env.DEEPSEEK_API_KEY)","sourceCodeStart":168,"sourceCodeEnd":204,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/utils/agents/index.js#L168-L204","documentation":"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.","triggerScenarios":"An agent invocation runs with workspace.agentProvider === 'perplexity' while PERPLEXITY_API_KEY is absent from process.env. Path: #providerSetupAndCheck() -> checkSetup() at index.js:476.","commonSituations":"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.","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)."],"exampleFix":"// before (.env)\n// PERPLEXITY_API_KEY=\n\n// after (.env)\nPERPLEXITY_API_KEY=pplx-...your-key","handlingStrategy":"validation","validationCode":"const key = process.env.PERPLEXITY_API_KEY;\nif (!key || !key.startsWith('pplx-')) {\n  throw new Error(\n    'Cannot start Perplexity agent: set PERPLEXITY_API_KEY (from perplexity.ai/settings/api) in .env.'\n  );\n}","typeGuard":null,"tryCatchPattern":"try {\n  await agentHandler.start();\n} catch (e) {\n  if (/Perplexity API key must be provided/.test(e.message)) {\n    return respondConfigError('perplexity', ['PERPLEXITY_API_KEY']);\n  }\n  throw e;\n}","preventionTips":["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."],"tags":["agents","llm-provider","perplexity","api-key","environment-variables","config"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}