Mintplex-Labs/anything-llm · critical · Error

No Groq API key was set.

Error message

No Groq API key was set.

What it means

Thrown by the GroqLLM constructor when process.env.GROQ_API_KEY is unset. Groq (api.groq.com/openai/v1) is an OpenAI-compatible ultra-low-latency inference platform that authenticates via bearer token; without the key the OpenAI client cannot be used and the provider refuses to construct.

Source

Thrown at server/utils/AiProviders/groq/index.js:13

const { NativeEmbedder } = require("../../EmbeddingEngines/native");
const {
  LLMPerformanceMonitor,
} = require("../../helpers/chat/LLMPerformanceMonitor");
const {
  handleDefaultStreamResponseV2,
} = require("../../helpers/chat/responses");
const { MODEL_MAP } = require("../modelMap");

class GroqLLM {
  constructor(embedder = null, modelPreference = null) {
    const { OpenAI: OpenAIApi } = require("openai");
    if (!process.env.GROQ_API_KEY) throw new Error("No Groq API key was set.");
    this.className = "GroqLLM";

    this.openai = new OpenAIApi({
      baseURL: "https://api.groq.com/openai/v1",
      apiKey: process.env.GROQ_API_KEY,
    });
    this.model =
      modelPreference || process.env.GROQ_MODEL_PREF || "llama-3.1-8b-instant";
    this.limits = {
      history: this.promptWindowLimit() * 0.15,
      system: this.promptWindowLimit() * 0.15,
      user: this.promptWindowLimit() * 0.7,
    };

    this.embedder = embedder ?? new NativeEmbedder();
    this.defaultTemp = 0.7;
  }

View on GitHub (pinned to 526360e320)

Solutions

  1. Create a key at console.groq.com and set GROQ_API_KEY in .env
  2. Restart AnythingLLM so process.env reloads
  3. Verify with curl https://api.groq.com/openai/v1/models -H 'Authorization: bearer <key>'
  4. Pass the env var through in containerized deployments

Example fix

// before
// .env: GROQ_MODEL_PREF=llama-3.1-8b-instant   // no key

// after
// .env:
//   GROQ_API_KEY=gsk_...
//   GROQ_MODEL_PREF=llama-3.1-8b-instant
Defensive patterns

Strategy: validation

Validate before calling

if (!process.env.GROQ_API_KEY) {
  throw new ConfigError('Create a key at console.groq.com and set GROQ_API_KEY.');
}

Prevention

When it happens

Trigger: Constructing `new GroqLLM(embedder, modelPreference)` while GROQ_API_KEY is absent. Fires at provider selection when the user chose Groq but supplied no key.

Common situations: .env missing GROQ_API_KEY; key not created at console.groq.com; key revoked/expired; Docker deployment without env passthrough; free-tier key rate-limited into a revoked state.

Related errors


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