Mintplex-Labs/anything-llm · critical · Error

Groq API key must be provided to use agents.

Error message

Groq API key must be provided to use agents.

What it means

checkSetup() (index.js:146-149) throws for provider === "groq" when process.env.GROQ_API_KEY is falsy, preventing an unauthenticated call to the Groq Cloud API.

Source

Thrown at server/utils/agents/index.js:148

      case "openai":
        if (!process.env.OPEN_AI_KEY)
          throw new Error("OpenAI API key must be provided to use agents.");
        break;
      case "anthropic":
        if (!process.env.ANTHROPIC_API_KEY)
          throw new Error("Anthropic API key must be provided to use agents.");
        break;
      case "lmstudio":
        if (!process.env.LMSTUDIO_BASE_PATH)
          throw new Error("LMStudio base path must be provided to use agents.");
        break;
      case "ollama":
        if (!process.env.OLLAMA_BASE_PATH)
          throw new Error("Ollama base path must be provided to use agents.");
        break;
      case "groq":
        if (!process.env.GROQ_API_KEY)
          throw new Error("Groq API key must be provided to use agents.");
        break;
      case "togetherai":
        if (!process.env.TOGETHER_AI_API_KEY)
          throw new Error("TogetherAI API key must be provided to use agents.");
        break;
      case "azure":
        if (!process.env.AZURE_OPENAI_ENDPOINT || !process.env.AZURE_OPENAI_KEY)
          throw new Error(
            "Azure OpenAI API endpoint and key must be provided to use agents."
          );
        break;
      case "koboldcpp":
        if (!process.env.KOBOLD_CPP_BASE_PATH)
          throw new Error(
            "KoboldCPP must have a valid base path to use for the api."
          );
        break;
      case "localai":

View on GitHub (pinned to 526360e320)

Solutions

  1. Set GROQ_API_KEY in .env to a valid Groq Cloud API key.
  2. Restart the server to reload the env.
  3. For Docker, pass the key via the compose env block or -e.
  4. Confirm the key is valid at console.groq.com.

Example fix

# before (.env)
# GROQ_API_KEY=

# after (.env)
GROQ_API_KEY=gsk_...validkey...
Defensive patterns

Strategy: validation

Validate before calling

function groqAgentReady() {
  return Boolean(process.env.GROQ_API_KEY && process.env.GROQ_API_KEY.trim());
}
if (provider === "groq" && !groqAgentReady())
  throw new Error("Set GROQ_API_KEY before enabling the groq agent.");

Try / catch

try {
  agent.checkSetup();
} catch (e) {
  if (/GROQ_API_KEY|API key must be provided/i.test(e.message)) {
    throw new Error("Groq agent is not configured: set GROQ_API_KEY in .env and restart.");
  }
  throw e;
}

Prevention

When it happens

Trigger: Selecting the groq agent provider while GROQ_API_KEY is unset or empty in the server environment.

Common situations: Groq provider selected without configuring the key, a typo in the env name, or a deployment that didn't inject the secret.

Related errors


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