Prerequisites
- An Azure subscription - Create one for free.
- A Microsoft Foundry resource - Create a Microsoft Foundry resource.
- A deployment of the
gpt-live-1model. - A trusted backend that holds your API key or Microsoft Entra ID credentials. GPT-Live doesn’t support ephemeral client keys, so the browser never authenticates to the service directly.
How the WebRTC connection is established
GPT-Live doesn’t issue ephemeral client keys, so the browser can’t create a session directly. Session initialization goes through your trusted backend, while the audio media connects directly between the browser and the service:- In the browser, create an
RTCPeerConnection, add an audio transceiver and a data channel, and create an SDP offer. - Send the SDP offer to your backend.
- Your backend forwards the offer to the service in a session-creation request, authenticated with your API key or Microsoft Entra ID credentials. The response contains the session ID and the SDP answer.
- Your backend relays the SDP answer to the browser.
- The browser applies the answer. Audio then flows directly between the browser and the service over the negotiated media track, and the data channel carries JSON events.
Browser: create the offer
Backend: create the session
Your backend sends the browser’s SDP offer and the session configuration to the service, then returns the SDP answer to the browser. Keep credentials on the backend.session.id if your backend attaches a sideband WebSocket to observe or steer the session.
Differences from the WebSocket transport
- Don’t send
session.input_audio.appendon the WebRTC data channel, and don’t expectsession.output_audio.deltathere. Audio flows over the negotiated media track instead. - Input and output media are synchronized through RTP and don’t carry JSON timing fields.
- All other session events—
session.update, thesession.instructions.append/session.thinking.append/session.commentary.appendcontext events, delegation events, transcripts, usage, and errors—use the same schema as WebSocket. See the GPT-Live event API reference.