---
title: "Deploy Kokoro TTS"
description: "OpenAI-compatible Kokoro TTS API and web player, protected by an API key"
category: "AI/ML"
url: https://railway.com/deploy/kokoro-tts-1
---

# Deploy Kokoro TTS

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

**[Deploy Kokoro TTS on Railway](https://railway.com/template/kokoro-tts-1)**

Machine-readable deploy manifest (JSON, validated by TemplateCI): https://railway.com/deploy/kokoro-tts-1/manifest.json

- **Creator:** Agaz Self-Host
- **Category:** AI/ML
- **Total deploys:** 1

## Template content

### Kokoro https://kokorottsai.com/logo.png

- **Image:** caddy:2.11.9-alpine@sha256:0bbb055bda6793c999bde78b1b5ce3e89f829fb031af2cf50056ea1246559fee
- **Start command:** `sh -c 'echo H4sIAAAAAAACA5VU0U7bQBB8jr9i5CIBVYxT+oICVCRARRWkoLRVi6rKOux1fErwWXeXJibk37vnGAgBqvQlyt3tzs7MrteQRUDeLwQ5/K1ev9cf9KPO1Zeod37t4zfu7zEHxZmC//wR0oBuC1s2oSmdGJkPYRWMFdr6h6CZtPhwiMUa9PfB5euw/LAxZCwsPiEkG4exSJIyPHW/qRwTjo62TztnZ9fn/c/b3txriORW5lBpyn8nVkWZtYVZngvSRhobxSpP5bC6W3hee7511R98ax+0DloLMMI79AvK2xgIOZ6KctsgIzG2GeKM4hFSpWEzwlBY4mdIa2icNtFTI6UVR6tp7kBWk5oQeQLBKhOpKbZItbpF6MQ6qCndoBiLkvSe18g4lHWFy/w7x6ihyRSKEXw18rHfanmNxXpgHfeHNVJUaDUrMV/pweJZSh3MZPAeIZcP8bG170Icc2444rGk3Jp2xW9EJYRh/l0Smli+GlHeBBvBtzMZiEIGLibEz4CTgx6VDmfnfMx88ktxY4LKgFPuKxkpAmNLplHX2N2rvVt6ZdhRiKGQOZtxwtAO2fFlnQkX70xsprS8E1YqnrOa0nxtlBd+Jfhktp6+Qtd/M+ll1Udhb2bV3q4y3rAdKyQ3zti8iutEV6up4aA2usLIGPxlZNiZ8BX8UeW930QhjJkqneC4arqbAi6x23SnaqKrj87N/1ToxGAqGcRF1i1wfMz6QIMRR+ZprB3hG8chqji4Y2PJ4In5j/NudNH5esH0neZ/CVwCLHsUTYr/GI5GZc7Ce1ge3lrxY39rp9o1yITJgkdzgoCFydzSzL7cn7u+R7NCaYs1NL6mGEs8PckZpV5Cr+60IBCJKCwzjx/uvL+T9jiSuAUAAA== | base64 -d | gunzip > /tmp/start.sh && exec sh /tmp/start.sh'`
- **Health check:** /healthz
- **Public domain:** Yes

### Kokoro-API https://kokorottsai.com/logo.png

- **Image:** ghcr.io/remsky/kokoro-fastapi-cpu:v0.10.0@sha256:f54c5960c2b9387f6349080a9944f8bc7e8cdb98a4ef9238cb0b0f9ff9795f44
- **Start command:** `sh -c 'echo c2V0IC1lClsgLW4gIiRLT0tPUk9fQVBJX0tFWSIgXSB8fCB7IGVjaG8gIktPS09ST19BUElfS0VZIGlzIGVtcHR5LCByZWZ1c2luZyB0byBzdGFydCI7IGV4aXQgMTsgfQpleHBvcnQgQVBJX0tFWVM9IltcIiRLT0tPUk9fQVBJX0tFWVwiXSIKZXhwb3J0IFBPUlQ9ODA4MApleHBvcnQgQVBJX0xPR19MRVZFTD0iJHtBUElfTE9HX0xFVkVMOi1JTkZPfSIKZXhwb3J0IERPV05MT0FEX01PREVMPSIke0RPV05MT0FEX01PREVMOi1mYWxzZX0iCiMgdG9yY2ggc3RhcnRzIG9uZSB0aHJlYWQgcGVyIGhvc3QgY29yZTsgb24gYSBDUFUtbGltaXRlZCBjb250YWluZXIgdGhhdAojIG92ZXJzdWJzY3JpYmVzIHRoZSBxdW90YSBhbmQgc2xvd3Mgc3BlZWNoIDUweC4gVXNlIHRoZSBDUFUgbGltaXQsIGF0IG1vc3QgOCB0aHJlYWRzLgppZiBbIC16ICIkT01QX05VTV9USFJFQURTIiBdOyB0aGVuCiAgbj0iIgogIGlmIFsgLXIgL3N5cy9mcy9jZ3JvdXAvY3B1Lm1heCBdOyB0aGVuCiAgICByZWFkIC1yIHEgcCA8IC9zeXMvZnMvY2dyb3VwL2NwdS5tYXggfHwgdHJ1ZQogICAgWyAiJHEiICE9ICJtYXgiIF0gJiYgWyAtbiAiJHAiIF0gJiYgbj0kKCggKHEgKyBwIC0gMSkgLyBwICkpCiAgZmkKICBbIC1uICIkbiIgXSB8fCBuPSQobnByb2MpCiAgWyAiJG4iIC1ndCA4IF0gJiYgbj04CiAgWyAiJG4iIC1sdCAxIF0gJiYgbj0xCiAgZXhwb3J0IE9NUF9OVU1fVEhSRUFEUz0iJG4iCmZpCmVjaG8gImNwdXM6IG5wcm9jPSQobnByb2MpIGNwdS5tYXg9JChjYXQgL3N5cy9mcy9jZ3JvdXAvY3B1Lm1heCAyPi9kZXYvbnVsbCB8fCBlY2hvIG4vYSkgT01QX05VTV9USFJFQURTPSRPTVBfTlVNX1RIUkVBRFMiCmV4ZWMgLi9lbnRyeXBvaW50LnNoCg== | base64 -d > /tmp/start.sh && exec sh /tmp/start.sh'`
- **Health check:** /health

## Documentation

# 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

* [Kokoro-FastAPI on GitHub](https://github.com/remsky/Kokoro-FastAPI) and its [configuration reference](https://github.com/remsky/Kokoro-FastAPI/blob/v0.10.0/docs/configuration.md)
* [Kokoro-FastAPI v0.10.0 release notes](https://github.com/remsky/Kokoro-FastAPI/releases/tag/v0.10.0)
* [Kokoro-82M model card](https://huggingface.co/hexgrad/Kokoro-82M)
* [Start scripts and gateway config for this template](https://github.com/aalfath/kokoro-railway-template)

### Implementation Details

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

```bash
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.



## Similar templates

- [Chat Chat](https://railway.com/deploy/-WWW5r) — Chat Chat, your own unified chat and search to AI platform.
- [Weaviate](https://railway.com/deploy/weaviate-1) — Vector database with hybrid search and an API key-protected API
- [Möbius Personal AI OS](https://railway.com/deploy/mobius-v01-personal-ai-os) — Self-hosted AI agent that builds and runs apps for you, with memory.

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