{"record":{"id":"bec2b7ab12fca6a6","repo":"Mintplex-Labs/anything-llm","slug":"no-groq-api-key-was-set-bec2b7","errorCode":null,"errorMessage":"No Groq API key was set.","messagePattern":"No Groq API key was set\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/utils/SpeechToText/groq/index.js","lineNumber":4,"sourceCode":"class GroqSTT {\n  constructor() {\n    if (!process.env.STT_GROQ_API_KEY)\n      throw new Error(\"No Groq API key was set.\");\n    const { OpenAI: OpenAIApi } = require(\"openai\");\n    this.openai = new OpenAIApi({\n      baseURL: \"https://api.groq.com/openai/v1\",\n      apiKey: process.env.STT_GROQ_API_KEY,\n    });\n    this.model = process.env.STT_GROQ_MODEL ?? \"whisper-large-v3-turbo\";\n  }\n\n  #log(text, ...args) {\n    console.log(`\\x1b[32m[GroqSTT]\\x1b[0m ${text}`, ...args);\n  }\n\n  /**\n   * Transcribes an audio buffer to text using the Groq STT service.\n   * @param {Buffer} audioBuffer - The audio buffer to be transcribed.\n   * @param {string} filename - Original filename, used to hint the audio container/codec to Groq.\n   * @returns {Promise<string>} The transcribed text.\n   */","sourceCodeStart":1,"sourceCodeEnd":22,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/3aec848f2885144aa8f1e53b9731a04310d5d558/server/utils/SpeechToText/groq/index.js#L1-L22","documentation":"GroqSTT's constructor throws when process.env.STT_GROQ_API_KEY is unset or empty, before the OpenAI-compatible client to https://api.groq.com/openai/v1 is created. The check runs at instantiation, i.e. the first transcription after STT_PROVIDER=groq is configured.","triggerScenarios":"STT_PROVIDER=groq set but STT_GROQ_API_KEY missing from the environment; variable present in .env but the process was started before the edit; wrong variable name used (e.g. GROQ_API_KEY without the STT_ prefix).","commonSituations":"Env var name confusion between the LLM-side Groq key and the STT-side key; Docker/compose not passing the variable; trailing whitespace or quotes around the key value in .env.","solutions":["Add STT_GROQ_API_KEY=<key> (a key from console.groq.com) to .env and restart","Optionally set STT_GROQ_MODEL (defaults to whisper-large-v3-turbo)","Ensure Docker passes the variable into the container","Double-check the exact prefix STT_GROQ_API_KEY, not GROQ_API_KEY"],"exampleFix":"# before (.env)\nSTT_PROVIDER=groq\n\n# after (.env)\nSTT_PROVIDER=groq\nSTT_GROQ_API_KEY=gsk_...","handlingStrategy":"validation","validationCode":"if (process.env.STT_PROVIDER === 'groq' && !process.env.STT_GROQ_API_KEY) {\n  throw new Error('STT_PROVIDER=groq requires STT_GROQ_API_KEY to be set');\n}","typeGuard":null,"tryCatchPattern":"try {\n  stt = new GroqSTT();\n} catch (err) {\n  if (err.message === 'No Groq API key was set.') {\n    // prompt for the key or fall back to another provider\n  }\n  throw err;\n}","preventionTips":["Use the exact STT_GROQ_API_KEY name — not GROQ_API_KEY or the LLM-side variable","Restart after .env edits and pass env through in containerized deployments","Validate provider env pairs in a startup checklist"],"tags":["groq","speech-to-text","environment-variable","constructor"],"backgroundTag":"missing-env-var","analyzedSha":"3aec848f2885144aa8f1e53b9731a04310d5d558","analyzedAt":"2026-08-18T10:02:21.017Z","contentChangedAt":"2026-08-18T10:02:21.017Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}