---
title: "Deploy Kokoro TTS API | (Just Updated) OpenAI-Compatible Voice, Hobby Plan Recommended"
description: "OpenAI-compatible TTS API. Needs 1.5GB RAM, Hobby plan or above."
category: "AI/ML"
url: https://railway.com/deploy/kokoro-tts-api
---

# Deploy Kokoro TTS API | (Just Updated) OpenAI-Compatible Voice, Hobby Plan Recommended

OpenAI-compatible TTS API. Needs 1.5GB RAM, Hobby plan or above.

**[Deploy Kokoro TTS API | (Just Updated) OpenAI-Compatible Voice, Hobby Plan Recommended on Railway](https://railway.com/template/kokoro-tts-api)**

- **Creator:** SuperSlowSloth
- **Category:** AI/ML
- **Total deploys:** 77

## Template content

### Kokoro API

- **Image:** ghcr.io/remsky/kokoro-fastapi-cpu:latest
- **Health check:** /health
- **Public domain:** Yes

## Documentation

# Deploy and Host Kokoro-FastAPI on Railway

Kokoro-FastAPI is a Dockerized FastAPI wrapper for the Kokoro-82M text-to-speech model. It provides OpenAI-compatible endpoints for multi-language speech synthesis with support for multiple audio formats, streaming, and voice combinations.

## Resource Requirements — Read Before Deploying

This template runs the PyTorch build of Kokoro and **needs at least 1.5 GB of RAM**. Measured on the
current image: ~1.05 GB resident once the model has loaded, ~1.15 GB after serving a request, and
about 20 seconds of cold start before the API answers.

That means it requires Railway's **Hobby plan or above**. On the Trial (1 GB) and Free (0.5 GB)
plans the container is OOM-killed during model load with exit status 137 and never serves traffic.
If you are on one of those plans, deploy
[**Kokoro TTS Lite**](https://railway.com/deploy/kokoro-tts-lite) instead — same OpenAI-compatible
`/v1/audio/speech`, ONNX runtime, ~375 MB resident, runs on the Free plan.

A healthcheck on `/health` is configured, so Railway waits for the model to finish loading before
routing traffic to a new deploy.

## About Hosting Kokoro-FastAPI

Deploying Kokoro-FastAPI on Railway gives you an OpenAI-compatible text-to-speech API. The service supports multiple output formats (MP3, WAV, Opus, FLAC, M4A, PCM), streaming audio with configurable chunk sizes, and multi-language synthesis including English, Japanese, and Chinese. Advanced features include weighted voice combinations, word-level timestamped captions, and natural boundary detection for automatic sentence-based splitting. A built-in web UI and API documentation are included.

## Common Use Cases

- Drop-in replacement for OpenAI's text-to-speech API
- Generating audio content in multiple languages
- Creating custom voices by combining existing voice profiles
- Producing captioned audio with word-level timestamps
- Streaming audio generation for real-time applications

## Dependencies for Kokoro-FastAPI Hosting

- Docker container runtime
- Kokoro-82M model (Apache 2.0 licensed)

### Deployment Dependencies

- [Kokoro-FastAPI GitHub Repository](https://github.com/remsky/Kokoro-FastAPI)
- [Docker Image on GHCR](https://github.com/remsky/Kokoro-FastAPI/pkgs/container/kokoro-fastapi-cpu)


### Implementation Details

OpenAI-compatible client usage:

```python
from openai import OpenAI

client = OpenAI(
    base_url="https://your-app.up.railway.app/v1",
    api_key="your-api-key"
)

response = client.audio.speech.create(
    model="kokoro",
    voice="af_bella",
    input="Hello world!"
)
response.stream_to_file("output.mp3")
```

Voice combinations with weighted ratios:

```python
response = client.audio.speech.create(
    model="kokoro",
    voice="af_bella(2)+af_sky(1)",  # 67% bella, 33% sky
    input="Hello world!"
)
```

**API Endpoints:**

| Endpoint | Purpose |
|----------|---------|
| `POST /v1/audio/speech` | OpenAI-compatible speech synthesis |
| `GET /v1/audio/voices` | List available voices |
| `POST /v1/audio/voices/combine` | Create weighted voice combinations |
| `POST /dev/captioned_speech` | Generate audio with timestamps |

**Web Interfaces:**
- API Documentation: `/docs`
- Web UI: `/web`

## Why Deploy Kokoro-FastAPI 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-FastAPI 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.


## 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-api
