Deploy Kokoro TTS

OpenAI-compatible text-to-speech voice API, 54 voices. Fits 0.5 GB of RAM.

Deploy Kokoro TTS

Just deployed

Deploy and Host Kokoro TTS on Railway

Deploy on Railway

Kokoro is an open-weight text-to-speech model: 82 million parameters, natural voices, and small enough to run on a CPU. This template serves it behind an OpenAI-compatible speech API, so any app or SDK that talks to /v1/audio/speech works by changing its base URL. It runs on a 0.5 GB service with no GPU.

About Hosting Kokoro TTS

One service, no database, no volume. The image carries the Kokoro v1.0 model as ONNX in two precisions and picks one from the memory your service has: the 8-bit model under 2 GB, the full-precision model at 2 GB or more. Nothing is downloaded at boot, so a deploy is ready in seconds. Requests need the generated API_KEY. The server sizes its work to the service's memory limit and hands memory back after each request, so it idles at about 260 MB on Railway's meter.

Common Use Cases

  • Give an app a voice without paying per character: narration, reading articles aloud, voice replies
  • A drop-in speech backend for Open WebUI, LibreChat, n8n and other tools that accept an OpenAI-compatible TTS URL
  • Generate audio for videos, podcasts and e-learning from scripts
  • Voice for agents and bots running in the same Railway project, over the private network

Dependencies for Kokoro TTS Hosting

  • None. The model is inside the image.

Deployment Dependencies

Implementation Details

Try it: open your Railway domain, paste API_KEY from the service's Variables tab, pick a voice and press Speak.

Call it:

curl https://‹your-domain›/v1/audio/speech \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "kokoro", "voice": "af_heart", "input": "Hello from Kokoro."}' \
  --output hello.mp3

With an OpenAI SDK, set the base URL to https://‹your-domain›/v1 and the API key to yours. From another service in the same project, use http://kokoro-tts.railway.internal:8080/v1.

Request fields:

  • input: the text, up to MAX_INPUT_CHARS characters
  • voice: a Kokoro voice (GET /v1/audio/voices lists all 54), an OpenAI voice name (alloy, nova, onyx, echo and fable map to their Kokoro namesakes, the rest to DEFAULT_VOICE), or a blend such as af_bella+am_michael
  • response_format: mp3 (default), wav, flac, opus or pcm
  • speed: 0.5 to 2.0
  • lang: optional espeak-ng language code, when you want a voice to read another language
  • model: accepted and ignored, so tts-1 and kokoro both work

Voices: the first letter is the language, the second the gender: af_ and am_ American English, bf_ and bm_ British English, e Spanish, f French, h Hindi, i Italian, p Brazilian Portuguese.

Notes and limits:

  • Speed: on a 0.5 GB service with one vCPU, a minute of audio took about 20 seconds to generate. More vCPUs make it faster, up to 4 threads.
  • Requests are answered one at a time; others wait in line. The whole audio is returned when it is done, not streamed.
  • On a service under 1 GB, long sentences are generated in shorter pieces, split at punctuation first. Give the service 1 GB or more for longer pieces, and 2 GB for the full-precision model.
  • Japanese and Chinese voices are in the model, but this server pronounces their text with espeak-ng, which reads them poorly. Use the other languages.
  • aac output is not supported.
  • If you clear API_KEY, the server makes a temporary key on each start and prints it in the deploy log. It is never open.

Why Deploy Kokoro TTS on Railway?

Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.

By deploying Kokoro TTS on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.


Template Content

More templates in this category

View Template
Chat Chat
Chat Chat, your own unified chat and search to AI platform.

okisdev
117
View Template
Weaviate
Vector database with hybrid search and an API key-protected API

GitHub Locker
1
View Template
Möbius Personal AI OS
Self-hosted AI agent that builds and runs apps for you, with memory.

Tracklayer
1