{"record":{"id":"ec1b3b44935268b9","repo":"Mintplex-Labs/anything-llm","slug":"perplexity-chat-this-model-is-not-valid-for-ch","errorCode":null,"errorMessage":"Perplexity chat: ${this.model} is not valid for chat completion!","messagePattern":"Perplexity chat: (.+?) is not valid for chat completion!","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/utils/AiProviders/perplexity/index.js","lineNumber":96,"sourceCode":"    return availableModels.hasOwnProperty(model);\n  }\n\n  constructPrompt({\n    systemPrompt = \"\",\n    contextTexts = [],\n    chatHistory = [],\n    userPrompt = \"\",\n  }) {\n    const prompt = {\n      role: \"system\",\n      content: `${systemPrompt}${this.#appendContext(contextTexts)}`,\n    };\n    return [prompt, ...chatHistory, { role: \"user\", content: userPrompt }];\n  }\n\n  async getChatCompletion(messages = null, { temperature = 0.7 }) {\n    if (!(await this.isValidChatCompletionModel(this.model)))\n      throw new Error(\n        `Perplexity chat: ${this.model} is not valid for chat completion!`\n      );\n\n    const result = await LLMPerformanceMonitor.measureAsyncFunction(\n      this.openai.chat.completions\n        .create({\n          model: this.model,\n          messages,\n          temperature,\n        })\n        .catch((e) => {\n          throw new Error(e.message);\n        })\n    );\n\n    if (\n      !result.output.hasOwnProperty(\"choices\") ||\n      result.output.choices.length === 0","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/20f6d3546c1938bfea1ad304f58a592dddcc5948/server/utils/AiProviders/perplexity/index.js#L78-L114","documentation":"Pre-flight guard in PerplexityLLM.getChatCompletion: the configured model is not a key in the bundled Perplexity MODELS list, so a completion would target an unsupported Sonar model and is rejected before the API call.","triggerScenarios":"Thrown when the configured Perplexity model is not a chat model.","commonSituations":"Model preference set to an invalid model.","solutions":["Select a Perplexity model valid for chat completion."],"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"}