{"record":{"id":"7bd2cb46e58313f5","repo":"Mintplex-Labs/anything-llm","slug":"no-groq-api-key-was-set","errorCode":null,"errorMessage":"No Groq API key was set.","messagePattern":"No Groq API key was set\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"server/utils/AiProviders/groq/index.js","lineNumber":13,"sourceCode":"const { NativeEmbedder } = require(\"../../EmbeddingEngines/native\");\nconst {\n  LLMPerformanceMonitor,\n} = require(\"../../helpers/chat/LLMPerformanceMonitor\");\nconst {\n  handleDefaultStreamResponseV2,\n} = require(\"../../helpers/chat/responses\");\nconst { MODEL_MAP } = require(\"../modelMap\");\n\nclass GroqLLM {\n  constructor(embedder = null, modelPreference = null) {\n    const { OpenAI: OpenAIApi } = require(\"openai\");\n    if (!process.env.GROQ_API_KEY) throw new Error(\"No Groq API key was set.\");\n    this.className = \"GroqLLM\";\n\n    this.openai = new OpenAIApi({\n      baseURL: \"https://api.groq.com/openai/v1\",\n      apiKey: process.env.GROQ_API_KEY,\n    });\n    this.model =\n      modelPreference || process.env.GROQ_MODEL_PREF || \"llama-3.1-8b-instant\";\n    this.limits = {\n      history: this.promptWindowLimit() * 0.15,\n      system: this.promptWindowLimit() * 0.15,\n      user: this.promptWindowLimit() * 0.7,\n    };\n\n    this.embedder = embedder ?? new NativeEmbedder();\n    this.defaultTemp = 0.7;\n  }\n","sourceCodeStart":1,"sourceCodeEnd":31,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/utils/AiProviders/groq/index.js#L1-L31","documentation":"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.","triggerScenarios":"Constructing `new GroqLLM(embedder, modelPreference)` while GROQ_API_KEY is absent. Fires at provider selection when the user chose Groq but supplied no key.","commonSituations":".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.","solutions":["Create a key at console.groq.com and set GROQ_API_KEY in .env","Restart AnythingLLM so process.env reloads","Verify with curl https://api.groq.com/openai/v1/models -H 'Authorization: bearer <key>'","Pass the env var through in containerized deployments"],"exampleFix":"// before\n// .env: GROQ_MODEL_PREF=llama-3.1-8b-instant   // no key\n\n// after\n// .env:\n//   GROQ_API_KEY=gsk_...\n//   GROQ_MODEL_PREF=llama-3.1-8b-instant","handlingStrategy":"validation","validationCode":"if (!process.env.GROQ_API_KEY) {\n  throw new ConfigError('Create a key at console.groq.com and set GROQ_API_KEY.');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate the key with GET /v1/models at startup","Store Groq keys via a secrets manager in production","Surface missing-key as a UI banner"],"tags":["groq","configuration","authentication","environment-variables","constructor"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}