{"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":"validation","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/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/utils/TextToSpeech/kokoro/index.js#L1-L22","documentation":"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(...)`.","triggerScenarios":"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.","commonSituations":"Self-hosting kokoro-fastapi but forgetting to point AnythingLLM at it; switching to kokoro without completing its env block; Docker env not propagated.","solutions":["Add TTS_KOKORO_ENDPOINT=http://<host>:8880/v1 to .env and restart (pathname is auto-corrected to /v1 if missing).","Optionally set TTS_KOKORO_KEY if your kokoro-fastapi server requires auth.","Verify the endpoint is reachable from the server container (curl http://<host>:8880/v1).","Ensure the value is a parseable absolute URL (scheme + host)."],"exampleFix":"# before\nTTS_PROVIDER=kokoro\n# TTS_KOKORO_ENDPOINT missing\n\n# after\nTTS_PROVIDER=kokoro\nTTS_KOKORO_ENDPOINT=http://localhost:8880/v1","handlingStrategy":"validation","validationCode":"if (process.env.TTS_PROVIDER === \"kokoro\" && !process.env.TTS_KOKORO_ENDPOINT) {\n  throw new Error(\"TTS_PROVIDER is 'kokoro' but TTS_KOKORO_ENDPOINT is not set.\");\n}\n// also guard against an unparseable URL\nif (process.env.TTS_KOKORO_ENDPOINT) {\n  try { new URL(process.env.TTS_KOKORO_ENDPOINT); }\n  catch { throw new Error(\"TTS_KOKORO_ENDPOINT is not a valid URL.\"); }\n}","typeGuard":"function isValidHttpUrl(v) {\n  try { new URL(v); return /^https?:/.test(new URL(v).protocol); }\n  catch { return false; }\n}","tryCatchPattern":"try {\n  return new KokoroTTS();\n} catch (e) {\n  if (/No Kokoro endpoint/i.test(e.message)) {\n    logger.error(\"Set TTS_KOKORO_ENDPOINT (kokoro-fastapi base URL) in .env, then restart.\");\n  }\n  throw e;\n}","preventionTips":["Provide a parseable absolute URL with scheme + host (pathname auto-corrected to /v1).","Verify the kokoro-fastapi server is reachable from the server container.","Restart after editing .env."],"tags":["tts","kokoro","configuration","environment"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}