Railway

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.

Deploy Kokoro TTS Lite | OpenAI-Compatible Voice API, Runs on the Free Plan

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_PRECISIONResident memory11 seconds of audioRuns on
int8 (default)~375 MB~9 sFree, Trial, Hobby
fp32~610 MB~3 sTrial, 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:

EndpointPurpose
POST /v1/audio/speechOpenAI-compatible speech synthesis
GET /v1/audio/voicesList the available voices
GET /v1/modelsModel listing, for clients that probe it
GET /healthHealthcheck

Variables:

VariableDefaultMeaning
MODEL_PRECISIONint8int8 for the Free plan, fp32 for ~4x the speed
DEFAULT_VOICEaf_heartVoice used when a request does not name one
API_KEYunsetWhen set, /v1/* requires Authorization: Bearer
OMP_NUM_THREADS2ONNX thread cap; raise it to match your plan's vCPU count
PORT8880Listen 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


Template Content

More templates in this category

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

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

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

codestorm
56