{"record":{"id":"f234e32b7a5b429f","repo":"Mintplex-Labs/anything-llm","slug":"cometapi-chat-this-model-is-not-valid-for-chat","errorCode":null,"errorMessage":"CometAPI chat: ${this.model} is not valid for chat completion!","messagePattern":"CometAPI chat: (.+?) is not valid for chat completion!","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/utils/AiProviders/cometapi/index.js","lineNumber":198,"sourceCode":"    attachments = [],\n  }) {\n    const prompt = {\n      role: \"system\",\n      content: `${systemPrompt}${this.#appendContext(contextTexts)}`,\n    };\n    return [\n      prompt,\n      ...formatChatHistory(chatHistory, this.#generateContent),\n      {\n        role: \"user\",\n        content: this.#generateContent({ userPrompt, attachments }),\n      },\n    ];\n  }\n\n  async getChatCompletion(messages = null, { temperature = 0.7 }) {\n    if (!(await this.isValidChatCompletionModel(this.model)))\n      throw new Error(\n        `CometAPI 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":180,"sourceCodeEnd":216,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/3aec848f2885144aa8f1e53b9731a04310d5d558/server/utils/AiProviders/cometapi/index.js#L180-L216","documentation":"Pre-flight guard in CometApiLLM.getChatCompletion: isValidChatCompletionModel(this.model) resolved false, meaning the configured model does not appear in CometAPI's known/cached model list, so a completion request would target a model the service does not offer.","triggerScenarios":"Thrown when the configured CometAPI model is not a chat model.","commonSituations":"Model preference set to an embedding or invalid model.","solutions":["Select a model valid for chat completion in CometAPI settings."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3aec848f2885144aa8f1e53b9731a04310d5d558","analyzedAt":"2026-08-18T10:02:21.017Z","contentChangedAt":"2026-08-18T10:02:21.017Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}