Skip to main content

Kokoro TTS plugin guide

How to run Kokoro TTS locally with LiveKit Agents.

Available inPython

Overview

Kokoro is an open-weight TTS model you can run locally. Kokoro-FastAPI  wraps it in an OpenAI-compatible endpoint, which the OpenAI plugin connects to directly.

Installation

Install the OpenAI plugin to add Kokoro support:

uv add "livekit-agents[openai]~=1.5"

Usage

Run Kokoro-FastAPI, then point openai.TTS at its OpenAI-compatible endpoint. For example, you can use this TTS in the Voice AI quickstart:

from livekit.plugins import openai
session = AgentSession(
tts=openai.TTS(
model="kokoro",
voice="af_alloy",
api_key="not-needed",
base_url="http://localhost:8880/v1",
response_format="wav",
),
# ... llm, stt, vad, turn_detection, etc.
)

Parameters

This section describes the parameters used to connect to a Kokoro-FastAPI server. See the plugin reference for a complete list of all available parameters.

modelstring

Model to use for speech generation. Set to kokoro to use the Kokoro model served by Kokoro-FastAPI.

voicestring

Kokoro voice name, such as af_alloy. For the full list of available voices, see the Kokoro-FastAPI documentation .

base_urlstring

URL of your Kokoro-FastAPI server's OpenAI-compatible endpoint. Kokoro-FastAPI listens on http://localhost:8880/v1 by default.

api_keystring

Kokoro-FastAPI doesn't require authentication, but the OpenAI client rejects an empty value. Set any non-empty placeholder, such as not-needed.

response_formatstring

Audio format returned by the server. Kokoro-FastAPI supports several formats, such as wav.

Additional resources

The following resources provide more information about using Kokoro with LiveKit Agents.