OpenAI TTS integration guide

How to use the OpenAI TTS plugin for LiveKit Agents.

Try LiveKit.fm

Chat with OpenAI's latest `gpt-4o-mini-tts` model in a LiveKit demo inspired by OpenAI.fm

Try LiveKit.fm

Overview

OpenAI TTS provides lifelike spoken audio through their latest model gpt-4o-mini-tts model or their well-tested tts-1 and tts-1-hd models. With LiveKit's OpenAI TTS integration and the Agents framework, you can build voice AI applications that sound realistic and natural.

To learn more about TTS and generating agent speech, see Agent speech.

Quick reference

This section includes a basic usage example and some reference material. For links to more detailed documentation, see Additional resources.

Installation

Install the plugin from PyPI:

pip install "livekit-agents[openai]~=1.0rc"

Authentication

The OpenAI plugin requires an OpenAI API key.

Set OPENAI_API_KEY in your .env file.

Usage

Use OpenAI TTS in an AgentSession or as a standalone speech generator. For example, you can use this TTS in the Voice AI quickstart.

from livekit.plugins import openai
session = AgentSession(
tts = openai.TTS(
model="gpt-4o-mini-tts",
voice="ash",
instructions="Speak in a friendly and conversational tone.",
),
# ... llm, stt, etc.
)

Parameters

This section describes some of the available parameters. See the plugin reference for a complete list of all available parameters.

modelTTSModels | stringOptionalDefault: gpt-4o-mini-tts

ID of the model to use for speech generation. To learn more, see TTS models.

voiceTTSVoice | stringOptionalDefault: ash

ID of the voice used for speech generation. To learn more, see TTS voice options.

instructionsstringOptional

Instructions to control tone, style, and other characteristics of the speech. Does not work with tts-1 or tts-1-hd models.

Additional resources

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

Was this page helpful?