Sideband WebSocket
/v1/live/sessions/{session_id}/attachAttach your backend server to an existing Live session with your OpenAI API key. For example, when your frontend connects over WebRTC, use this WebSocket to handle events and control the session from your backend.
Connection
wss://api.tpg-oai.studydeckedu.com/v1/live/sessions/{session_id}/attachsession_id: string required · path
The ID of the existing session to attach to. Use the session ID returned when the session was created or accepted.
Authorization: Bearer $OPENAI_API_KEY required · header
Use your OpenAI API key from your backend server. Keep this key on your server; never expose it in frontend code.
Attaching does not create a session or replay earlier events. The primary connection carries live media; this sideband receives reflected input and output audio. Do not send session.start or session.input_audio.append on this WebSocket.
Inputs
For a session using Responses delegation, update its tool choice. The delegation type cannot change. There is no required first message after attaching.
session.update{
"type": "session.update",
"event_id": "update_1",
"session": {
"delegation": {
"type": "responses",
"responses": {
"tool_choice": "required"
}
}
}
}Outputs
A configuration update is acknowledged with session.updated. You also receive subsequent session events; attaching alone does not trigger this event.
session.updated{
"type": "session.updated",
"event_id": "event_updated_1",
"client_event_id": "update_1",
"session": {
"id": "live_123",
"expires_at": 1788307200,
"status": "active",
"model": "gpt-live-1"
}
}Update the delegation settings or transcript triggers of an active Live session. The server acknowledges accepted changes with session.updated.
Mute audio input to the Live model without closing the session. The server acknowledges with session.input_audio.muted.
Resume audio input to a Live model after muting it. The server acknowledges with session.input_audio.unmuted. An active audio fixture still pauses inference until playback finishes.
Play one complete audio fixture through the session output. Send this event over the primary WebSocket or a server sideband. Audio must be raw mono PCM16 little-endian at 24 kHz, regardless of the session audio format, and at most 30 seconds. The entire payload is validated before model speech is interrupted and input is muted. Only one fixture can be active. fixture.playing acknowledges acceptance and fixture.played reports server mixer drain. These notifications are not exact transport-media boundaries. Input arriving during playback is dropped and not replayed.
Append developer instructions to the Live conversation while it is running, optionally associating them with an existing client delegation. Rejected while an audio fixture is active. These instructions remain in conversation history through compaction and are included in future backend delegations. For external audio, describe content already delivered so the assistant does not repeat it.
Instruction text to append, limited to 500 tokens. This is a plain string, not an array of content parts.
Provide silent reasoning or progress context to the Live model, optionally for an existing client delegation. Rejected while an audio fixture is active.
Silent reasoning or progress context, limited to 500 tokens. It does not directly request speech, but can influence later speech and is not a secrecy boundary.
Provide context the Live model can communicate to the user, optionally for an existing client delegation. Rejected while an audio fixture is active.
Speakable context for the Live model, limited to 500 tokens. Use this for a result the model should communicate; use session.thinking.append for silent context.
Delete an input item from future decisions without starting an evaluation or changing Live voice context.
Add an input item to the Live session’s Responses backend. Requires Responses delegation; use response.create to request a response.
Request a response from the Live session’s Responses backend, or continue a delegated response waiting for tool results. Requires Responses delegation.
Request that the Live session close. The terminal session.closed event contains the close reason and final usage.
Acknowledges a session.input_audio.mute command. An independent input mute sends silence to the model and preserves sideband audio reflection. Fixture playback does not emit this event.
Acknowledges a session.input_audio.unmute command, removing the independent input mute. An active audio fixture still pauses inference until playback finishes. Fixture playback does not emit this event.
The existing playback path has accepted the validated audio fixture. This acknowledgment does not identify when the listener receives the first sample. The optional client_event_id echoes the play command.
The complete audio fixture has drained from the server mixer and normal inference has resumed. Transport buffers may still contain audio; this event does not prove listener-side completion. The optional client_event_id echoes the play command. This event is not emitted for canceled or failed playback.
Returned when a session.instructions.append command is accepted into the Live session timeline. Acknowledges the appended instructions without guaranteeing that the model has acted on them.
Returned when a session.thinking.append command is accepted into the Live session timeline. Acknowledges the added reasoning context without guaranteeing any spoken output.
Returned when a session.commentary.append command is accepted into the Live session timeline. Acknowledges the added commentary without guaranteeing exact wording or completed audio playback.
An audio chunk generated by the Live model. Decode and play primary WebSocket chunks in delivery order using the configured session audio format. Sideband connections receive reflected output audio with timestamps.
Base64-encoded raw audio. Primary WebSocket events use the session's configured format; reflected sideband events use mono PCM16LE at 24 kHz.
A transcript fragment for user input audio in the Live session. Accumulate fragments in delivery order; these events do not define complete turns or include a transcript-done event.
The transcript text fragment for the audio in this time range. Append fragments in delivery order to build the transcript.
The end of this event on the Live session timeline, in milliseconds from the beginning of the session. For appended context, this can equal start_ms.
A transcript fragment for assistant output audio in the Live session. Accumulate fragments in delivery order; these events do not define complete turns or include a transcript-done event.
The transcript text fragment for the audio in this time range. Append fragments in delivery order to build the transcript.
The end of this event on the Live session timeline, in milliseconds from the beginning of the session. For appended context, this can equal start_ms.
Returned when the Live model delegates work to your application, Responses, or Decisions. Contains delegation metadata and the position on the session timeline where the work was delegated.
A streaming Responses API event from a backend delegated to by the Live session. Use the outer delegation_id to associate the nested stream with its Live delegation.
The nested Responses streaming event. Dispatch on its type field. Response lifecycle snapshots omit input and clear instructions, tools, and output to keep messages small; consume granular output events for the generated content.
Reports cumulative Live audio usage and, when available, the most recent context-window usage. Delegated Responses token usage is reported separately in response.event events.
Returned after the Live session finishes finalizing, with the close reason, final session snapshot, and cumulative audio usage. A connection closing without this event does not confirm successful finalization.
An informational notice about the Live session, such as the event permissions applied to a frontend data channel.
Input audio received from the primary transport and reflected to a Live sideband connection before model-input muting.