Installation
Install the Stream OpenAI plugin withTutorials
The Voice AI quickstart and Video AI quickstart pages have examples to get you up and running.Example
Check out our OpenAI example to see a practical implementation of the plugin and get inspiration for your own projects, or read on for some key details.Usage
The OpenAI Realtime plugin is used as the LLM component of an Agent. Here’s a complete example:Parameters
These are the parameters available in the OpenAI Realtime plugin:Name | Type | Default | Description |
---|---|---|---|
model | str | "gpt-realtime" | The OpenAI model to use for speech-to-speech. Supports real-time models only. |
voice | str | "marin" | The voice to use for spoken responses (e.g., “marin”, “alloy”, “echo”). |
fps | int | 1 | Number of video frames per second to send (for video-enabled agents). |
OPENAI_API_KEY
environment variable. Instructions are set via the Agent’s instructions
parameter.
Methods
connect()
Establishes the WebRTC connection to OpenAI’s Realtime API. This is called automatically when the agent joins a call and should not be called directly in most cases.simple_response(text)
Sends a text message to the OpenAI Realtime session. The model will respond with audio output.simple_audio_response(pcm_data)
Sends raw PCM audio data to OpenAI. Audio should be 48 kHz, 16-bit PCM format.request_session_info()
Requests session information from the OpenAI API.Properties
output_track
Theoutput_track
property provides access to the audio output stream from OpenAI. This is an AudioStreamTrack
that contains the synthesized speech responses.
is_connected
ReturnsTrue
if the realtime session is currently active.