Skip to content
Clone GPT-Live: Full-Duplex Voice Agent That Delegates — ContentBuffer guide

Clone GPT-Live: Full-Duplex Voice Agent That Delegates

K
Kodetra Technologies··11 min read Advanced

Summary

Reproduce GPT-Live's full-duplex voice and background delegation using the GA Realtime API.

Clone GPT-Live: A Full-Duplex Voice Agent That Delegates the Hard Questions

OpenAI previewed GPT-Live and GPT-Live-1 mini on July 8, 2026, and the clips took over every feed within hours. The pitch is simple and a little uncanny: a voice model that listens and speaks at the same time, handles interruptions the way a person does, and quietly hands off the genuinely hard questions to a stronger reasoning model in the background while it keeps the conversation warm. No awkward "give me a moment" dead air.

There is one catch that a lot of the excitement skipped over. GPT-Live is not in the API yet. OpenAI's own docs say it is coming and you can sign up to be notified, but as of today you cannot call it programmatically. The good news is that the two things that make GPT-Live feel magic are not new model magic at all. They are an architecture you can build right now on top of the generally available Realtime API using gpt-realtime-2.1, plus a plain function call to a stronger model like gpt-5.6.

This guide builds that architecture end to end. You will connect to the Realtime API over a WebSocket, stream microphone audio in, play the model's speech back as it arrives, let the model interrupt-and-resume like a human, and wire up a delegation tool so that when someone asks a question that needs real thinking, a background call to GPT-5.6 does the reasoning while the voice model stalls gracefully. By the end you will have a running voice agent and a clear mental model of exactly which parts GPT-Live automated for you.

Prerequisites

  • Python 3.10 or newer.
  • An OpenAI API key with Realtime access, exported as OPENAI_API_KEY.
  • A microphone and speakers (a headset avoids the model hearing itself).
  • Packages: pip install websocket-client sounddevice numpy openai. sounddevice needs PortAudio (brew install portaudio on macOS, apt install libportaudio2 on Debian/Ubuntu).
  • Comfort with WebSockets, base64, and 16-bit PCM audio. This is an advanced build.

Every API detail below (the endpoint, model IDs, event names, and the session schema) was verified against OpenAI's Realtime API docs at the time of writing. Where the docs carry both a legacy and a GA event name, the gotchas section flags it.


The two tricks behind GPT-Live

Strip away the demo polish and GPT-Live is doing exactly two things that a normal turn-based voice assistant does not.

Trick one: full duplex. A classic voice assistant is half duplex. It records you, waits for you to stop, transcribes, thinks, then speaks, and it ignores you while it is speaking. Full duplex means the audio channel is open in both directions at once. The model streams speech to you while it is still receiving audio from you, so when you cut in mid-sentence it hears you and stops. The Realtime API already gives you this: one WebSocket carries your microphone audio up and the model's audio down simultaneously, and server-side voice activity detection tells you the moment the user starts talking.

Trick two: background delegation. Fast conversational voice models are tuned for latency, not deep reasoning. GPT-Live keeps the chat responsive by recognizing when a question is actually hard, acknowledging it out loud ("good question, let me work that out"), and dispatching the real work to a heavier model. When the answer comes back it is spoken naturally. You reproduce this with a single function tool: the realtime model calls deep_reason, your code runs a normal GPT-5.6 completion, and you feed the result back into the live session.

Put those together and the realtime model becomes a conversational front end, while a stronger model sits behind it as an on-demand brain. That is the whole GPT-Live illusion.


Step 1 — Open the WebSocket

The Realtime API lives at a single WebSocket endpoint. You pass the model as a query parameter and authenticate with a bearer token in the connection headers. Server-to-server, this is a plain WebSocket connection.

import os, json, base64, threading
import numpy as np
import sounddevice as sd
from websocket import WebSocketApp

API_KEY = os.environ["OPENAI_API_KEY"]
REALTIME_URL = "wss://api.openai.com/v1/realtime?model=gpt-realtime-2.1"
SAMPLE_RATE = 24000            # Realtime API expects 24 kHz PCM16 audio

headers = [f"Authorization: Bearer {API_KEY}"]

