█

AI/TLDR

Buy me a coffee
Buy me a coffee

Kokoro-FastAPI

Serve the Kokoro-82M voice model behind an OpenAI-compatible speech endpoint

Audio, Music & VoiceOpen source
Language
Python
License
Apache-2.0
$docker run -p 8880:8880 ghcr.io/remsky/kokoro-fastapi-cpu:latest
IN SHORT

What is Kokoro-FastAPI?

Kokoro-FastAPI is Serve the Kokoro-82M voice model behind an OpenAI-compatible speech endpoint. It sits in the Audio, Music & Voice category of the Multimodal Generation tools and is open-source, written in Python and licensed Apache-2.0. To get started: run the CPU image.

Overview

Kokoro-FastAPI, also published as FastKoko, wraps the Kokoro-82M text-to-speech model in a FastAPI server that speaks the OpenAI speech API. That single design decision is the point of the project: any client already written against OpenAI's `audio.speech` endpoint — the official Python library included — can be pointed at `http://localhost:8880/v1` with a throwaway API key and start generating audio from a local model instead of a hosted one.

The images ship with the model baked in and cover the hardware people actually have: a CPU image for laptops and CPU-only servers, NVIDIA CUDA images (cu126 by default, cu128 for RTX 50-series/Blackwell, and an arm64 build for Jetson and GH200), an experimental AMD ROCm image, and a native Apple Silicon MPS path that runs directly through uv rather than Docker. A `docker compose` setup and a direct uv run are both documented for people who want to build rather than pull.

On top of plain synthesis it exposes the pieces that longer-form work needs: multi-speaker generation and weighted voice mixing (a voice can be written as `af_sky+af_bella`), SSML, per-word or per-chunk timestamped captions, phoneme endpoints in both directions, custom voicepack generation through the companion Inno Clone-Tuner project, and an optional built-in web UI with read-along. It supports English (US and GB), Spanish, French, Hindi, Italian, Japanese, Brazilian Portuguese and Mandarin Chinese, and is used as the TTS backend by a long list of community projects — Home Assistant add-ons, audiobook generators, SillyTavern and Open WebUI among them.

What it does

  • OpenAI-compatible /v1 speech endpoint — existing OpenAI client code works unchanged against a local Kokoro-82M
  • Prebuilt multi-platform images with models included: CPU, NVIDIA CUDA (cu126 / cu128 / arm64), and experimental AMD ROCm; Apple Silicon MPS supported when run directly via uv
  • Inline multi-speaker generation and voice mixing with weighted combinations and aliasing, plus SSML support
  • Per-word or per-chunk timestamped caption generation, and phoneme endpoints that convert text to phonemes or phonemes to audio
  • Custom voicepack generation via the Inno Clone-Tuner companion project
  • Optional integrated web UI with read-along for long generations, served alongside the interactive API docs

Getting started

The quickest path is a single docker run with a prebuilt image — the models are baked in. Pin a release tag rather than :latest for anything you depend on.

Run the CPU image

For a laptop or a CPU-only server. The API comes up on port 8880.

bashbash
docker run -p 8880:8880 ghcr.io/remsky/kokoro-fastapi-cpu:latest

Or run on an NVIDIA GPU

The default GPU tag ships cu126 (GTX 900-series through RTX 40). For RTX 50-series / Blackwell use the cu128 tag instead; the same default tag covers arm64 Jetson and GH200.

bashbash
docker run --gpus all -p 8880:8880 ghcr.io/remsky/kokoro-fastapi-gpu:latest
# RTX 50-series / Blackwell
docker run --gpus all -p 8880:8880 ghcr.io/remsky/kokoro-fastapi-gpu:latest-cu128

Generate speech with the OpenAI client

Point base_url at your server and pass any string as the API key. The voice can be a single voicepack or a combination.

pythonpython
from openai import OpenAI

client = OpenAI(
    base_url="http://localhost:8880/v1", api_key="not-needed"
)

with client.audio.speech.with_streaming_response.create(
    model="kokoro",
    voice="af_sky+af_bella", #single or multiple voicepack combo
    input="Hello world!"
  ) as response:
      response.stream_to_file("output.mp3")

Open the UI and the docs

The server exposes interactive API documentation and an optional web interface on the same port.

texttext
# API docs:      http://localhost:8880/docs
# Web interface: http://localhost:8880/web

Build from source instead

Clone the repo and bring up the compose stack for your hardware, or run directly through uv for hot-reload and native Apple Silicon acceleration.

bashbash
git clone https://github.com/remsky/Kokoro-FastAPI.git
cd Kokoro-FastAPI
cd docker/gpu   # or docker/cpu, or docker/rocm
docker compose up --build

Commands and code are distilled from the project's own documentation — always check the official repo for the latest.

When to use it

  • Swap a paid hosted TTS API for a local model without touching client code, by repointing an existing OpenAI speech integration at localhost
  • Generate long-form narration — audiobooks, read-along documents — where per-chunk timestamps and hours of throughput matter more than a single short clip
  • Give a self-hosted assistant, Home Assistant install or chat UI a voice, using the community integrations the project already documents
  • Build a custom voice with the Clone-Tuner companion and serve it through the same endpoint as the stock voicepacks

How Kokoro-FastAPI compares

Kokoro-FastAPI alongside other open-source audio, music & voice tools AI/TLDR tracks, ranked by GitHub stars.

ToolStarsWhat it does
VoiceStudio★ 121kA local-first desktop voice studio that clones and designs voices, dubs video, and handles dictation, running 16 text-to-speech and 11 speech-recognition engines on your own hardware.
Whisper★ 114kOpenAI's speech recognition model that transcribes and translates audio across many languages.
GPT-SoVITS★ 64.3kAn open-source WebUI that clones a voice from a short audio sample and turns text into speech, with zero-shot and few-shot fine-tuning.
Voicebox★ 61.6kLocal-first voice studio that clones a voice from a short sample, generates speech across seven TTS engines and 23 languages, handles system-wide dictation, and speaks for agents over MCP.
VibeVoice★ 57.6kMicrosoft's text-to-speech model for generating long, expressive multi-speaker audio like podcasts.
whisper.cpp★ 55.7kA dependency-free C/C++ port of Whisper built on ggml, running speech recognition on CPU, Metal, CUDA, Vulkan and NPUs from phones to servers.
Coqui TTS★ 46.3kA library of text-to-speech models including the multilingual XTTS voice-cloning model.
Kokoro-FastAPI★ 5.7kServe the Kokoro-82M voice model behind an OpenAI-compatible speech endpoint