Mintplex-Labs/anything-llm · error · Error

No ElevenLabs API key was set.

Error message

No ElevenLabs API key was set.

What it means

Thrown by the ElevenLabsTTS constructor when process.env.TTS_ELEVEN_LABS_KEY is falsy. The class builds an ElevenLabsClient used for text-to-speech synthesis. Without the key the client cannot authenticate, so construction is aborted.

Source

Thrown at server/utils/TextToSpeech/elevenLabs/index.js:6

const { ElevenLabsClient } = require("elevenlabs");

class ElevenLabsTTS {
  constructor() {
    if (!process.env.TTS_ELEVEN_LABS_KEY)
      throw new Error("No ElevenLabs API key was set.");
    this.elevenLabs = new ElevenLabsClient({
      apiKey: process.env.TTS_ELEVEN_LABS_KEY,
    });

    // Rachel as default voice
    // https://api.elevenlabs.io/v1/voices
    this.voiceId =
      process.env.TTS_ELEVEN_LABS_VOICE_MODEL ?? "21m00Tcm4TlvDq8ikWAM";
    this.modelId = "eleven_multilingual_v2";
  }

  static async voices(apiKey = null) {
    try {
      const client = new ElevenLabsClient({
        apiKey: apiKey ?? process.env.TTS_ELEVEN_LABS_KEY ?? null,
      });
      return (await client.voices.getAll())?.voices ?? [];
    } catch {}

View on GitHub (pinned to 526360e320)

Solutions

  1. Add TTS_ELEVEN_LABS_KEY=<your-key> to .env and restart.
  2. Optionally set TTS_ELEVEN_LABS_VOICE_MODEL (defaults to Rachel voice id 21m00Tcm4TlvDq8ikWAM).
  3. Confirm the exact name TTS_ELEVEN_LABS_KEY.
  4. In Docker, pass the variable to the container.

Example fix

# before
TTS_PROVIDER=elevenlabs
# TTS_ELEVEN_LABS_KEY missing

# after
TTS_PROVIDER=elevenlabs
TTS_ELEVEN_LABS_KEY=el_xxxxxxxx
Defensive patterns

Strategy: validation

Validate before calling

if (process.env.TTS_PROVIDER === "elevenlabs" && !process.env.TTS_ELEVEN_LABS_KEY) {
  throw new Error("TTS_PROVIDER is 'elevenlabs' but TTS_ELEVEN_LABS_KEY is not set.");
}

Try / catch

try {
  return new ElevenLabsTTS();
} catch (e) {
  if (/No ElevenLabs API key/i.test(e.message)) {
    logger.error("Set TTS_ELEVEN_LABS_KEY in .env, then restart.");
  }
  throw e;
}

Prevention

When it happens

Trigger: TTS_PROVIDER=elevenlabs is set but TTS_ELEVEN_LABS_KEY is missing/empty; the key was added but the process not restarted; the var was set under a different name.

Common situations: New deployment forgetting the ElevenLabs key; rotated key not updated; Docker env not propagated.

Related errors


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