Mintplex-Labs/anything-llm · error · Error
Perplexity chat: is not valid for chat completion!
Error message
Perplexity chat: ${this.model} is not valid for chat completion! What it means
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.
Solutions
- Select a Perplexity model valid for chat completion.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown when the configured Perplexity model is not a chat model.
Common situations: Model preference set to an invalid model.
AI-assisted analysis of Mintplex-Labs/anything-llm@20f6d3546c (2026-08-18).
Data as JSON: /api/errors/ec1b3b44935268b9.
Report an issue: GitHub.
Appendix: source
Thrown at server/utils/AiProviders/perplexity/index.js:96
return availableModels.hasOwnProperty(model);
}
constructPrompt({
systemPrompt = "",
contextTexts = [],
chatHistory = [],
userPrompt = "",
}) {
const prompt = {
role: "system",
content: `${systemPrompt}${this.#appendContext(contextTexts)}`,
};
return [prompt, ...chatHistory, { role: "user", content: userPrompt }];
}
async getChatCompletion(messages = null, { temperature = 0.7 }) {
if (!(await this.isValidChatCompletionModel(this.model)))
throw new Error(
`Perplexity chat: ${this.model} is not valid for chat completion!`
);
const result = await LLMPerformanceMonitor.measureAsyncFunction(
this.openai.chat.completions
.create({
model: this.model,
messages,
temperature,
})
.catch((e) => {
throw new Error(e.message);
})
);
if (
!result.output.hasOwnProperty("choices") ||
result.output.choices.length === 0View on GitHub (pinned to 20f6d3546c)