Overview
LiveKit's OpenAI integration provides support for LLM, STT, TTS, and the OpenAI Realtime API. The Quick reference section in this topic describes using OpenAI for LLM, STT, and TTS. For a guide on using the Realtime API, see the OpenAI Realtime API integration guide.
Use OpenAI STT, TTS, and LLM to create agents using the VoicePipelineAgent class. To use the Realtime API, you can create an agent using the MultimodalAgent class.
The following quickstart guides are available to get you started creating an AI voice assistant with OpenAI:
- Voice agent quickstart using the
VoicePipelineAgent
class. - Speech-to-speech quickstart using the
MultimodalAgent
class.
Quick reference
The following sections provide a quick reference for integrating OpenAI with LiveKit. For the complete reference, see the links provided in each section.
LLM
LiveKit's OpenAI plugin provides support for creating an instance of an LLM class to be used in a VoicePipelineAgent
.
LLM class usage
Create an instance of OpenAI LLM:
from livekit.plugins.openai import llmopenai_llm = llm.LLM(model="gpt-4o",temperature=0.8,)
LLM parameters
This section describes some of the available parameters. For a complete reference of all available parameters, see the plugin reference.
OpenAI API key. Required if the environment variable is not set.
A measure of randomness of completions. A lower temperature is more deterministic. To learn more, see chat completions.
STT
LiveKit's OpenAI plugin allows you to create an instance of OpenAI STT that can be used as the first stage in a VoicePipelineAgent
or as a standalone transcription service.
STT usage
Create an OpenAI STT:
from livekit.plugins.openai import sttopenai_stt = stt.STT(language="en",model="whisper-1",)
STT parameters
This section describes some of the available parameters. For a complete reference of all available parameters, see the plugin reference.
ID of the model to use for speech recognition. To learn more, see Whisper.
Language of input audio in ISO-639-1 format. See OpenAI's documentation for a list of supported languages.
TTS
LiveKit's OpenAI plugin allows you to create an instance of OpenAI TTS that can be used in a VoicePipelineAgent
or as a standalone speech generator.
TTS usage
Create an OpenAI TTS:
from livekit.plugins.openai import ttsopenai_tts = tts.TTS(model="tts-1",voice="nova",)
TTS parameters
This section describes some of the available parameters. For a complete reference of all available parameters, see the plugin reference.
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.