Chat with OpenAI's latest `gpt-4o-mini-tts` model in a LiveKit demo inspired by OpenAI.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 openaisession = 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.
ID of the model to use for speech generation. To learn more, see TTS models.
ID of the voice used for speech generation. To learn more, see TTS voice options.
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.
Python package
The livekit-plugins-openai
package on PyPI.
Plugin reference
Reference for the OpenAI TTS plugin.
GitHub repo
View the source or contribute to the LiveKit OpenAI TTS plugin.
OpenAI docs
OpenAI TTS docs.
Voice AI quickstart
Get started with LiveKit Agents and OpenAI TTS.
OpenAI ecosystem guide
Overview of the entire OpenAI and LiveKit Agents integration.