{"record":{"id":"8e8822ec14c7245b","repo":"Mintplex-Labs/anything-llm","slug":"groqai-chatcompletion-this-model-is-not-valid","errorCode":null,"errorMessage":"GroqAI:chatCompletion: ${this.model} is not valid for chat completion!","messagePattern":"GroqAI:chatCompletion: (.+?) is not valid for chat completion!","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/utils/AiProviders/groq/index.js","lineNumber":175,"sourceCode":"    systemPrompt = \"\",\n    contextTexts = [],\n    chatHistory = [],\n    userPrompt = \"\",\n    attachments = [], // This is the specific attachment for only this prompt\n  }) {\n    // NOTICE: SEE GroqLLM.#conditionalPromptStruct for more information on how attachments are handled with Groq.\n    return this.#conditionalPromptStruct({\n      systemPrompt,\n      contextTexts,\n      chatHistory,\n      userPrompt,\n      attachments,\n    });\n  }\n\n  async getChatCompletion(messages = null, { temperature = 0.7 }) {\n    if (!(await this.isValidChatCompletionModel(this.model)))\n      throw new Error(\n        `GroqAI:chatCompletion: ${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":157,"sourceCodeEnd":193,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/utils/AiProviders/groq/index.js#L157-L193","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Check Groq's current model list (GET /v1/models) and set GROQ_MODEL_PREF to a live id","Update AnythingLLM's server/utils/AiProviders/modelMap.js MODEL_MAP if a new model is missing","Pass a valid modelPreference when constructing GroqLLM","Restart the server after fixing .env"],"exampleFix":"// before\n// .env: GROQ_MODEL_PREF=llama-3-70b-chat   // deprecated/renamed\n\n// after\n// .env: GROQ_MODEL_PREF=llama-3.1-8b-instant","handlingStrategy":"validation","validationCode":"const valid = await groqLlm.isValidChatCompletionModel(model);\nif (!valid) {\n  throw new ConfigError(`GROQ_MODEL_PREF '${model}' is not in Groq's MODEL_MAP.`);\n}","typeGuard":"const isKnownGroqModel = (id, MODEL_MAP) =>\n  Object.values(MODEL_MAP).flat().includes(id);","tryCatchPattern":null,"preventionTips":["Keep server/utils/AiProviders/modelMap.js in sync with Groq's catalog","Validate the model id at startup against MODEL_MAP","Let the UI pick only from known model ids"],"tags":["groq","model-validation","model-map","chat-completion"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}