ws_app = WebSocketApp(
    REALTIME_URL,
    header=headers,
    on_open=on_open,          # defined in later steps
    on_message=on_message,
    on_error=lambda ws, e: print("error:", e),
    on_close=lambda ws, c, m: print("closed"),
)

Two things to lock in now, because they cause most first-run failures. The audio sample rate is 24000 Hz and the wire format is 16-bit little-endian PCM, mono. If you feed the API 44.1 kHz audio or float samples, you get silence or garbled noise, not an error message. And the header is a list of raw "Key: value" strings because that is what websocket-client expects, not a dict.


Step 2 — Configure the session

As soon as the socket opens you send one session.update event. This is where you set the voice, the audio formats, turn detection, the system instructions, and the tools. Using semantic_vad for turn detection is what makes the agent feel human: instead of firing on raw silence, it uses a model to judge when you have actually finished a thought, which cuts down on the assistant talking over your pauses.

def on_open(ws):
    session = {
        "type": "session.update",
        "session": {
            "type": "realtime",
            "model": "gpt-realtime-2.1",
            "output_modalities": ["audio"],
            "audio": {
                "input": {
                    "format": {"type": "audio/pcm", "rate": 24000},
                    "turn_detection": {"type": "semantic_vad"}
                },
                "output": {
                    "format": {"type": "audio/pcm"},
                    "voice": "marin"
                }
            },
            "instructions": (
                "You are a warm, concise voice assistant. Keep replies short. "
                "For any question that needs real calculation, research, multi-step "
                "reasoning, or up-to-date facts, DO NOT guess. Call the deep_reason "
                "tool with a precise question, and say a short filler like 'let me "
                "work that out' while you wait."
            ),
            "tools": [{
                "type": "function",
                "name": "deep_reason",
                "description": "Delegate a hard question to a stronger reasoning model. Use for math, multi-step logic, planning, or anything you are unsure about.",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "question": {
                            "type": "string",
                            "description": "A self-contained version of the user's hard question."
                        }
                    },
                    "required": ["question"]
                }
            }],
            "tool_choice": "auto"
        }
    }
    ws.send(json.dumps(session))
    threading.Thread(target=mic_loop, args=(ws,), daemon=True).start()

The instructions do real work here. They are the policy that decides when the model reaches for the delegation tool versus answering from its own head. Be explicit: list the categories that must be delegated, and tell it to emit a short filler phrase so the user is never met with silence. That filler is the audible half of the GPT-Live trick.

Recommended voices are marin and cedar; the full set includes alloy, ash, ballad, coral, echo, sage, shimmer, and verse. You cannot change the voice once the model has emitted audio in a session.


Step 3 — Stream the microphone up

With semantic_vad enabled, you do not manually commit turns or trigger responses. You just keep appending audio chunks, and the server detects when the user starts and stops talking and generates a reply on its own. Each chunk is base64-encoded PCM16 sent as an input_audio_buffer.append event.

def mic_loop(ws):
    """Capture 24 kHz mono audio and stream it to the API in ~40 ms chunks."""
    blocksize = 960  # 40 ms at 24 kHz

    def callback(indata, frames, time_info, status):
        # indata is float32 in [-1, 1]; convert to little-endian PCM16
        pcm16 = (np.clip(indata[:, 0], -1.0, 1.0) * 32767).astype("<i2").tobytes()
        ws.send(json.dumps({
            "type": "input_audio_buffer.append",
            "audio": base64.b64encode(pcm16).decode("ascii")
        }))

    with sd.InputStream(samplerate=SAMPLE_RATE, channels=1,
                        dtype="float32", blocksize=blocksize,
                        callback=callback):
        threading.Event().wait()   # keep the stream alive

That is the entire upstream path. No commit, no response.create, no turn management. The server's VAD owns turn-taking, which is precisely why the conversation feels continuous rather than walkie-talkie.


Step 4 — Play the model's speech and route events

