Realtime API - WebRTC, randomly receiving no response

I absolutely love this feature and just testing it for integration into my app.

Sometimes though, no response is coming back. I talk, get all events, transcription is coming, but no audio response.

Anyone experiences this as well?

Basically just using the web based code example:

...
...
  const baseUrl = ".......api.openai.com/v1/realtime";
  const model = "gpt-4o-realtime-preview-2024-12-17";
  const sdpResponse = await fetch(`${baseUrl}?model=${model}`, {
    method: "POST",
    body: offer.sdp,
    headers: {
      Authorization: `Bearer ${EPHEMERAL_KEY}`,
      "Content-Type": "application/sdp"
    },
  });

  const sdp = await sdpResponse.text();
  console.log("sdpResponse.text()", sdp);

  const answer = {
    type: "answer",
    sdp: sdp,
  };
  await pc.setRemoteDescription(answer);

Update:

I am basically using this code:

But with model: “gpt-4o-mini-realtime-preview-2024-12-17”;

Also using same server code to get the token.

And I am updating the session to support transcriptions:

dc.addEventListener("open", () => {
  const sessionUpdate = {
    type: "session.update",
    session: {
         turn_detection: { type: "server_vad" }, // Sprachaktivitätserkennung
        input_audio_transcription: {
         model: "whisper-1", // Aktiviert die Transkription
    },
   modalities: ["text", "audio"], // UnterstĂĽtzt Text- und Audio-Modi
   }, 
};

  //  Send update to get Transkriptions
  dc.send(JSON.stringify(sessionUpdate));
});

Instructions prompt can be quite long, but as I said, sometimes it is working and suddenly stops responding, which is why I have some doubts in releasing it to my users.

I am logging all events using dc.addEventListener("message"

I receive these:

input_audio_buffer.speech_started
input_audio_buffer.speech_stopped
input_audio_buffer.committed
conversation.item.created
response.create
response.done
conversation.item.input_audio_transcription.completed (incl the transcript of my voice)

and I have this:

dc.addEventListener("error", (err) => {
  console.error("!!! Data Channel Error:", err);
});

Never gets logged.

Just randomly no audio response played. And I dont get any errors and dont how how to better debug it

Network Conditions: perfect.

Any ideas how I could debug this more sophisticated?

2 Likes

Today it looks fine again, so I suppose there is an issue with the stability of the openAI webrtc endpoint?

I am doing a POST to https://api.openai.com/v1/realtime?model=gpt-4o-mini-realtime-preview-2024-12-17

Answer looks good to me:

v=0
o=- 6263816383938019776 1735541251 IN IP4 0.0.0.0
s=-
t=0 0
a=msid-semantic:WMS*
a=fingerprint:sha-256 83:FC:5E:A6:C0:68:83:3B:66:1E:A2:5E:36:C1:7A:DE:0C:B6:E2:86:8D:BB:49:31:25:50:12:87:DF:A3:A7:92
a=extmap-allow-mixed
a=group:BUNDLE 0 1
m=audio 9 UDP/TLS/RTP/SAVPF 111 9 0 8
c=IN IP4 0.0.0.0
a=setup:active
a=mid:0
a=ice-ufrag:cXMHqOMgCUrOYWAL
a=ice-pwd:DmLdCJuivNZeCgMsdEqGCPYQmvVKfocz
a=rtcp-mux
a=rtcp-rsize
a=rtpmap:111 opus/48000/2
a=fmtp:111 minptime=10;useinbandfec=1
a=rtcp-fb:111 transport-cc
a=rtpmap:9 G722/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=extmap:3 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01
a=ssrc:1276298424 cname:realtimeapi
a=ssrc:1276298424 msid:realtimeapi audio
a=ssrc:1276298424 mslabel:realtimeapi
a=ssrc:1276298424 label:audio
a=msid:realtimeapi audio
a=sendrecv
a=candidate:3090077034 1 udp 2130706431 40.86.182.178 3478 typ host
a=candidate:3090077034 2 udp 2130706431 40.86.182.178 3478 typ host
a=end-of-candidates
m=application 9 UDP/DTLS/SCTP webrtc-datachannel
c=IN IP4 0.0.0.0
a=setup:active
a=mid:1
a=sendrecv
a=sctp-port:5000
a=ice-ufrag:cXMHqOMgCUrOYWAL
a=ice-pwd:DmLdCJuivNZeCgMsdEqGCPYQmvVKfocz

I would be just interested in how I could better debug this issue

1 Like

Ok it’s the rate limits:

gpt-4o-mini-realtime-preview-2024-12-17 → 100 RPD

I need to check the response.done event, it has an error object: realtimeEvent.response.status_details.error

Message:


Rate limit reached for gpt-4o-mini-realtime in organization org-xxx on requests per day (RPD): Limit 100, Used 100, Requested 1. Please try again in 14m24s. Visit https://platform.openai.com/account/rate-limits to learn more.

How am I supposed to use this in production? Any idea how to fix it in order to ship this to my users?

1 Like

Hi!

What’s your usage tier?
You can find the information here:
https://platform.openai.com/settings/organization/limits

Otherwise I expect limits to go up, when the real-time API gets out of preview.

1 Like

Ok thx!

@vb Is there a timeline for when I can expect it to go out of preview? Or a newsletter I can follow or something similar?

Tier 1 currently.

1 Like

You need to upgrade your rate limits.
Here are the relevant docs:

https://platform.openai.com/docs/guides/rate-limits#usage-tiers

Check the difference between the different tiers.

1 Like