---
title: "Deploy Kitten TTS 2 | (Just Updated) OpenAI-Compatible Text-to-Speech API on CPU, API Key Generated"
description: "Kitten-TTS 2 speech API, OpenAI-compatible, CPU, generated API key"
category: "AI/ML"
url: https://railway.com/deploy/kitten-tts-2-or-just-updated-openai-comp
---

# Deploy Kitten TTS 2 | (Just Updated) OpenAI-Compatible Text-to-Speech API on CPU, API Key Generated

Kitten-TTS 2 speech API, OpenAI-compatible, CPU, generated API key

**[Deploy Kitten TTS 2 | (Just Updated) OpenAI-Compatible Text-to-Speech API on CPU, API Key Generated on Railway](https://railway.com/template/kitten-tts-2-or-just-updated-openai-comp)**

Machine-readable deploy manifest (JSON, validated by TemplateCI): https://railway.com/deploy/kitten-tts-2-or-just-updated-openai-comp/manifest.json

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

## Template content

### kittentts

- **Image:** ghcr.io/bon5co/kittentts-2-railway@sha256:75315332d2102e93b360a207737b8bf5cf5d5560c75daf6b2ddffd309c03d837
- **Health check:** /health
- **Public domain:** Yes

## Documentation

# Deploy and Host Kitten TTS 2 on Railway

**Kitten-TTS 2** text-to-speech as an OpenAI-compatible API, running on CPU with no GPU. Deploy, copy the
generated `API_KEY`, and call `POST /v1/audio/speech`. The model weights download on first boot onto a Railway
volume, so redeploys do not download them again.

**Powered by KittenML.**

## About Hosting Kitten TTS 2

The service is [KittenTTS](https://github.com/KittenML/KittenTTS) Kitten-TTS 2 (1.7B parameters, 100+ built-in
voices, 24 kHz) served by a small FastAPI wrapper over the CPU runtime `kitten_tts_cpp`. The API key is generated
for you and enforced on every `/v1/*` route. `/health` answers immediately and reports `loading` while the first-boot
download and model load finish (a few minutes), then `ready`.

**Speed, measured on an 8 vCPU Railway container:** generation runs about 10 to 14 times slower than real time
(2.7 s of audio took 38 s, 8.9 s took 90 s). Memory use is about 2.5 GB. Input is capped at 300 characters per
request so a request always finishes inside Railway's edge timeout of about 5 minutes; split longer text into
several requests. This template is for batch and offline speech, not live conversation. Plan on Hobby or above.

**Licence:** the weights are under the
[Stellon Labs Community License](https://huggingface.co/KittenML/kitten-tts-2/blob/main/LICENSE.md). Commercial use
requires registering with Stellon Labs and is capped at US$1,000,000 annual revenue and funding. The weights are
downloaded from Hugging Face at first boot, never bundled in the image. You are the licensee when you deploy this.

### Agent contract

- Public URL: `https://` (also `KITTENTTS_URL`)
- Private URL: `http://kittentts.railway.internal:8080` (also `KITTENTTS_PRIVATE_URL`)
- Credentials: `API_KEY`
- Auth: header `Authorization: Bearer $API_KEY` on every `/v1/*` route
- Health: `GET /health` returns 200 with `{"status":"ready"}` once the model is loaded (`loading` before that,
  `error` with a message if the download failed)

```bash
U="$KITTENTTS_URL"; H="Authorization: Bearer $API_KEY"
until curl -fs "$U/health" | grep -q '"ready"'; do sleep 10; done          # first boot downloads ~1 GB
curl -s -H "$H" "$U/v1/audio/voices"                                         # list voices
curl -s -H "$H" -H "Content-Type: application/json" \
  -d '{"input":"Hello from Kitten TTS.","voice":"Bruno","response_format":"wav"}' \
  "$U/v1/audio/speech" -o out.wav &amp;&amp; head -c 4 out.wav                       # RIFF
```

`response_format` is `mp3` (default), `wav`, `opus`, `aac`, `flac` or `pcm`. `"stream": true` with `wav` or `pcm`
returns audio chunk by chunk. The OpenAI SDK works with `base_url="$KITTENTTS_URL/v1"` and `api_key=$API_KEY`.

## Why Deploy Kitten TTS 2 on Railway

Railway gives the API a public HTTPS URL, a persistent volume for the 1 GB of weights and one-click redeploys, with
nothing to configure: the API key is generated, the port and healthcheck are set, and the model downloads itself.
You get a private speech endpoint your own agents and apps call with the standard OpenAI speech request.

## Common Use Cases

- Batch narration, voice-overs and audiobook clips from text, generated offline.
- Giving an AI agent a private text-to-speech endpoint it can call with an API key.
- Replacing a paid speech API with a self-hosted, OpenAI-compatible one for non-real-time jobs.

## Dependencies for Kitten TTS 2

- Kitten-TTS 2 weights `KittenML/kitten-tts-2` (pinned revision), runtime `kitten_tts_cpp` 0.2.0.

### Deployment Dependencies

- Outbound internet on first boot to download about 1 GB from Hugging Face. No database or other service.


## Similar templates

- [Chat Chat](https://railway.com/deploy/-WWW5r) — Chat Chat, your own unified chat and search to AI platform.
- [Möbius v0.1 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.
- [stella](https://railway.com/deploy/stella) — Self-host stella with web, API, Postgres, Redis, and object storage.

Open this page in a browser: https://railway.com/deploy/kitten-tts-2-or-just-updated-openai-comp
