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.2"
pnpm add @livekit/agents-plugin-openai@1.x
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.)
import * as openai from '@livekit/agents-plugin-openai';const session = new voice.AgentSession({tts: new 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 links in the Additional resources section 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.