Primary WebSocket
For the complete documentation index, see llms.txt. Markdown versions of documentation pages are available by appending
.mdto the page URL.
Connect from your backend server with your OpenAI API key to start a Live session. Send and receive audio and control events on the same WebSocket connection.
WS /v1/live/sessions
Connection
wss://api.openai.com/v1/live/sessions
Authenticate from your backend with your OpenAI API key in the Authorization: Bearer $OPENAI_API_KEY header. Keep the key on your server.
No query parameters. After connecting, send session.start with your model and session configuration. Wait for session.started before sending audio.
Inputs
Required once, immediately after connecting. Configure the session here, then send audio and other client events.
First message: session.start
{
"type": "session.start",
"event_id": "evt_start_001",
"session": {
"model": "gpt-live-1",
"instructions": "Help the caller plan a restaurant reservation. Confirm details before booking.",
"audio": {
"format": {
"type": "audio/pcm",
"rate": 24000
},
"output": {
"voice": "marin"
}
},
"delegation": {
"type": "client"
}
}
}Outputs
The server confirms the session has started. Audio, transcripts, and other server events follow as the session runs.
Session ready · excerpt: session.started
{
"type": "session.started",
"event_id": "event_started_1",
"session": {
"id": "live_123",
"expires_at": 1788307200,
"status": "active",
"model": "gpt-live-1"
}
}Using WebRTC on the frontend? Attach a sideband WebSocket from your backend.
Client events
session.start
Start a Live session on a primary WebSocket. Send this event before other commands and wait for session.started.
本篇目录
- Schema
- Example
- Schema
- Example
- Schema
- Example
- Schema
- Example
- Schema
- Example
- Schema
- Example
- Schema
- Example
- Schema
- Example
- Schema
- Example
- Schema
- Example
- Schema
- Example
- Schema
- Example
- Schema
- Example
- Schema
- Example
- Schema
- Example
- Schema
- Example
- Schema
- Example
- Schema
- Example
- Schema
- Example
- Schema
- Example
- Schema
- Example
- Schema
- Example
- Schema
- Example
- Schema
- Example
- Schema
- Example
- Schema
- Example
- Schema
- Example
- Schema
- Example
- Schema
- Example
- Schema
- Example
- Schema
- Example
- Schema
- Example
- Schema
- Example