{"record":{"id":"ace19a1ad2b7e728","repo":"Mintplex-Labs/anything-llm","slug":"no-perplexity-api-key-was-set","errorCode":null,"errorMessage":"No Perplexity API key was set.","messagePattern":"No Perplexity API key was set\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/utils/AiProviders/perplexity/index.js","lineNumber":21,"sourceCode":"const { isAbortError } = require(\"../../helpers/abortSignals\");\nconst {\n  writeResponseChunk,\n  clientAbortedHandler,\n} = require(\"../../helpers/chat/responses\");\nconst {\n  LLMPerformanceMonitor,\n} = require(\"../../helpers/chat/LLMPerformanceMonitor\");\nconst { getAnythingLLMUserAgent } = require(\"../../../endpoints/utils\");\n\nfunction perplexityModels() {\n  const { MODELS } = require(\"./models.js\");\n  return MODELS || {};\n}\n\nclass PerplexityLLM {\n  constructor(embedder = null, modelPreference = null) {\n    if (!process.env.PERPLEXITY_API_KEY)\n      throw new Error(\"No Perplexity API key was set.\");\n\n    this.className = \"PerplexityLLM\";\n    const { OpenAI: OpenAIApi } = require(\"openai\");\n    this.openai = new OpenAIApi({\n      baseURL: \"https://api.perplexity.ai\",\n      apiKey: process.env.PERPLEXITY_API_KEY ?? null,\n      defaultHeaders: {\n        \"X-Pplx-Integration\": getAnythingLLMUserAgent(),\n      },\n    });\n    this.model =\n      modelPreference ||\n      process.env.PERPLEXITY_MODEL_PREF ||\n      \"llama-3-sonar-large-32k-online\"; // Give at least a unique model to the provider as last fallback.\n    this.limits = {\n      history: this.promptWindowLimit() * 0.15,\n      system: this.promptWindowLimit() * 0.15,\n      user: this.promptWindowLimit() * 0.7,","sourceCodeStart":3,"sourceCodeEnd":39,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/20f6d3546c1938bfea1ad304f58a592dddcc5948/server/utils/AiProviders/perplexity/index.js#L3-L39","documentation":"Configuration guard thrown by the PerplexityLLM constructor: the perplexity provider was selected but the PERPLEXITY_API_KEY environment variable is empty/unset, so the online-models/search API cannot be authenticated.","triggerScenarios":"Thrown at provider construction when no Perplexity API key is configured.","commonSituations":"Perplexity selected as LLM provider without an API key.","solutions":["Set the Perplexity API key in provider settings or env."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"20f6d3546c1938bfea1ad304f58a592dddcc5948","analyzedAt":"2026-08-18T10:02:21.017Z","contentChangedAt":"2026-08-18T10:02:21.017Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}