Mintplex-Labs/anything-llm · error · Error
No Kokoro endpoint was set. Please set TTS_KOKORO_ENDPOINT…
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 TTS_KOKORO_ENDPOINT is unset. This provider talks to a kokoro-fastapi server through the OpenAI SDK, so the base URL is mandatory; an API key (TTS_KOKORO_KEY) is optional. The constructor normalizes the URL: if the pathname does not end with /v1 it is forced to /v1, so the value should be the base such as http://localhost:8880/v1.
Solutions
- Set TTS_KOKORO_ENDPOINT=http://<host>:8880/v1 (the constructor appends /v1 if missing, but including it is clearer) and restart.
- From Docker, replace localhost with the host IP, host.docker.internal, or the kokoro container's service name.
- Verify the server responds: curl http://<host>:8880/v1/models.
- Optionally set TTS_KOKORO_KEY if your kokoro-fastapi instance requires auth.
Example fix
# before (.env) TTS_PROVIDER=kokoro # -> Error: No Kokoro endpoint was set... # after (.env) TTS_PROVIDER=kokoro TTS_KOKORO_ENDPOINT=http://localhost:8880/v1
Defensive patterns
Strategy: validation
Validate before calling
const canUseKokoroTTS = () => Boolean(process.env.TTS_KOKORO_ENDPOINT);
if (process.env.TTS_PROVIDER === "kokoro" && !canUseKokoroTTS()) {
throw new Error("kokoro TTS requires TTS_KOKORO_ENDPOINT");
}
// bonus: fail early on an unparseable URL
if (process.env.TTS_PROVIDER === "kokoro")
new URL(process.env.TTS_KOKORO_ENDPOINT); Try / catch
try {
tts = getTTSProvider();
} catch (e) {
if (/No Kokoro endpoint was set/.test(e.message))
return respondConfigError("TTS_KOKORO_ENDPOINT missing");
throw e;
} Prevention
- In Docker, always configure the kokoro host as a resolvable name (service name / host.docker.internal), never localhost.
- Health-check the endpoint (/v1/models) in your orchestration so a dead kokoro server is caught before TTS requests.
- Include /v1 in the value; the constructor only appends it when the pathname lacks it.
When it happens
Trigger: Setting TTS_PROVIDER=kokoro and starting TTS without TTS_KOKORO_ENDPOINT; or setting a variable with a different name (KOKORO_ENDPOINT, TTS_KOKORO_URL) that the constructor does not read.
Common situations: Running kokoro-fastapi locally or in a sibling container but forgetting to wire the endpoint into the server env; port confusion between the kokoro-fastapi web UI port (8880) and its API port; endpoint set only on the host while the app runs in Docker (localhost then points at the container itself).
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
- No OpenAI compatible endpoint was set. Please set this to…
- ENV: No TTS_PROVIDER value found in environment!
- No ElevenLabs API key was set.
- No OpenAI API key was set.
- No OpenAI compatible endpoint was set. Please set this to…
AI-assisted analysis of Mintplex-Labs/anything-llm@3aec848f28 (2026-08-18).
Data as JSON: /api/errors/41935d9baffd8c59.
Report an issue: GitHub.
Appendix: 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 3aec848f28)