Everything the server sends arrives on on_message as JSON events. The ones that matter for a voice loop are the audio deltas (chunks of the model's speech), the speech-started signal (the user is interrupting), and response.done (which is where a function call shows up). Here is a compact router with a thread-safe playback queue.

import queue
play_q = queue.Queue()

def speaker_loop():
    with sd.OutputStream(samplerate=SAMPLE_RATE, channels=1, dtype="int16") as out:
        while True:
            chunk = play_q.get()
            if chunk is None:      # flush signal on interruption
                continue
            out.write(np.frombuffer(chunk, dtype="<i2"))

threading.Thread(target=speaker_loop, daemon=True).start()

def on_message(ws, message):
    ev = json.loads(message)
    t = ev.get("type", "")

    if t == "response.output_audio.delta":
        # GA event name. Older stacks emit "response.audio.delta".
        play_q.put(base64.b64decode(ev["delta"]))

    elif t == "input_audio_buffer.speech_started":
        # Barge-in: the user started talking, dump queued playback.
        with play_q.mutex:
            play_q.queue.clear()

    elif t == "response.done":
        for item in ev["response"].get("output", []):
            if item.get("type") == "function_call":
                handle_function_call(ws, item)

The barge-in handling is the second half of full duplex. When input_audio_buffer.speech_started fires, the user is talking over the assistant, so you clear the playback queue immediately and let the new turn take over. Without this the agent keeps babbling its old answer while you are trying to redirect it, which instantly breaks the illusion. In production you would also send conversation.item.truncate so the model's own transcript reflects that it was cut off.


Step 5 — The delegation trick

When the realtime model decides a question is hard, it emits a function_call in response.done with a name, an arguments JSON string, and a call_id. You run the real work, then return the result with a conversation.item.create event of type function_call_output carrying the same call_id, and finally send response.create so the voice model speaks the answer.

from openai import OpenAI
client = OpenAI()   # uses OPENAI_API_KEY

def deep_reason(question: str) -> str:
    """The 'stronger brain'. A normal GPT-5.6 call, run in the background."""
    r = client.responses.create(
        model="gpt-5.6",
        reasoning={"effort": "high"},
        input=[{"role": "user", "content": question}],
    )
    return r.output_text

def handle_function_call(ws, item):
    if item["name"] != "deep_reason":
        return
    args = json.loads(item["arguments"])
    print("delegating:", args["question"])

    # Runs off the socket thread so audio playback never stalls.
    def worker():
        answer = deep_reason(args["question"])
        ws.send(json.dumps({
            "type": "conversation.item.create",
            "item": {
                "type": "function_call_output",
                "call_id": item["call_id"],
                "output": json.dumps({"answer": answer})
            }
        }))
        ws.send(json.dumps({"type": "response.create"}))

    threading.Thread(target=worker, daemon=True).start()

Run the delegation on its own thread. If you block the WebSocket thread on a multi-second GPT-5.6 call, incoming audio events pile up and playback stutters. Offloading it keeps the live channel responsive, which is what lets the model deliver its "let me work that out" filler smoothly while the heavier model thinks. The call_id is the thread that ties the answer back to the original request, so pass it through untouched.

Finally, start the whole thing:

if __name__ == "__main__":
    print("Talk to your agent. Ctrl+C to quit.")
    ws_app.run_forever()

A worked example: what a delegated turn looks like

Say you ask out loud: "If I invest 4,500 dollars a month at 7 percent annual return compounded monthly, how much will I have after 18 years?" That is a multi-step calculation, exactly the kind of thing a latency-tuned voice model should not attempt from memory. Here is the event trace you would see printed, lightly trimmed.

# You start speaking -> server VAD fires
{"type": "input_audio_buffer.speech_started"}
{"type": "input_audio_buffer.speech_stopped"}

# The realtime model decides to delegate and emits a function call
{"type": "response.done", "response": {"output": [
  {"type": "function_call", "name": "deep_reason",
   "call_id": "call_8sHlR7iaFwQ2YQOqm",
   "arguments": "{\"question\": \"Future value of $4500/month, 7% annual rate compounded monthly, over 18 years (216 deposits). Give the total.\"}"}
]}}

# Meanwhile you HEAR the agent say: "Great question, let me work that out."
delegating: Future value of $4500/month, 7% annual ...

# Your worker returns the answer to the session
{"type": "conversation.item.create", "item": {
  "type": "function_call_output", "call_id": "call_8sHlR7iaFwQ2YQOqm",
  "output": "{\"answer\": \"About $195,600. Using the annuity formula ...\"}"}}
{"type": "response.create"}

# Then you HEAR: "You'd have roughly $195,600 after 18 years."

Notice the shape of it. The realtime model never tried to do the arithmetic. It reframed your spoken question into a clean, self-contained prompt, delegated, filled the silence, and then narrated the result. Swap gpt-5.6 for a tool-using research agent and the same skeleton becomes a voice assistant that can look things up live, which is the other half of what the GPT-Live demos showed.


Common pitfalls and gotchas

The audio delta event name changed. The GA interface emits response.output_audio.delta, but older code samples and stacks still use response.audio.delta. If you hear nothing, log every event type and check which one carries your audio. Handle both to be safe.

Wrong sample rate is silent, not loud. The API wants 24 kHz PCM16 mono. Feeding 44.1 kHz or 48 kHz audio does not raise an error; it just produces noise or nothing. Set your input and output streams to 24000 explicitly and do not rely on device defaults.

The model hears itself. On laptop speakers, the mic picks up the assistant's own voice and the VAD treats it as a user interruption, so the agent talks over itself in a loop. Use a headset for testing, or add echo cancellation before you ship.

Blocking the socket thread. Any slow work (the GPT-5.6 call, disk, network) done inline on on_message freezes audio. Always offload to a worker thread, as in Step 5.

Over-delegating or under-delegating. The whole quality of the experience rides on your instructions. Too eager and every trivial "what time is it" round-trips to GPT-5.6 and feels sluggish; too shy and the model confidently makes up math. Tune the delegation policy in the instructions with concrete examples of what to hand off.

Forgetting the filler. If you do not tell the model to speak while it delegates, the user gets dead air for the two seconds GPT-5.6 is thinking, which feels broken. The spoken filler is not cosmetic; it is the thing that makes background delegation feel live.

GPT-Live itself is not callable yet. If your goal is literally the GPT-Live model over the API, it is not available at the time of writing. This architecture reproduces its behavior on shipping models. When the GPT-Live API opens, most of this code stays; you mainly swap the model ID.


Quick reference: the events that matter

EventDirectionPurpose
session.updateclient to serverSet voice, audio format, VAD, instructions, tools
input_audio_buffer.appendclient to serverStream a base64 PCM16 mic chunk
input_audio_buffer.speech_startedserver to clientUser started talking; clear playback (barge-in)
response.output_audio.deltaserver to clientA chunk of the model's spoken reply (GA name)
response.doneserver to clientTurn finished; function_call appears here
conversation.item.createclient to serverReturn function_call_output with matching call_id
response.createclient to serverAsk the model to speak after a tool result
SettingValue
WebSocket URLwss://api.openai.com/v1/realtime?model=gpt-realtime-2.1
Auth headerAuthorization: Bearer $OPENAI_API_KEY
Audio formatPCM16, 24000 Hz, mono, little-endian
Turn detectionsemantic_vad (human-like) or null to control manually
Recommended voicesmarin, cedar
Delegation modelgpt-5.6 (or any strong model / tool agent)

Next steps

  • Give deep_reason real tools: let the background GPT-5.6 call search the web or hit your database, and you have a voice research assistant.
  • Add a second tool for actions (booking, sending messages) and confirm out loud before executing, mirroring the instruction to "confirm before taking actions."
  • Log full event traces during development so you can see exactly when the model delegates and tune the policy.
  • Swap gpt-realtime-2.1 for the lighter realtime tier to cut cost on high-volume deployments, keeping GPT-5.6 only for delegated turns.
  • Sign up for GPT-Live API access so you can drop in the native model when it ships; the surrounding architecture here will carry over.

You now have the actual mechanism behind the GPT-Live demos: a fast full-duplex voice front end with a stronger model wired in as an on-demand brain. It is not a single magic model, it is a pattern, and the pattern runs today.

Comments

Subscribe to join the conversation...

Be the first to comment

Found this useful?

Get new AI guides for builders by email. Free.

Join 3,617 newsletter subscribers.

Also get