Deploy Kokoro TTS API (CPU)

OpenAI-compatible Kokoro text-to-speech API on CPU, model baked in

Deploy Kokoro TTS API (CPU)

Just deployed

Deploy and Host Kokoro TTS on Railway

Kokoro TTS is an OpenAI-compatible text-to-speech API built on the open Kokoro-82M model, served by the Kokoro-FastAPI project. It speaks English, Spanish, French, Hindi, Italian, Japanese, Portuguese and Mandarin, supports voice mixing, inline multi-speaker tags and SSML, streams mp3, wav, opus, flac, aac or pcm, and ships a web player for trying voices in the browser.

About Hosting Kokoro TTS

Hosting Kokoro TTS is a single stateless container. This template uses the official CPU image ghcr.io/remsky/kokoro-fastapi-cpu:v0.9.0 with the model weights and voice packs baked in, so there is no volume, no database, and no external API key. PORT is pinned to 8880 (the image entrypoint passes it to uvicorn) so Railway's healthcheck hits /health on the right port, HOST is :: so other Railway services can reach it over IPv6 private networking, and the healthcheck window is 600 seconds because the model loads and warms up before the port opens. Inference runs on CPU and needs roughly 2 to 4 GB of RAM, so use the Hobby plan or higher.

Common Use Cases

  • Drop-in OpenAI TTS replacement: point any OpenAI SDK at /v1 with model kokoro
  • Voice for chat UIs and agents: Open WebUI, LibreChat, SillyTavern, voice assistants
  • Narration and audiobooks: long-form text with automatic chunking, captions and read-along timings
  • Multi-speaker dialogue: inline [voice:...] tags or POST /dev/dialogue
  • Private TTS for other Railway services: http://kokoro-tts.railway.internal:8880/v1

Dependencies for Kokoro TTS Hosting

  • None: no database, no volume, no GPU, no external API keys
  • Memory: about 2 to 4 GB RAM (Hobby plan or higher)

Deployment Dependencies

Implementation Details

The image CMD runs the upstream entrypoint, which starts uvicorn --host "$HOST" --port "$PORT", so no custom start command is needed. Key variables:

PORT=8880
HOST=0.0.0.0
USE_GPU=false
API_LOG_LEVEL=INFO
DEFAULT_VOICE=af_heart
WEB_CONCURRENCY=1

First steps after deploy

  1. Wait for /health to return {"status":"healthy"}. First boot takes a few minutes while the model loads.
  2. Open /web/ on your Railway domain and generate a sample.
  3. Call POST /v1/audio/speech with {"model":"kokoro","input":"...","voice":"af_heart","response_format":"mp3"} from your app.
  4. Decide on access: the upstream server has no authentication, so anyone with the URL can generate audio. Put it behind a gateway such as LiteLLM or Bifrost, use Cloudflare Access, or remove the public domain and call it privately.

Keep one worker: inference is synchronous and each extra worker loads its own copy of the model. Avoid the latest tag when upgrading; pick a release tag.

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 get a pinned, health-checked, OpenAI-compatible speech endpoint with managed SSL and private networking to the rest of your Railway project, with no GPU bill and no per-character API pricing.


Template Content

More templates in this category

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

okisdev
116
View Template
stella
Self-host stella with web, API, Postgres, Redis, and object storage.

Jan Kubica
5
View Template
Hermes Agent | OpenClaw Alternative with Dashboard
Self-Hosted Hermes AI Agent for Telegram, Discord & Slack

codestorm
71