Mintplex-Labs/anything-llm · error · Error

CometAPI chat: is not valid for chat completion!

Error message

CometAPI chat: ${this.model} is not valid for chat completion!

What it means

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.

Solutions

  1. Select a model valid for chat completion in CometAPI settings.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown when the configured CometAPI model is not a chat model.

Common situations: Model preference set to an embedding or invalid model.


AI-assisted analysis of Mintplex-Labs/anything-llm@3aec848f28 (2026-08-18). Data as JSON: /api/errors/f234e32b7a5b429f. Report an issue: GitHub.

Appendix: source

Thrown at server/utils/AiProviders/cometapi/index.js:198

    attachments = [],
  }) {
    const prompt = {
      role: "system",
      content: `${systemPrompt}${this.#appendContext(contextTexts)}`,
    };
    return [
      prompt,
      ...formatChatHistory(chatHistory, this.#generateContent),
      {
        role: "user",
        content: this.#generateContent({ userPrompt, attachments }),
      },
    ];
  }

  async getChatCompletion(messages = null, { temperature = 0.7 }) {
    if (!(await this.isValidChatCompletionModel(this.model)))
      throw new Error(
        `CometAPI 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 === 0

View on GitHub (pinned to 3aec848f28)