Overview
This plugin allows you to use OpenAI as an STT provider for your voice agents.
Installation
Install the plugin from PyPI:
uv add "livekit-agents[openai]~=1.5"
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 STT in an AgentSession or as a standalone transcription service. For example, you can use this STT in the Voice AI quickstart.
from livekit.plugins import openaisession = AgentSession(stt = openai.STT(model="gpt-4o-mini-transcribe",),# ... llm, tts, etc.)
import { inference, voice } from '@livekit/agents';import * as openai from '@livekit/agents-plugin-openai';const vad = new inference.VAD({ model: 'silero' });const session = new voice.AgentSession({stt: new openai.STT({model: 'gpt-realtime-whisper',vad,}),// ... llm, tts, etc.});
The gpt-realtime-whisper model doesn't support server-side turn detection. You must pass a vad instance so the plugin can commit the audio buffer at end-of-speech.
In @livekit/agents-plugin-openai@1.4.1, the default model for openai.STT changed from whisper-1 to gpt-realtime-whisper, which streams transcription over a WebSocket. To restore the previous behavior, set useRealtime: false:
const stt = new openai.STT({ useRealtime: false });
Using an OpenAI-compatible gateway
Realtime transcription streams over a WebSocket, which you can route through an OpenAI-compatible gateway or proxy, such as LiteLLM , Cloudflare AI Gateway, Helicone, or Portkey. Set the baseURL to your gateway endpoint and set the apiKey:
import { voice } from '@livekit/agents';import * as openai from '@livekit/agents-plugin-openai';import * as silero from '@livekit/agents-plugin-silero';const vad = await silero.VAD.load();const session = new voice.AgentSession({stt: new openai.STT({model: 'gpt-realtime-whisper',// Connects to wss://your-gateway.example.com/v1/realtime?intent=transcription&model=gpt-realtime-whisperbaseURL: 'https://your-gateway.example.com/v1',apiKey: process.env.GATEWAY_API_KEY,vad,}),// ... llm, tts, etc.});
The plugin adds the model as a ?model= query parameter on the connection URL when the host isn't api.openai.com, so the gateway can route each connection to the correct model. An https:// base URL maps to wss://, and http:// maps to ws://.
Connecting directly to OpenAI omits the ?model= parameter by design. In that case, the plugin sends the model in the session configuration instead.
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.
modelWhisperModels | stringDefault: gpt-4o-mini-transcribe | gpt-realtime-whisperModel to use for transcription. See OpenAI's documentation for a list of supported models .
Default model varies by SDK:
- Python:
gpt-4o-mini-transcribe - Node.js:
gpt-realtime-whisper
languageLanguageCodeDefault: enLanguage code for the input audio. See OpenAI's documentation for a list of supported languages .
useRealtimebooleanDefault: trueWhen true, streams transcription over the OpenAI Realtime WebSocket. Set to false to use the standard REST transcription API with whisper-1.
vadVADA VAD instance for client-side end-of-speech detection. Required when using gpt-realtime-whisper, because this model doesn't support server-side turn detection.
Additional resources
The following resources provide more information about using OpenAI with LiveKit Agents.