{"record":{"id":"41935d9baffd8c59","repo":"Mintplex-Labs/anything-llm","slug":"no-kokoro-endpoint-was-set-please-set-tts-kokoro","errorCode":null,"errorMessage":"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).","messagePattern":"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\\)\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/utils/TextToSpeech/kokoro/index.js","lineNumber":4,"sourceCode":"class KokoroTTS {\n  constructor() {\n    if (!process.env.TTS_KOKORO_ENDPOINT)\n      throw new Error(\n        \"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).\"\n      );\n\n    const endpoint = new URL(process.env.TTS_KOKORO_ENDPOINT);\n    if (!endpoint.pathname.endsWith(\"/v1\")) endpoint.pathname = \"/v1\";\n    const { OpenAI: OpenAIApi } = require(\"openai\");\n    this.openai = new OpenAIApi({\n      apiKey: process.env.TTS_KOKORO_KEY || null,\n      baseURL: endpoint.toString(),\n    });\n\n    this.model = \"kokoro\";\n    this.voice = process.env.TTS_KOKORO_VOICE_MODEL ?? \"af_bella\";\n    this.#log(\n      `Service (${process.env.TTS_KOKORO_ENDPOINT}) with voice: ${this.voice}`\n    );\n  }\n","sourceCodeStart":1,"sourceCodeEnd":22,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/3aec848f2885144aa8f1e53b9731a04310d5d558/server/utils/TextToSpeech/kokoro/index.js#L1-L22","documentation":"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.","triggerScenarios":"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.","commonSituations":"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).","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."],"exampleFix":"# before (.env)\nTTS_PROVIDER=kokoro\n# -> Error: No Kokoro endpoint was set...\n\n# after (.env)\nTTS_PROVIDER=kokoro\nTTS_KOKORO_ENDPOINT=http://localhost:8880/v1","handlingStrategy":"validation","validationCode":"const canUseKokoroTTS = () => Boolean(process.env.TTS_KOKORO_ENDPOINT);\n\nif (process.env.TTS_PROVIDER === \"kokoro\" && !canUseKokoroTTS()) {\n  throw new Error(\"kokoro TTS requires TTS_KOKORO_ENDPOINT\");\n}\n\n// bonus: fail early on an unparseable URL\nif (process.env.TTS_PROVIDER === \"kokoro\")\n  new URL(process.env.TTS_KOKORO_ENDPOINT);","typeGuard":null,"tryCatchPattern":"try {\n  tts = getTTSProvider();\n} catch (e) {\n  if (/No Kokoro endpoint was set/.test(e.message))\n    return respondConfigError(\"TTS_KOKORO_ENDPOINT missing\");\n  throw e;\n}","preventionTips":["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."],"tags":["env","configuration","tts","kokoro","self-hosted"],"backgroundTag":"missing-env-var","analyzedSha":"3aec848f2885144aa8f1e53b9731a04310d5d558","analyzedAt":"2026-08-18T10:02:21.017Z","contentChangedAt":"2026-08-18T10:02:21.017Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}