Mintplex-Labs/anything-llm · error · Error

No Groq API key was set.

Error message

No Groq API key was set.

What it means

Thrown by the GroqSTT constructor when process.env.STT_GROQ_API_KEY is falsy. The class builds an OpenAI-compatible client pointed at https://api.groq.com/openai/v1 and needs the key for the Authorization header. It hard-fails at instantiation, so selecting STT_PROVIDER=groq without the key prevents service creation.

Source

Thrown at server/utils/SpeechToText/groq/index.js:4

class GroqSTT {
  constructor() {
    if (!process.env.STT_GROQ_API_KEY)
      throw new Error("No Groq API key was set.");
    const { OpenAI: OpenAIApi } = require("openai");
    this.openai = new OpenAIApi({
      baseURL: "https://api.groq.com/openai/v1",
      apiKey: process.env.STT_GROQ_API_KEY,
    });
    this.model = process.env.STT_GROQ_MODEL ?? "whisper-large-v3-turbo";
  }

  #log(text, ...args) {
    console.log(`\x1b[32m[GroqSTT]\x1b[0m ${text}`, ...args);
  }

  /**
   * Transcribes an audio buffer to text using the Groq STT service.
   * @param {Buffer} audioBuffer - The audio buffer to be transcribed.
   * @param {string} filename - Original filename, used to hint the audio container/codec to Groq.
   * @returns {Promise<string>} The transcribed text.
   */

View on GitHub (pinned to 526360e320)

Solutions

  1. Add STT_GROQ_API_KEY=<your-key> to .env and restart.
  2. In Docker, ensure the variable is passed to the container.
  3. Confirm the exact name STT_GROQ_API_KEY.
  4. Optionally set STT_GROQ_MODEL (defaults to whisper-large-v3-turbo) if you need a different model.

Example fix

# before
STT_PROVIDER=groq
# key missing

# after
STT_PROVIDER=groq
STT_GROQ_API_KEY=gsk_yourgroqkey
Defensive patterns

Strategy: validation

Validate before calling

if (process.env.STT_PROVIDER === "groq" && !process.env.STT_GROQ_API_KEY) {
  throw new Error("STT_PROVIDER is 'groq' but STT_GROQ_API_KEY is not set.");
}

Try / catch

try {
  return new GroqSTT();
} catch (e) {
  if (/No Groq API key/i.test(e.message)) {
    logger.error("Set STT_GROQ_API_KEY in .env, then restart.");
  }
  throw e;
}

Prevention

When it happens

Trigger: STT_PROVIDER=groq is set but STT_GROQ_API_KEY is missing/empty; env var added but process not restarted; key set under a different name.

Common situations: New deployment forgetting the Groq key; Docker env not propagated; .env not loaded; switching providers without updating keys.

Related errors


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