Deploy Kokoro TTS

OpenAI-compatible Kokoro TTS API and web player, protected by an API key

Deploy Kokoro TTS

Just deployed

Just deployed

Deploy and Host Kokoro TTS on Railway

Kokoro TTS is a self-hosted text-to-speech server built on Kokoro-82M, an open-weight speech model released under Apache 2.0. Kokoro-FastAPI wraps the model in an OpenAI-compatible /v1/audio/speech API, adds ElevenLabs- and Cartesia-style websockets, and ships a web player. It includes 72 voices across English, Spanish, French, Italian, Portuguese, Hindi, Japanese and Chinese.

About Hosting Kokoro TTS

This template runs the official CPU image of Kokoro-FastAPI v0.10.0, which has the model weights built in, so nothing is downloaded at startup. Kokoro-API stays on Railway's private network and checks an API key itself. A small Caddy gateway is the only public service. API clients send the key as a Bearer token. Browsers get a password prompt, and after it the built-in web player works. The key is generated at deploy. Kokoro stores no data, so no volume is needed. Plan for about 1.2 GB of RAM at idle and up to 3–4 GB on long inputs, so use the Hobby plan or above. Speech threads follow the service's CPU limit, up to 8.

Common Use Cases

  • Voice for AI agents, chatbots and phone bots through an OpenAI-, ElevenLabs- or Cartesia-compatible API
  • Narration for articles, e-books, podcasts and videos without per-character fees
  • A private text-to-speech backend for Open WebUI, n8n or your own app

Dependencies for Kokoro TTS Hosting

  • Kokoro-FastAPI CPU image (ghcr.io/remsky/kokoro-fastapi-cpu:v0.10.0, pinned by digest) with the Kokoro-82M model built in
  • Caddy 2.11 as the public gateway that checks the API key

Deployment Dependencies

Implementation Details

After the deploy, copy KOKORO_API_KEY from the Kokoro service's variables and call the public domain:

curl -X POST https://YOUR-DOMAIN.up.railway.app/v1/audio/speech \
  -H "Authorization: Bearer $KOKORO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"kokoro","input":"Hello from Railway!","voice":"af_heart","response_format":"mp3"}' \
  --output hello.mp3

With an OpenAI SDK, set base_url to https://YOUR-DOMAIN.up.railway.app/v1 and api_key to the same key. List the voices at /v1/audio/voices. ElevenLabs- and Cartesia-style clients can send the key as xi-api-key or X-API-Key instead.

To use the web player, open the domain in a browser. When asked, sign in with the user name kokoro and your KOKORO_API_KEY as the password. Requests without the key get 401. Only /health, /healthz and the redirect from / to the web player answer without it.

To change the number of speech threads, set OMP_NUM_THREADS on the Kokoro-API service.

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.

bento
1