{"record":{"id":"1070b972ced158de","repo":"Mintplex-Labs/anything-llm","slug":"no-deepgram-api-key-was-set","errorCode":null,"errorMessage":"No Deepgram API key was set.","messagePattern":"No Deepgram API key was set\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/utils/SpeechToText/deepgram/index.js","lineNumber":4,"sourceCode":"class DeepgramSTT {\n  constructor() {\n    if (!process.env.STT_DEEPGRAM_API_KEY)\n      throw new Error(\"No Deepgram API key was set.\");\n\n    this.apiKey = process.env.STT_DEEPGRAM_API_KEY;\n    this.model = process.env.STT_DEEPGRAM_MODEL ?? \"nova-3\";\n    this.endpoint = \"https://api.deepgram.com/v1/listen\";\n    this.#log(`Service ready with model: ${this.model}`);\n  }\n\n  #log(text, ...args) {\n    console.log(`\\x1b[32m[DeepgramSTT]\\x1b[0m ${text}`, ...args);\n  }\n\n  // Map common audio file extensions to a Content-Type that Deepgram accepts.\n  // Deepgram auto-detects most containers from the bytes but a hint is best.\n  #contentTypeFromFilename(filename) {\n    const ext = filename.split(\".\").pop()?.toLowerCase();\n    switch (ext) {\n      case \"wav\":\n        return \"audio/wav\";","sourceCodeStart":1,"sourceCodeEnd":22,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/3aec848f2885144aa8f1e53b9731a04310d5d558/server/utils/SpeechToText/deepgram/index.js#L1-L22","documentation":"DeepgramSTT's constructor throws when process.env.STT_DEEPGRAM_API_KEY is unset or empty, before any request is made. The class is created on demand when the speech-to-text provider is set to deepgram, so the error appears at the first transcription attempt (or startup warm-up) after selecting the provider.","triggerScenarios":"STT_PROVIDER=deepgram in the environment but STT_DEEPGRAM_API_KEY missing; key present in .env but server/container not restarted; variable name typo'd (e.g. DEEPGRAM_API_KEY without the STT_ prefix).","commonSituations":"Docker deployments missing the -e flag; .env edited while the process was running; copying the Deepgram key with surrounding quotes/spaces making it technically set but rejected later with 401.","solutions":["Add STT_DEEPGRAM_API_KEY=<key> to .env and restart the server","Optionally set STT_DEEPGRAM_MODEL (defaults to nova-3) to a valid model name","For Docker, pass the variable into the container environment and recreate it","Verify the exact variable name spelling and that the value is non-empty"],"exampleFix":"# before (.env)\nSTT_PROVIDER=deepgram\n\n# after (.env)\nSTT_PROVIDER=deepgram\nSTT_DEEPGRAM_API_KEY=your-deepgram-key","handlingStrategy":"validation","validationCode":"if (process.env.STT_PROVIDER === 'deepgram' && !process.env.STT_DEEPGRAM_API_KEY) {\n  throw new Error('STT_PROVIDER=deepgram requires STT_DEEPGRAM_API_KEY to be set');\n}","typeGuard":null,"tryCatchPattern":"try {\n  stt = new DeepgramSTT();\n} catch (err) {\n  if (err.message === 'No Deepgram API key was set.') {\n    // fall back to default STT or prompt for the key\n  }\n  throw err;\n}","preventionTips":["Validate provider-specific env vars in a boot-time dependency check","Restart the process after every .env change","Keep a mapping of provider → required env keys and assert it in CI config tests"],"tags":["deepgram","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"}