Mintplex-Labs/anything-llm · error · Error

GroqAI:chatCompletion: ${this.model} is not valid for chat c

Error message

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

What it means

Thrown at the top of getChatCompletion when isValidChatCompletionModel(this.model) resolves false. Unlike Foundry/GenericOpenAI (which only check for a falsy model), Groq validates the model against its known MODEL_MAP, so a non-empty but unrecognized id also trips this guard.

Source

Thrown at server/utils/AiProviders/groq/index.js:175

    systemPrompt = "",
    contextTexts = [],
    chatHistory = [],
    userPrompt = "",
    attachments = [], // This is the specific attachment for only this prompt
  }) {
    // NOTICE: SEE GroqLLM.#conditionalPromptStruct for more information on how attachments are handled with Groq.
    return this.#conditionalPromptStruct({
      systemPrompt,
      contextTexts,
      chatHistory,
      userPrompt,
      attachments,
    });
  }

  async getChatCompletion(messages = null, { temperature = 0.7 }) {
    if (!(await this.isValidChatCompletionModel(this.model)))
      throw new Error(
        `GroqAI:chatCompletion: ${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 526360e320)

Solutions

  1. Check Groq's current model list (GET /v1/models) and set GROQ_MODEL_PREF to a live id
  2. Update AnythingLLM's server/utils/AiProviders/modelMap.js MODEL_MAP if a new model is missing
  3. Pass a valid modelPreference when constructing GroqLLM
  4. Restart the server after fixing .env

Example fix

// before
// .env: GROQ_MODEL_PREF=llama-3-70b-chat   // deprecated/renamed

// after
// .env: GROQ_MODEL_PREF=llama-3.1-8b-instant
Defensive patterns

Strategy: validation

Validate before calling

const valid = await groqLlm.isValidChatCompletionModel(model);
if (!valid) {
  throw new ConfigError(`GROQ_MODEL_PREF '${model}' is not in Groq's MODEL_MAP.`);
}

Type guard

const isKnownGroqModel = (id, MODEL_MAP) =>
  Object.values(MODEL_MAP).flat().includes(id);

Prevention

When it happens

Trigger: Calling getChatCompletion with a this.model that is not present in the Groq MODEL_MAP — a typo, a deprecated model id, or a model Groq removed from its catalog.

Common situations: GROQ_MODEL_PREF set to a model Groq deprecated (e.g. an old llama/gemma id); typo in the model id; MODEL_MAP in modelMap.js is out of date relative to Groq's current catalog.

Related errors


AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13). Data as JSON: /api/errors/8e8822ec14c7245b. Report an issue: GitHub.