Skip to content
,

OpenAI Realtime API Guide (November 2026): Python Voice Agent with gpt-realtime-2.1, GPT-Live, WebRTC and SIP

9–14 minutes
Stressed woman beside gaming PCs holding an OpenAI logo card, hook $0.05 a minute voice agents

OpenAI’s voice stack changed a lot in 2026. The Realtime API now runs gpt-realtime-2.1, a new Live API with gpt-live-1 went GA in September, and older realtime models shut down on January 20, 2027.

This guide shows you which model to pick, how WebRTC, WebSocket and SIP differ, what it costs per minute, and how to build a working voice agent in Python. Everything is checked against OpenAI’s docs as of November 9, 2026.

TLDR

  • Best Realtime model: gpt-realtime-2.1 (128K context, reasoning, tools). Cheap option: gpt-realtime-2.1-mini.
  • New option: GPT-Live (gpt-live-1) at a flat $0.05 per minute, billed per second, plus backend model costs.
  • Transports: WebRTC for browsers and apps, WebSocket for servers, SIP for phone calls.
  • Price: audio is $32 per 1M input tokens and $64 per 1M output tokens on gpt-realtime-2.1.
  • Migrate now: gpt-realtime and gpt-realtime-mini shut down on January 20, 2027.

What the OpenAI Realtime API Does

The Realtime API lets a model listen and talk back in one step. You stream microphone audio in and get spoken audio out, with no separate speech-to-text and text-to-speech stages.

That single step is what makes voice agents feel natural. Key features include:

  • Speech to speech: audio in, audio out, with low delay.
  • Interruptions: the user can cut in, and the model stops and listens.
  • Turn detection: semantic_vad guesses when the user has finished speaking.
  • Tool calls: the model can call your functions mid-conversation, such as “look up order”.
  • Image input: gpt-realtime-2.1 also accepts images, like a photo of a broken part.

Current Realtime Model Names (November 2026)

On July 6, 2026 OpenAI released gpt-realtime-2.1 and gpt-realtime-2.1-mini. OpenAI says the update cut p95 latency by at least 25% and improved number and letter recognition, noise handling and interruptions.

Model Status Best for
gpt-realtime-2.1 Current flagship Support agents, complex tool use
gpt-realtime-2.1-mini Current low-cost model High volume, simple flows
gpt-live-1 GA since Sep 10, 2026 (Live API) Natural, full-duplex conversation
gpt-realtime-2 Previous version Existing apps (move to 2.1)
gpt-realtime-1.5 Older, not on the shutdown list Legacy apps
gpt-realtime, gpt-realtime-mini Shut down Jan 20, 2027 Migrate to the 2.1 models

Key specs of gpt-realtime-2.1

  • Context window: 128,000 tokens. Max output: 32,000 tokens.
  • Input: text, audio and image. Output: text and audio.
  • Reasoning: configurable reasoning effort. Higher effort adds delay and output tokens.
  • Function calling: supported. Structured outputs and fine-tuning are not.
  • Knowledge cutoff: September 30, 2024.

Warning: OpenAI’s deprecations page lists gpt-realtime and gpt-realtime-mini (and the older gpt-4o realtime models) for shutdown on January 20, 2027. The old tts-1 and gpt-4o-mini-tts models shut down on January 6, 2027.

Realtime API vs GPT-Live: Which One?

GPT-Live is a separate API at /v1/live/sessions. OpenAI calls gpt-live-1 its “premier model for natural, expressive voice conversations”. It is full duplex, which means it can listen and speak at the same time.

The big design difference is delegation. GPT-Live handles the talking, and hands harder thinking and tool work to a backend model, either your own code or the Responses API.

Feature Realtime API GPT-Live
Endpoint /v1/realtime /v1/live/sessions
Model gpt-realtime-2.1 / 2.1-mini gpt-live-1
Billing Per token $0.05 per minute, billed per second, plus backend usage
Image input Yes (2.1) No
Reasoning and tools Inside the voice model Delegated to a backend agent
Rate limit style Requests and tokens per minute Concurrent sessions (50 / 300 / 500 by tier)
Voice change Before first audio only Set at session start
Quick answer: pick gpt-realtime-2.1 if you want one model that hears, thinks and calls tools with token billing. Pick GPT-Live if you want the most natural talking feel and a simple per-minute price for the voice layer.

The two APIs use different event names, so do not mix code between them. The rest of this guide focuses on the Realtime API, with GPT-Live notes where they matter.

WebRTC vs WebSocket vs SIP

You can reach the Realtime API in three ways. The right one depends on where the audio comes from.

Transport Use it for How audio flows
WebRTC Browsers and mobile apps Media track for audio, a data channel for JSON events
WebSocket Server-to-server, backends, testing You send and receive Base64 audio chunks in JSON
SIP Phone calls via a SIP trunk OpenAI answers the call; you control it by webhook
  • WebRTC: OpenAI recommends it over WebSocket for anything client-side. It handles jitter and packet loss for you.
  • WebSocket: OpenAI calls it “perhaps the lowest-level interface”. You manage audio buffers yourself, which is fine on a server.
  • SIP: connect a provider like a phone carrier to sip.api.openai.com. Since November 2, 2026, outbound SIP calls are also open to all organizations through the Live API.

