Deploy Kokoro TTS Lite | OpenAI-Compatible Voice API, Runs on the Free Plan
OpenAI-compatible TTS on ONNX. Fits 512MB, runs on the Free plan.
Kokoro TTS Lite
Just deployed
Deploy and Host Kokoro TTS Lite on Railway
Kokoro TTS Lite is an OpenAI-compatible text-to-speech API for the Kokoro-82M model, running on ONNX
Runtime instead of PyTorch. It answers POST /v1/audio/speech exactly like OpenAI's endpoint, so the
official OpenAI SDKs work against it with nothing changed but the base URL — and it fits inside
Railway's smallest memory limits, including the 0.5 GB Free plan.
About Hosting Kokoro TTS Lite
The usual Kokoro server images run PyTorch and hold about 1.1 GB resident, which is more memory than the Free (0.5 GB) and Trial (1 GB) plans allow — the container is killed during model load and never serves a request. This template runs the ONNX build and ships both quantised and full-precision weights, so one variable picks the tradeoff that matches your plan:
MODEL_PRECISION | Resident memory | 11 seconds of audio | Runs on |
|---|---|---|---|
int8 (default) | ~375 MB | ~9 s | Free, Trial, Hobby |
fp32 | ~610 MB | ~3 s | Trial, Hobby |
Both numbers are measured, not estimated. The model weights are baked into the image rather than
downloaded at boot, so a cold start is a few seconds and does not depend on your network. A
healthcheck on /health means Railway only routes traffic once the model is actually loaded.
Why Deploy Kokoro TTS Lite 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 Lite 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.
Common Use Cases
- Drop-in replacement for OpenAI's text-to-speech API, at no per-character cost
- Voice for AI agents and chatbots that already speak the OpenAI protocol
- Narration for video, podcast, and course pipelines
- Accessibility read-aloud for web and mobile apps
- Notification and IVR audio generated on demand
Implementation Details
from openai import OpenAI
client = OpenAI(base_url="https://your-app.up.railway.app/v1", api_key="unused")
client.audio.speech.create(
model="kokoro",
voice="af_bella",
input="Hello world!",
).stream_to_file("output.mp3")
API Endpoints:
| Endpoint | Purpose |
|---|---|
POST /v1/audio/speech | OpenAI-compatible speech synthesis |
GET /v1/audio/voices | List the available voices |
GET /v1/models | Model listing, for clients that probe it |
GET /health | Healthcheck |
Variables:
| Variable | Default | Meaning |
|---|---|---|
MODEL_PRECISION | int8 | int8 for the Free plan, fp32 for ~4x the speed |
DEFAULT_VOICE | af_heart | Voice used when a request does not name one |
API_KEY | unset | When set, /v1/* requires Authorization: Bearer |
OMP_NUM_THREADS | 2 | ONNX thread cap; raise it to match your plan's vCPU count |
PORT | 8880 | Listen port |
Audio formats: mp3, wav, pcm, opus, aac, flac. 50-odd voices across English, French,
Italian, Japanese, and Chinese, and voices can be blended by name.
Need the full PyTorch feature set — streaming with configurable chunking, word-level caption timestamps, weighted voice combination endpoints, the bundled web player? Deploy Kokoro TTS API instead. It needs 1.5 GB of RAM and so requires the Hobby plan or above.
Dependencies for Kokoro TTS Lite Hosting
- Docker container runtime
- Kokoro-82M model weights, Apache 2.0 licensed
Deployment Dependencies
- Source repository for this template
- kokoro-onnx — ONNX runtime bindings and weights
- Kokoro-82M on Hugging Face
Template Content
Kokoro TTS Lite
bon5co/kokoro-lite-railway