{"record":{"id":"a99b787b3bfd7c8a","repo":"Mintplex-Labs/anything-llm","slug":"groqai-streamchatcompletion-this-model-is-not","errorCode":null,"errorMessage":"GroqAI:streamChatCompletion: ${this.model} is not valid for chat completion!","messagePattern":"GroqAI:streamChatCompletion: (.+?) is not valid for chat completion!","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/utils/AiProviders/groq/index.js","lineNumber":216,"sourceCode":"      textResponse: result.output.choices[0].message.content,\n      metrics: {\n        prompt_tokens: result.output.usage.prompt_tokens || 0,\n        completion_tokens: result.output.usage.completion_tokens || 0,\n        total_tokens: result.output.usage.total_tokens || 0,\n        outputTps:\n          result.output.usage.completion_tokens /\n          result.output.usage.completion_time,\n        duration: result.output.usage.total_time,\n        model: this.model,\n        provider: this.className,\n        timestamp: new Date(),\n      },\n    };\n  }\n\n  async streamGetChatCompletion(messages = null, { temperature = 0.7 }) {\n    if (!(await this.isValidChatCompletionModel(this.model)))\n      throw new Error(\n        `GroqAI:streamChatCompletion: ${this.model} is not valid for chat completion!`\n      );\n\n    const measuredStreamRequest = await LLMPerformanceMonitor.measureStream({\n      func: this.openai.chat.completions.create({\n        model: this.model,\n        stream: true,\n        messages,\n        temperature,\n      }),\n      messages,\n      runPromptTokenCalculation: false,\n      modelTag: this.model,\n      provider: this.className,\n    });\n\n    return measuredStreamRequest;\n  }","sourceCodeStart":198,"sourceCodeEnd":234,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/utils/AiProviders/groq/index.js#L198-L234","documentation":"Identical guard to the non-streaming Groq path but at the top of streamGetChatCompletion. It throws when isValidChatCompletionModel(this.model) is false — a model not in MODEL_MAP — before opening the streaming request.","triggerScenarios":"Calling streamGetChatCompletion with a this.model that is absent from Groq's MODEL_MAP: deprecated id, typo, or a model not yet added to AnythingLLM's map.","commonSituations":"GROQ_MODEL_PREF pointing at a model Groq removed; UI saved a model id that was later renamed; streaming a brand-new model before updating modelMap.js.","solutions":["Set GROQ_MODEL_PREF to an id present in GET /v1/models","Update server/utils/AiProviders/modelMap.js MODEL_MAP for new models","Pass a valid modelPreference at construction","Restart the server after the change"],"exampleFix":"// before\n// .env: GROQ_MODEL_PREF=llama2-70b-chat   // not in MODEL_MAP\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(`Model '${model}' is not valid for Groq streaming.`);\n}","typeGuard":"const isStreamableGroqModel = (id, MODEL_MAP) =>\n  Object.values(MODEL_MAP).flat().includes(id);","tryCatchPattern":null,"preventionTips":["Share model validation between stream and non-stream entry points","Update modelMap.js when Groq adds/removes models","Block saving a streaming config whose model is not in MODEL_MAP"],"tags":["groq","model-validation","model-map","streaming"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}