Note: never put your standard API key in a browser or app. For WebRTC, your server either forwards the SDP offer or mints a short-lived client secret.

Realtime API Voices

The Realtime API has ten built-in voices. OpenAI recommends marin or cedar for the best quality.

  • Full list: alloy, ash, ballad, coral, echo, sage, shimmer, verse, marin, cedar.
  • Locked after first audio: once the model speaks in a session, you cannot change the voice.
  • GPT-Live voices: the Live guide lists 21 voices across English, Portuguese, German, French, Hindi, Japanese and Korean, and it defaults to marin. Nine were added on October 16, 2026.
  • Prompt-to-voice: since October 16, 2026, all API customers can design a custom voice from a text description through /v1/audio/voices.

Realtime API Pricing per Token and per Minute

The Realtime API bills by token, with separate rates for text, audio and images. These are OpenAI’s list prices per 1 million tokens:

Model Audio in Cached audio in Audio out Text in Text out
gpt-realtime-2.1 $32.00 $0.40 $64.00 $4.00 $24.00
gpt-realtime-2.1-mini $10.00 $0.30 $20.00 $0.60 $2.40
gpt-live-1 $0.05 per minute of session, billed per second, plus backend model and tool costs

What a minute of voice costs

Independent estimates (Cekura, prices checked October 26, 2026) put one minute of caller audio at about $0.019 and one minute of agent speech at about $0.077 on gpt-realtime-2.1.

  • gpt-realtime-2.1, 5-minute call: about $0.18 per minute without caching, about $0.066 with caching.
  • gpt-realtime-2.1-mini, 5-minute call: about $0.052 per minute without caching, about $0.021 with caching.
  • Long calls cost more per minute: each turn re-reads the growing conversation, so caching matters a lot.

These estimates leave out reasoning and text tokens, so treat them as a floor. For how caching works across providers, see my prompt caching guide, and for all other OpenAI rates see OpenAI API pricing.

Tip: Keep system instructions stable at the top of the session. Stable early tokens are what get cached, and cached audio input is 80 times cheaper than fresh audio input on gpt-realtime-2.1.

Python Quickstart: Your First Realtime Session

Start with a text-only test. It proves your key, model and events work before you add audio.

  1. Install the SDK. Run pip install openai in a fresh virtual environment.
  2. Set your key. Export OPENAI_API_KEY in your shell. Realtime is not available on the free API tier.
  3. Save the script below as realtime_test.py.
  4. Run it with python realtime_test.py. You should see the reply stream in as text.
  5. Switch to audio by setting output_modalities to ["audio"] and handling audio delta events.
import asyncio
from openai import AsyncOpenAI

async def main():
    client = AsyncOpenAI()
    async with client.realtime.connect(model="gpt-realtime-2.1") as conn:
        await conn.session.update(session={
            "type": "realtime",
            "output_modalities": ["text"],
            "instructions": "You are a friendly support agent. Keep answers short.",
        })
        await conn.conversation.item.create(item={
            "type": "message",
            "role": "user",
            "content": [{"type": "input_text", "text": "What are your opening hours?"}],
        })
        await conn.response.create()

        async for event in conn:
            if event.type == "response.output_text.delta":
                print(event.delta, end="", flush=True)
            elif event.type == "response.done":
                break
            elif event.type == "error":
                print(event.error)
                break

asyncio.run(main())

Turning on audio

For voice, set an audio format and voice in session.update. OpenAI’s guide uses 24 kHz mono PCM:

{
  "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", "rate": 24000},
        "voice": "marin"
      }
    }
  }
}

Over WebSocket, the raw URL is wss://api.openai.com/v1/realtime?model=gpt-realtime-2.1 with an Authorization: Bearer header. The first event you get back is session.created.

Browser Voice with WebRTC (Python Backend)

For a web page, the browser talks to OpenAI directly over WebRTC. Your Python server only hands out a short-lived client secret.

  1. Create a token route. Your server calls /v1/realtime/client_secrets with your real key and returns the result.
  2. Fetch the token in the browser. The short-lived key is in the value field.
  3. Open a peer connection. Add the microphone track and a data channel named oai-events.
  4. Send the SDP offer to https://api.openai.com/v1/realtime/calls with the short-lived key.
  5. Apply the answer with setRemoteDescription and play the remote audio track.

Here is a minimal token route with FastAPI and httpx:

import os
import httpx
from fastapi import FastAPI

app = FastAPI()

SESSION = {
    "session": {
        "type": "realtime",
        "model": "gpt-realtime-2.1",
        "audio": {"output": {"voice": "marin"}},
    }
}

@app.get("/token")
async def token():
    async with httpx.AsyncClient() as http:
        r = await http.post(
            "https://api.openai.com/v1/realtime/client_secrets",
            headers={"Authorization": f"Bearer {os.environ['OPENAI_API_KEY']}"},
            json=SESSION,
        )
    return r.json()

