{"record":{"id":"f85aeaee4c1acc5d","repo":"Mintplex-Labs/anything-llm","slug":"deepgram-transcription-failed-response-status","errorCode":null,"errorMessage":"Deepgram transcription failed (${response.status}) - ${errBody}","messagePattern":"Deepgram transcription failed \\((.+?)\\) - (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/utils/SpeechToText/deepgram/index.js","lineNumber":61,"sourceCode":"   * @returns {Promise<string>} The transcribed text.\n   */\n  async transcribe(audioBuffer, filename = \"audio.webm\") {\n    const url = new URL(this.endpoint);\n    url.searchParams.set(\"model\", this.model);\n    url.searchParams.set(\"smart_format\", \"true\");\n\n    return await fetch(url.toString(), {\n      method: \"POST\",\n      headers: {\n        Authorization: `Token ${this.apiKey}`,\n        \"Content-Type\": this.#contentTypeFromFilename(filename),\n      },\n      body: audioBuffer,\n    })\n      .then(async (response) => {\n        if (!response.ok) {\n          const errBody = await response.text().catch(() => \"\");\n          throw new Error(\n            `Deepgram transcription failed (${response.status}) - ${errBody}`\n          );\n        }\n        return response.json();\n      })\n      .then((result) => {\n        return (\n          result?.results?.channels?.[0]?.alternatives?.[0]?.transcript ?? \"\"\n        );\n      })\n      .catch((error) => {\n        this.#log(`Deepgram transcription failed - ${error.message}`);\n        throw new Error(`Deepgram transcription failed - ${error.message}`);\n      });\n  }\n}\n\nmodule.exports = { DeepgramSTT };","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/utils/SpeechToText/deepgram/index.js#L43-L79","documentation":"Thrown when the Deepgram pre-recorded REST API returns a non-OK HTTP status. The response status code and best-effort body text are embedded in the message. This wraps Deepgram-side failures: authentication, bad request, quota, rate limit, or server errors. The error is re-thrown after logging.","triggerScenarios":"401/403 from an invalid or expired STT_DEEPGRAM_API_KEY; 400 from an invalid STT_DEEPGRAM_MODEL (e.g. a typo) or an audio container Deepgram cannot parse; 402 account out of credits; 429 rate limit; 5xx Deepgram outage.","commonSituations":"Wrong/revoked API key; mistyped model name (nova-3 vs nova-2); sending an audio format not in the Content-Type map (defaults to audio/webm); burst of requests hitting rate limits; Deepgram incident.","solutions":["Match the HTTP status: 401/403 → regenerate STT_DEEPGRAM_API_KEY; 400 → check STT_DEEPGRAM_MODEL and audio format; 402 → check billing; 429 → back off; 5xx → retry shortly.","Read errBody in the message — Deepgram returns a JSON reason string that pinpoints the problem.","Confirm STT_DEEPGRAM_MODEL is a valid model id for your Deepgram account tier.","Ensure the audio buffer is non-empty and a supported codec; convert to WAV via the helpers if unsure.","Check Deepgram status page for ongoing incidents."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Pre-flight the key/model cheaply is not possible; validate config shape instead.\nif (!process.env.STT_DEEPGRAM_API_KEY) {\n  throw new Error(\"STT_DEEPGRAM_API_KEY is required for Deepgram STT.\");\n}","typeGuard":null,"tryCatchPattern":"async function transcribeWithRetry(stt, buf, name, attempts = 2) {\n  for (let i = 0; i < attempts; i++) {\n    try {\n      return await stt.transcribe(buf, name);\n    } catch (e) {\n      const m = e.message || \"\";\n      const retriable = /\\(429\\)|\\(5\\d{2}\\)/.test(m);\n      if (!retriable || i === attempts - 1) throw e;\n      await new Promise((r) => setTimeout(r, 500 * Math.pow(2, i)));\n    }\n  }\n}","preventionTips":["Keep STT_DEEPGRAM_API_KEY current; monitor for 401s and alert.","Use a valid STT_DEEPGRAM_MODEL for your account tier (default nova-3).","Convert audio to a supported codec before sending.","Implement retry with backoff for 429/5xx only — never for 400/401/402."],"tags":["stt","deepgram","network","api","http"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}