GPT-Live API: Build a Voice App With WebRTC, a Sideband and Delegation
Build a voice app on the GPT-Live API: open a WebRTC session, attach a sideband, delegate to a backend, keep state, test it and price each call.
Published

The GPT-Live API (gpt-live-1.1) holds a spoken conversation in both directions at once and hands lookups and tool work to a backend model while it keeps talking. Building on it comes down to three things OpenAI's GPT-Live course teaches: audio both ways over WebRTC, a sideband that lets your server into the same session, and delegation. All three are shown with OpenAI's own code, as of December 2026.
New to GPT-Live itself? Start with what GPT-Live is and how ChatGPT uses it.
What a first GPT-Live app is made of
A GPT-Live app has three parts, and each keeps one job. The browser owns the microphone and the speaker. Your server owns the API key, creates the session and runs anything that touches your systems. OpenAI runs GPT-Live, the voice, and, if you choose, the backend model it delegates to.
As of Dec 5, 2026 · Source: OpenAI, GPT-Live docs and training
OpenAI's split of duties is worth keeping in view from the first line of code. GPT-Live listens, speaks and decides when to ask the backend for help. The backend reasons and uses tools. Your application checks permissions, gets required confirmations, runs the functions that reach your systems and saves task progress. Getting started with GPT-Live
What you need before you start, per OpenAI's quickstart and course:
- A project API key with access to GPT-Live, on an OpenAI Platform account with API credits or billing.
- A server runtime. The TypeScript example needs Node.js 22.6 or later.
- A browser with microphone permission, on a page served over HTTPS or localhost.
Open a session over WebRTC
WebRTC is the connection OpenAI recommends, and the one its course uses throughout. The browser describes its side of the call in an SDP offer (Session Description Protocol: the audio formats it supports and the network addresses OpenAI can try). Your server sends that offer to OpenAI with the session settings and returns OpenAI's SDP answer. The HTTP request itself starts the session.
Ask for the microphone
Request microphone access from a user action, such as a Start conversation button, and add its audio track to a peer connection.
Open the data channel first
Create the data channel and register its listeners before you create the SDP offer. In OpenAI's example the channel's label is
oai-events.Send the offer to your server
Set the local description, wait for ICE candidate gathering to complete, and post the offer to your own endpoint.
Create the session on your server
Your server posts the session settings and
transport: { type: "webrtc", sdp: ... }to OpenAI with the project key, and returns the answer.Apply the answer and wait
Set the answer as the remote description. Wait for
session.startedon the data channel before you send any command.
This is the session call in OpenAI's TypeScript server, from the WebRTC quickstart. It sets the voice model, a short voice prompt, and a Responses backend that can search the web:
const result = await client.live.create({
session: {
model: "gpt-live-1.1",
instructions:
"Be concise. Delegate requests needing current information to the backend, which can search the web.",
delegation: {
type: "responses",
responses: {
model: "gpt-5.6-terra",
instructions:
"Use web search when current facts are needed. Return concise, grounded results for a spoken conversation.",
tools: [{ type: "web_search" }],
tool_choice: "auto",
},
},
},
transport: {
type: "webrtc",
sdp: request.body.sdp,
},
});The browser side, from the same quickstart, ends with the answer:
const result = await response.json();
console.log("Created session", result.session.id);
await connection.setRemoteDescription({
type: "answer",
sdp: result.transport.sdp,
});
// The HTTP request started this session. Do not send session.start here.A successful request returns HTTP 201 with the session ID and the answer. Keep the ID exactly as it comes, prefix included: the sideband needs it.
{
"session": { "id": "live_123" },
"transport": { "type": "webrtc", "sdp": "<SDP answer>" }
}npm install openai express
npm pkg set type=module
npm install --save-dev esbuild
npx esbuild browser.ts --format=esm --outfile=browser.js
node --experimental-strip-types server.ts
Four details trip up first builds:
- Do not send
session.starton the data channel. On WebRTC the HTTP request already started the session. - Leave
audio.formatout. WebRTC negotiates the format in the SDP exchange, and audio travels on the media tracks, never as events on the data channel. - Creating the session bills 15 seconds up front. With the default startup, OpenAI bills 15 seconds of voice duration during initialization and credits it once the session runs. It matters when you reconnect often or open sessions before anyone speaks.
- End with a handshake. Send
session.close, keep the connection open untilsession.closedarrives with the final usage, then release the microphone. OpenAI's example gives it 15 seconds before it reports an incomplete close.
OpenAI's course walks the same handshake step by step in its third lesson, and the video version is short:
WebRTC or WebSocket, and when each fits
Live audio has two needs at once: send the caller's voice as they speak, and play the reply as it is generated. Both need a connection that stays open for the whole call. OpenAI's course puts the difference plainly: a WebSocket can carry audio but was not built for it, so your app must buffer pieces that arrive at uneven intervals; WebRTC was built for live audio and handles compression and smooth playback for you. GPT-Live training, lesson 3
Browser sends its SDP offer to your server
Server calls POST /v1/live/sessions, gets HTTP 201 and the answer
Wait for session.started on oai-events; audio flows on media tracks
Server connects to wss://api.openai.com/v1/live/sessions
First message: session.start, with model, audio format, voice, delegation
Wait for session.started, then stream session.input_audio.append
Two facts decide most cases. OpenAI recommends WebRTC even for server-to-server integrations, so a browser app has no reason to pick anything else. And the cheaper standby rate applies only to WebRTC sessions. Choose a WebSocket when your server already moves raw PCM or G.711 audio and you are ready to handle buffering, resampling and playback tracking yourself: a WebSocket session sends output audio with no timing fields and no output-audio-done event. WebSockets guide
On a WebSocket, the first message starts the session. This is the opening of OpenAI's TypeScript WebSocket example:
ws.socket.on("open", () => {
ws.send({
type: "session.start",
event_id: "event_start",
session: {
model: "gpt-live-1.1",
instructions:
"Be concise. Delegate requests needing current information to the backend, which can search the web.",
audio: {
format: { type: "audio/pcm", rate: 24000 },
output: { voice: "marin" },
},
delegation: {
type: "responses",
responses: {
model: "gpt-5.6-luna",
tools: [{ type: "web_search" }],
tool_choice: "auto",
},
},
},
});
});For phone calls, OpenAI documents SIP and partner integrations for LiveKit, Twilio, Telnyx, Bandwidth and Daily/Pipecat. Its getting-started page also reminds you that consent, do-not-call, time-of-day and opt-out rules, and required disclosures, are yours to meet.
The sideband: your server inside the same call
Once the WebRTC call is open, audio and events flow straight between the browser and GPT-Live. Your server set the call up but cannot hear it. The sideband fixes that: a second WebSocket, opened from your server, attached to the same session. Audio stays on the browser's connection; the sideband carries events and commands.
Attach with the session ID from the 201 response and your project key (Authorization: Bearer), at this address:
wss://api.openai.com/v1/live/sessions/{session_id}/attachThe session is already running, so do not send session.start again. Server-side controls
When you need one. Use a sideband when the work runs on your server: private tools, guardrail checks on the transcript, sentiment checks, or a lookup started early from what the caller is saying. In OpenAI's custom-tool lesson, the server uses the session ID to open a sideband so the tool call reaches the server, not the browser. When you don't. Captions and local UI updates belong on the browser's data channel. Responses delegation also works without a sideband: the browser can forward function-call events to an authenticated backend, and OpenAI's hosted tools need no executor at all.
Three rules keep a sideband honest:
- It replays the last 3 seconds when it attaches. Attach early, and drop repeated events by their
event_idso a reconnect never runs a tool twice. - One owner per action. If both the browser and the server receive a function-call event, only one of them runs it.
- Reflected audio is a copy. The sideband receives both sides as raw mono PCM16 at 24 kHz, but microphone audio is only ever sent on the primary connection.
A guardrail is the sideband's clearest use. Your server checks the transcript as it grows, blocks the affected action in its own state, and redirects the voice. This is OpenAI's own correction:
import type { ClientEvent } from "openai/resources/live/live";
export function sendUpdate(connection: { send: (event: ClientEvent) => void }) {
connection.send({
type: "session.instructions.append",
event_id: "guardrail_block_17",
delegation_id: null,
content:
"Stop speaking immediately. Do not continue or act on the last request. Refuse briefly, then wait.",
});
}Delegation: the voice keeps talking while the backend works
Delegation is the second big idea. GPT-Live decides a request needs more than conversation, hands it to a backend, and keeps talking with the caller until the result comes back. OpenAI's course frames the gain: you can move to newer backend models as they ship without replacing the voice, and an agent you already built for text can be reached by voice. GPT-Live training, lesson 2
You pick one of two modes when you create the session. To change modes, start a new session.
Responses delegation
Start here if the task fits one model with tools. OpenAI's delegation guide suggests starting with gpt-6-luna and trying gpt-6-sol for more complex backend tasks; its quickstart uses gpt-5.6-terra. Compare answer quality and latency on your own tasks before you choose. The backend can use OpenAI's hosted tools (web search, file search, Code Interpreter, hosted shell, image generation), MCP servers and your own functions. For speed-sensitive calls, delegation.responses.service_tier: "priority" selects Fast mode where your model and project have it. Delegation and tools
Hosted tools finish on their own. Your own functions need a round trip through your server:
As of Dec 5, 2026 · Source: OpenAI, Delegation and tools
OpenAI's code for steps 3 and 4:
import type { ClientEvent } from "openai/resources/live/live";
export function sendUpdate(connection: { send: (event: ClientEvent) => void }) {
connection.send({
type: "response.item.create",
event_id: "tool_result_1",
item: {
type: "function_call_output",
call_id: "call_123",
output: '{"status":"confirmed","order_id":"order_123"}',
},
});
}import type { ClientEvent } from "openai/resources/live/live";
export function sendUpdate(connection: { send: (event: ClientEvent) => void }) {
connection.send({
type: "response.create",
event_id: "continue_1",
});
}Appending a result does not resume the backend; response.create does. Leave a call unanswered and the session answers tool_outputs_required. One more trap: the forwarded response.completed event carries an empty output array even when calls are waiting, so read each call from its own response.output_item.done event.
Client delegation
Choose client delegation to put an existing agent behind the voice. The trade is context. When GPT-Live delegates, your server receives session.delegation.created with an ID and a target, and no words:
{
"type": "session.delegation.created",
"event_id": "event_delegation",
"offset_ms": 1000,
"delegation": {
"id": "item_9tA2bF3h7K9m2P5q8R1s4",
"type": "delegation",
"target": "client"
}
}So your server keeps both transcripts as they arrive (session.input_transcript.delta and session.output_transcript.delta), works out what the caller wants, runs the agent, and answers with the same ID. Three events carry the answer, each up to 500 tokens:
This is OpenAI's spoken result for a client delegation:
import type { ClientEvent } from "openai/resources/live/live";
export function sendUpdate(connection: { send: (event: ClientEvent) => void }) {
connection.send({
type: "session.commentary.append",
event_id: "result_123",
delegation_id: "item_9tA2bF3h7K9m2P5q8R1s4",
content: "The order shipped today and should arrive tomorrow.",
});
}GPT-Live can speak an automatic acknowledgment while your backend works. To keep it quiet, set a delay when you create the session, then send an empty session.thinking.append with the delegation's ID as soon as the delegation arrives. Any thinking or commentary append cancels every pending automatic acknowledgment in the session.
{
"delegation": {
"type": "client",
"acknowledgement_delay_ms": 800
}
}OpenAI's evaluation guide publishes a recorded call that uses client delegation. Its times and words, as recorded:
Hi, I'm John from Acme. How can I help you today?
Hi John! I was hoping to book a table on August 7th, if that's possible.
delegation 1 · client
Sure, let me check that for you.
Sure. What time would you like, for how many guests, and under what name?
7 p.m., please, for two under Maya.
delegation 2 · client; create_reservation runs at 0:21 (Maya, 2026-08-07, 19:00, 2)
All set, Maya. You're confirmed for August 7th at 7 p.m. for two.
The voice spoke at 0:09, a second after the first delegation began, and the question at 0:11 is the backend's reply in GPT-Live's words. The booking was confirmed at 0:24, after create_reservation ran at 0:21. That ordering is the discipline of delegation, and OpenAI's docs spell out the rest of it:
- Interrupting the voice does not cancel the work. If the caller changes Friday to Thursday, update the task in your application, ignore results from the Friday request, and confirm a cancellation before you announce it.
- A finished backend response is not a heard answer. The backend can complete while the spoken answer is cut off. Check the record and the audio separately.
- Check before you retry. A lost response must not produce a second booking. Give each action its own operation ID and each changed request a task revision, next to the delegation ID.
Prompt the voice short, keep the rules in the backend
GPT-Live's prompt is about how to talk and when to ask for help. Business rules, tool procedures and confirmation requirements belong to the backend. OpenAI gives a template for each.
OpenAI's recommended structure, from lesson 4 of the course:
Role and speaking style
You’re [name], a voice assistant for [service]. Help callers with [task]. Speak [language] in a warm tone and keep your replies brief.
Backchannel policy
Listen while the caller is speaking. Give an occasional quiet “mm-hmm” during a pause.
Interruption policy
If the caller interrupts with a question or correction, pause and listen. If they’re just letting you know they’re following, keep going.
Delegation policy
Backend tools:
- [Capability]: [what the backend can look up or do].
Delegate to the backend when:
- The caller’s request needs a backend capability or careful reasoning.
- The caller corrects something that changes work already in progress.
Do not delegate when:
- You can answer from the conversation or a backend result that still applies.
- You need to ask a clarifying question first.
Delegate to the backend before giving an answer that depends on backend work. Do not guess the result while waiting.OpenAI's starting point for adapting an existing text-agent prompt, from the delegation guide:
## Voice conversation context
You are helping an assistant in a live voice conversation. Transcripts
can contain mistakes, unfinished phrases, and later corrections. Use
the latest context and verified records. If a needed detail is still
unclear, ask for that detail instead of guessing.
## Task instructions
[Your task instructions, business rules, available tools,
and confirmation requirements.]
## Return the result
Return the relevant facts, the task's current status, and the next step.
Report an action as complete after the tool or service confirms success.
If the outcome is unclear, state that and explain what needs to be checked.Some settings are fixed for the life of a session: the voice model, the startup instructions (up to 16,384 tokens), the voice (marin by default, with 28 more listed across eight languages), the WebSocket audio format and the delegation mode. Changing any of them means a new session. The backend's model, instructions and tools can change mid-call with session.update. Managing sessions
Long conversations: what to keep in your own application
GPT-Live manages long calls for you, and that is exactly why your application must keep its own record. As of December 2026, OpenAI's session guide describes it this way:
- The context window holds 128,000 tokens, counting your instructions, the conversation text and audio tokens that never appear in the transcript.
- GPT-Live summarizes older history in the background. Above 90% usage it starts a replacement voice engine inside the same session, which gets your original instructions and up to 8,192 tokens of history: recent messages and, when available, a summary of older ones.
- Older details may be summarized or dropped.
session.usage.updated reports both the running voice seconds and how full the context is:
{
"type": "session.usage.updated",
"event_id": "event_usage_1",
"usage": { "seconds": 12 },
"context_window": { "usage_ratio": 0.42 }
}What to keep in your application, whatever the delegation mode:
- Confirmed actions and the current task state, with an operation ID per action, so a retry or reconnect never repeats one.
- Important facts the caller gave (names, numbers, choices), to hand back with
session.thinking.appendwhen they matter. - Both transcripts, with their
start_msandend_ms. Under client delegation they are your backend's only context. They also arrive as fragments with no event that marks a finished turn, so your app decides how to group them. - The session ID and the delegation IDs, so late results from an old session or an outdated request cannot overwrite newer work.
To restart a conversation, seed a new session's input with up to 128 messages and 8,192 combined tokens of saved history, or fork a stored session if you created it with store: true. For quiet stretches on WebRTC, standby keeps the call connected at the lower rate: set wake_policy.type to speech and idle_timeout_s to a whole number from 5 to 60, and keep the microphone track live. For long gaps, close the session and start another when the user returns.
When a call ends, session.closed tells you why: close_requested, expired, content (a safety filter ended it), remote_hangup or connection_lost. If the connection drops before that event, the final usage is unconfirmed: record it that way.
How OpenAI evaluates a voice agent
A voice agent can sound right and still book the wrong date. OpenAI's evaluation guide therefore follows one request from the caller's audio to the tool call, the saved record and the spoken confirmation, and grades two things separately: the conversation and the task. GPT-Live evaluation guide
Its test case restaurant_003 shows why. The caller says, “Book a table for Maya on August 7–sorry, August 6–at 7 p.m. for two.” A pass needs exactly one reservation, for August 6, confirmed only after the tool succeeded.
OpenAI builds the tests up in three stages:
- Crawl: one request, turned into clean synthetic audio and replayed the same way after each change.
- Walk: the same request as real recordings, or with added noise, telephone filtering, background speech, echo or packet loss.
- Run: a whole conversation against a second GPT-Live session that plays the caller with its own private goal.
Voice models are nondeterministic, so OpenAI's guide runs each scenario several times and reports P50 and P90 for timing. Its course gives the arithmetic for task completion: two passing attempts out of three is a 67% task completion rate. GPT-Live training, lesson 8
The recorded call in the scene above passed. Its report, as OpenAI published it:
OpenAI says a single run is not a performance benchmark. Read it as the shape of a report, not as a promise about latency on your calls. The runnable harness for all three stages is in OpenAI's cookbook repository.
Start with six kinds of scenario, from OpenAI's list:
- Direct answer: the answer is already in the context; no delegation, no tool.
- Required action: the right function, exact arguments, one execution, the expected saved state.
- Correction: a detail changes mid-request; the task follows the latest one.
- Missing information: the agent asks instead of guessing.
- Forbidden action: the refusal holds, and the record proves nothing happened.
- Audio conditions: hesitation, interruption, background speech, accents, phone audio.
What it costs
The price lines, as OpenAI's GPT-Live-1.1 model page states them in December 2026:
The model page adds that the lower standby rate applies to WebRTC sessions while inference is paused, and the pricing page that sessions are billed per second. Active time includes silence before the idle timeout and time spent waiting for backend work. Muting the microphone leaves the session active.
Priced with those lines, OpenAI's recorded 42-second booking call comes to about four cents:
- Voice: 42 seconds at $0.05 a minute is $0.035.
- Backend: at
gpt-5.6-terra's standard rates of $2.00 per million input tokens and $12.00 per million output tokens, 2,374 input tokens and 105 output tokens come to about $0.006, before any cache discount. - Total: about $0.041.
A hosted web search adds $10.00 per 1,000 calls plus its content tokens at the model's rates. For a phone line with idle time, transport and per-call budgets, see what GPT-Live costs per phone call.
OpenAI's cost guide makes one point worth testing on your own calls: a larger backend model can cost less overall when it finishes the task sooner, because every minute saved is a minute of voice not billed. Compare cost per successful task, failed attempts included.
Where it stops
- No images at the voice. GPT-Live takes text and audio. To discuss a photo or a screen, send the image to a vision-capable backend.
- No structured outputs. The model page lists function calling as supported and structured outputs as not supported.
- No turn events. There is no event marking a finished turn, and on WebSocket no output-audio-done event. Track playback in your audio player.
- No guaranteed greeting. A developer message in
session.inputimproves the odds that GPT-Live opens the call, but does not guarantee it. For exact wording, play a recorded clip through your app. - Moderation can cut in. Some moderation events end the session; others cut off the rest of the current reply with an
errorevent. - Concurrency is per model. GPT-Live-1.1 and GPT-Live-1 have separate concurrent-session limits; check your organization's limits page.
Can I build a GPT-Live app without delegation?
Yes. The first build prompt in OpenAI's course is a simple gpt-live-1.1 voice app over WebRTC without delegation. Note that leaving delegation out, or setting it to null, selects client mode.
Should a server use WebRTC or a WebSocket?
OpenAI recommends WebRTC for browser, mobile and server applications, including server-to-server. A WebSocket is supported when your server already handles raw PCM or G.711 audio and can do its own buffering and playback tracking.
Can I change the voice or the model during a call?
No. The voice model, the voice, the startup instructions, the WebSocket audio format and the delegation mode are fixed at startup. Start a new session to change them. The Responses backend's settings can change mid-call with session.update.
Does muting the microphone stop the bill?
No. Muting input leaves the session active. To pay the lower rate during quiet stretches, use standby on WebRTC. To stop paying, close the session and collect its final usage.
Where to go next
OpenAI's GPT-Live training runs to eight lessons, including Decisions delegation and a client-delegation restaurant agent, each with a ready prompt to build it with Codex. The OpenAI Live Console is a local sample with read-only tools and both delegation modes; it targets gpt-live-1 and is offered as-is.
If you are still choosing a stack, compare the platforms that host this for you in the best AI voice agent platforms. For Google's side of the same problem, see building a voice agent with the Gemini Live API and changing an agent's rules mid-conversation with the Gemini Interactions API. If you would rather not run the sideband and tool loop yourself, see how Vapi handles a voice-agent build.
10 best AI voice agent platforms in 2026
The platforms that host a voice agent for you, and the real per-minute cost.
- Published
- Category
- Build








