Mintplex-Labs/anything-llm · error · Error

No Deepgram API key was set.

Error message

No Deepgram API key was set.

What it means

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.

Solutions

  1. Add STT_DEEPGRAM_API_KEY=<key> to .env and restart the server
  2. Optionally set STT_DEEPGRAM_MODEL (defaults to nova-3) to a valid model name
  3. For Docker, pass the variable into the container environment and recreate it
  4. Verify the exact variable name spelling and that the value is non-empty

Example fix

# before (.env)
STT_PROVIDER=deepgram

# after (.env)
STT_PROVIDER=deepgram
STT_DEEPGRAM_API_KEY=your-deepgram-key
Defensive patterns

Strategy: validation

Validate before calling

if (process.env.STT_PROVIDER === 'deepgram' && !process.env.STT_DEEPGRAM_API_KEY) {
  throw new Error('STT_PROVIDER=deepgram requires STT_DEEPGRAM_API_KEY to be set');
}

Try / catch

try {
  stt = new DeepgramSTT();
} catch (err) {
  if (err.message === 'No Deepgram API key was set.') {
    // fall back to default STT or prompt for the key
  }
  throw err;
}

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Understand the failure class

Background: "environment variable is not set" and "Missing keys in environment" errors: what missing required env var messages mean and how to fix them — this error's family across 28 libraries.

Related errors


AI-assisted analysis of Mintplex-Labs/anything-llm@3aec848f28 (2026-08-18). Data as JSON: /api/errors/1070b972ced158de. Report an issue: GitHub.

Appendix: source

Thrown at server/utils/SpeechToText/deepgram/index.js:4

class DeepgramSTT {
  constructor() {
    if (!process.env.STT_DEEPGRAM_API_KEY)
      throw new Error("No Deepgram API key was set.");

    this.apiKey = process.env.STT_DEEPGRAM_API_KEY;
    this.model = process.env.STT_DEEPGRAM_MODEL ?? "nova-3";
    this.endpoint = "https://api.deepgram.com/v1/listen";
    this.#log(`Service ready with model: ${this.model}`);
  }

  #log(text, ...args) {
    console.log(`\x1b[32m[DeepgramSTT]\x1b[0m ${text}`, ...args);
  }

  // Map common audio file extensions to a Content-Type that Deepgram accepts.
  // Deepgram auto-detects most containers from the bytes but a hint is best.
  #contentTypeFromFilename(filename) {
    const ext = filename.split(".").pop()?.toLowerCase();
    switch (ext) {
      case "wav":
        return "audio/wav";

View on GitHub (pinned to 3aec848f28)