---
title: "Deploy Kokoro TTS Lite | OpenAI-Compatible Voice API, Runs on the Free Plan"
description: "OpenAI-compatible TTS on ONNX. Fits 512MB, runs on the Free plan."
category: "AI/ML"
url: https://railway.com/deploy/kokoro-tts-lite
---

# 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 on Railway](https://railway.com/template/kokoro-tts-lite)**

- **Creator:** SuperSlowSloth
- **Category:** AI/ML

## Template content

### Kokoro TTS Lite

- **Source:** bon5co/kokoro-lite-railway
- **Health check:** /health
- **Public domain:** Yes

## Documentation

# 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

```python
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](https://railway.com/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](https://github.com/bon5co/kokoro-lite-railway)
- [kokoro-onnx](https://github.com/thewh1teagle/kokoro-onnx) — ONNX runtime bindings and weights
- [Kokoro-82M on Hugging Face](https://huggingface.co/hexgrad/Kokoro-82M)


## Similar templates

- [Chat Chat](https://railway.com/deploy/-WWW5r) — Chat Chat, your own unified chat and search to AI platform.
- [stella](https://railway.com/deploy/stella) — Self-host stella with web, API, Postgres, Redis, and object storage.
- [Hermes Agent | OpenClaw Alternative with Dashboard](https://railway.com/deploy/hermes-agent-or-openclaw-alternative-wit) — Self-Hosted Hermes AI Agent for Telegram, Discord & Slack

Open this page in a browser: https://railway.com/deploy/kokoro-tts-lite
