{"record":{"id":"3cc3a90cfea9fad8","repo":"Mintplex-Labs/anything-llm","slug":"e-message-3cc3a9","errorCode":null,"errorMessage":"e.message","messagePattern":"e\\.message","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/utils/AiProviders/groq/index.js","lineNumber":187,"sourceCode":"      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\n    )\n      return null;\n\n    return {\n      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,","sourceCodeStart":169,"sourceCodeEnd":205,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/utils/AiProviders/groq/index.js#L169-L205","documentation":"Not a distinct error — the message is whatever the OpenAI SDK raised against Groq's endpoint. The `.catch((e) => { throw new Error(e.message); })` wrapper re-throws only the text, discarding the SDK error subclass (Groq's errors include rate-limit tokens-per-minute data) and the stack.","triggerScenarios":"this.openai.chat.completions.create({ model, messages, temperature }) rejecting: Groq TPM/RPM rate limit (429), invalid model (404), auth failure (401), prompt too long, or a Groq platform 5xx.","commonSituations":"Free-tier TPM exceeded; model id deprecated since the last config; prompt exceeds the model's context window; transient Groq overload (529).","solutions":["Read e.message — Groq rate-limit errors include the limit and window","If 429, throttle requests or upgrade the Groq plan","Confirm GROQ_MODEL_PREF is still valid against GET /v1/models","Shorten the prompt if the message mentions context length"],"exampleFix":"// before\n.catch((e) => { throw new Error(e.message); })\n\n// after\n.catch((e) => { throw e; })","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  return await llm.getChatCompletion(messages, { temperature });\n} catch (e) {\n  const msg = e.message;\n  if (/rate_limit|429|tpm|rpm/i.test(msg)) {\n    await backoff();            // Groq rate limits are time-bounded\n    return retryOnce();\n  }\n  if (/model_not_found|deprecat/i.test(msg)) throw new UnknownModelError(msg);\n  throw e;\n}","preventionTips":["Re-throw the original SDK error to keep Groq's rate-limit metadata","Implement request-level rate limiting using Groq's TPM/RPM headers","Pre-validate the model id against MODEL_MAP"],"tags":["groq","openai-sdk","error-wrapping","chat-completion","rate-limit"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}