OpenAI also offers a “unified” path where your server forwards the browser’s SDP offer to /v1/realtime/calls itself. It is simpler and faster to connect, but your server sits in the setup path.

Voice Agents with the OpenAI Agents SDK

If you want handoffs, tools and guardrails without writing the event loop yourself, use the Agents SDK. It wraps the Realtime API in a RealtimeAgent and a RealtimeRunner.

import asyncio
from agents.realtime import RealtimeAgent, RealtimeRunner

agent = RealtimeAgent(
    name="Assistant",
    instructions="You are a helpful voice assistant. Keep replies short.",
)

async def main():
    runner = RealtimeRunner(
        starting_agent=agent,
        config={
            "model_settings": {
                "model_name": "gpt-realtime-2.1",
                "audio": {
                    "input": {
                        "format": "pcm16",
                        "transcription": {"model": "gpt-4o-mini-transcribe"},
                        "turn_detection": {"type": "semantic_vad", "interrupt_response": True},
                    },
                    "output": {"format": "pcm16", "voice": "ash"},
                },
            }
        },
    )
    session = await runner.run()
    async with session:
        await session.send_message("Say hello in one short sentence.")
        async for event in session:
            if event.type == "audio":
                pass  # send event.audio to your speaker
            elif event.type == "history_added":
                print(event.item)
            elif event.type == "agent_end":
                break
            elif event.type == "error":
                print(event.error)

asyncio.run(main())

Install it with pip install openai-agents. The SDK repo has full microphone and speaker examples in examples/realtime.

Note: the SDK quickstart still uses gpt-4o-mini-transcribe for transcripts, but that model shuts down on February 26, 2027. OpenAI’s suggested replacements are gpt-live-transcribe (streaming) or gpt-transcribe.

For agents beyond voice, see my OpenAI Agents SDK guide, and for plain text calls the OpenAI API Python tutorial.

Phone Calls with SIP

SIP lets callers dial a normal phone number and talk to your agent. OpenAI answers the audio, and your server decides what the agent does.

  1. Find your project ID. It starts with proj_ and is on Project > General in the platform settings.
  2. Point your SIP trunk at sip:PROJECT_ID@sip.api.openai.com;transport=tls.
  3. Add a webhook under Project > Webhooks. OpenAI sends a realtime.call.incoming event with a call_id.
  4. Accept the call with a POST to /v1/realtime/calls/CALL_ID/accept, including the model, instructions, voice and tools.
  5. Monitor the call over WebSocket at wss://api.openai.com/v1/realtime?call_id=CALL_ID. Do not pass model there.

Troubleshooting: Common Problems and Fixes

  • Model not found: check the exact name, such as gpt-realtime-2.1. Realtime is not available on the free API tier.
  • Old code breaks: the beta header OpenAI-Beta: realtime=v1 stopped working on May 12, 2026. Move to the GA event names and the "type": "realtime" session field.
  • Voice will not change: set the voice before the first audio. After that it is locked for the session.
  • Agent talks over the user: use semantic_vad and make sure your player stops playback when the user starts speaking.
  • Robotic or fast audio: your sample rate does not match. Send and play 24 kHz mono PCM.
  • Bills higher than expected: long calls re-read the history. Keep instructions stable for caching, trim old turns and try the mini model.
  • Too many sessions error: GPT-Live limits concurrent sessions by tier (50, 300 or 500). Queue new calls or ask for a higher tier.

Frequently Asked Questions

What is the latest OpenAI Realtime model?

As of November 2026 it is gpt-realtime-2.1, with gpt-realtime-2.1-mini as the cheaper option. Both were released on July 6, 2026.

How much does the OpenAI Realtime API cost per minute?

Independent estimates put gpt-realtime-2.1 at roughly $0.07 to $0.18 per minute for a short call, depending on caching. GPT-Live costs a flat $0.05 per minute plus backend usage.

Should I use WebRTC or WebSocket?

Use WebRTC for browsers and mobile apps, as OpenAI recommends. Use WebSocket for server-side code where you control the audio buffers.

What is the difference between gpt-realtime and GPT-Live?

gpt-realtime models do the listening, thinking and talking in one model with token billing. GPT-Live focuses on natural full-duplex talk and hands reasoning and tools to a backend model.

Which voice should I use?

OpenAI recommends marin or cedar for the best quality on the Realtime API. GPT-Live has its own set of 21 voices and defaults to marin.

Can the Realtime API make phone calls?

Yes. It can answer calls through SIP, and since November 2, 2026 outbound SIP calling is open to all organizations through the Live API.

When does gpt-realtime shut down?

The original gpt-realtime and gpt-realtime-mini models shut down on January 20, 2027. OpenAI recommends moving to gpt-realtime-2.1 and gpt-realtime-2.1-mini.

Sources

Free weekly email

Get new AI guides every week

One short weekly email with our newest local AI, ComfyUI and AI tool guides. No spam, no pop-ups, just the good stuff.

Free. Unsubscribe anytime in one click. We only use your email to send this newsletter. See our privacy policy.

Stressed woman beside gaming PCs holding an OpenAI logo card, hook $0.05 a minute voice agents