Mintplex-Labs/anything-llm · error · Error

No Kokoro endpoint was set. Please set TTS_KOKORO_ENDPOINT t

Error message

No Kokoro endpoint was set. Please set TTS_KOKORO_ENDPOINT to the base URL of your kokoro-fastapi server (e.g. http://localhost:8880/v1).

What it means

Thrown by the KokoroTTS constructor when process.env.TTS_KOKORO_ENDPOINT is falsy. Kokoro TTS targets a self-hosted kokoro-fastapi server via an OpenAI-compatible client, so the base URL is mandatory. The endpoint is normalized so its pathname ends with /v1. An invalid URL string (not a parseable URL) would throw a different error from `new URL(...)`.

Source

Thrown at server/utils/TextToSpeech/kokoro/index.js:4

class KokoroTTS {
  constructor() {
    if (!process.env.TTS_KOKORO_ENDPOINT)
      throw new Error(
        "No Kokoro endpoint was set. Please set TTS_KOKORO_ENDPOINT to the base URL of your kokoro-fastapi server (e.g. http://localhost:8880/v1)."
      );

    const endpoint = new URL(process.env.TTS_KOKORO_ENDPOINT);
    if (!endpoint.pathname.endsWith("/v1")) endpoint.pathname = "/v1";
    const { OpenAI: OpenAIApi } = require("openai");
    this.openai = new OpenAIApi({
      apiKey: process.env.TTS_KOKORO_KEY || null,
      baseURL: endpoint.toString(),
    });

    this.model = "kokoro";
    this.voice = process.env.TTS_KOKORO_VOICE_MODEL ?? "af_bella";
    this.#log(
      `Service (${process.env.TTS_KOKORO_ENDPOINT}) with voice: ${this.voice}`
    );
  }

View on GitHub (pinned to 526360e320)

Solutions

  1. Add TTS_KOKORO_ENDPOINT=http://<host>:8880/v1 to .env and restart (pathname is auto-corrected to /v1 if missing).
  2. Optionally set TTS_KOKORO_KEY if your kokoro-fastapi server requires auth.
  3. Verify the endpoint is reachable from the server container (curl http://<host>:8880/v1).
  4. Ensure the value is a parseable absolute URL (scheme + host).

Example fix

# before
TTS_PROVIDER=kokoro
# TTS_KOKORO_ENDPOINT missing

# after
TTS_PROVIDER=kokoro
TTS_KOKORO_ENDPOINT=http://localhost:8880/v1
Defensive patterns

Strategy: validation

Validate before calling

if (process.env.TTS_PROVIDER === "kokoro" && !process.env.TTS_KOKORO_ENDPOINT) {
  throw new Error("TTS_PROVIDER is 'kokoro' but TTS_KOKORO_ENDPOINT is not set.");
}
// also guard against an unparseable URL
if (process.env.TTS_KOKORO_ENDPOINT) {
  try { new URL(process.env.TTS_KOKORO_ENDPOINT); }
  catch { throw new Error("TTS_KOKORO_ENDPOINT is not a valid URL."); }
}

Type guard

function isValidHttpUrl(v) {
  try { new URL(v); return /^https?:/.test(new URL(v).protocol); }
  catch { return false; }
}

Try / catch

try {
  return new KokoroTTS();
} catch (e) {
  if (/No Kokoro endpoint/i.test(e.message)) {
    logger.error("Set TTS_KOKORO_ENDPOINT (kokoro-fastapi base URL) in .env, then restart.");
  }
  throw e;
}

Prevention

When it happens

Trigger: TTS_PROVIDER=kokoro is set but TTS_KOKORO_ENDPOINT is missing/empty; the var was renamed; the var is set but the process was not restarted.

Common situations: Self-hosting kokoro-fastapi but forgetting to point AnythingLLM at it; switching to kokoro without completing its env block; Docker env not propagated.

Related errors


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