Getting "Invalid SDP offer" from Realtime API

We started getting this error when creating a Realtime WebRTC connection this week:

{"error": {"code": "invalid_offer", "message": "Invalid SDP offer. Please try again with a WHIP-compliant offer.", "param": null, "type": "invalid_request_error"}}

It seems to be upset that we start off with no media streams and only a data channel. This used to work just fine though, and we want to start off with just a data channel for text chat and only open a voice connection if the user chooses to.

Has anyone else ran into this?

I’m encountering the same issue when creating a WebRTC connection with the OpenAI Realtime API:

OperationError: Failed to execute 'setRemoteDescription' on 'RTCPeerConnection':  
Failed to parse SessionDescription.  
{"error":{"message":"Invalid SDP offer. Please try again with a WHIP-compliant offer.",  
"type":"invalid_request_error","param":null,"code":"invalid_offer"}}  

Setup Details:

  • Using the OpenAI Realtime API beta client with React (18.x).
  • Implemented a relay server based on OpenAI’s documentation.

What I’ve Tried:

  1. Verified API key and relay server setup.
  2. Checked SDP offer format for WHIP compliance.
  3. Updated to the latest API client version.

Questions:

  1. What are the WHIP-compliance requirements for SDP offers?
  2. Any known issues or debugging tips for SDP validation?

Any insights would be appreciated—thanks!

@billzabob or @geenathweer1 , Did you find a solution for this?

We have been working on a project for a few weeks then , suddenly this morning everything stopped working. our SDP offers are coming back null form the ICE candidate.

This would be (probably) irrelevant to the above posts.

Even when the handshakes are operable, null responses are expected. If there is nothing available you need a TURN server.

@RonaldGRuckus

We tried this as well. Perhaps I am referencing the issue incorrectly.

You are correct in that the SDP is successful, which shows the SDP details in the [LOG] [startAgent] Answer SDP received: v=0… SDP details

but then this happens:

[LOG] [startAgent] Setting remote description with answer…
logger.js:14 [LOG] [pc.iceconnectionstatechange] ICE connection state: checking
logger.js:14 [LOG] [ontrack] Received track event: RTCTrackEvent {isTrusted: true, receiver: RTCRtpReceiver, track: MediaStreamTrack, streams: Array(1), transceiver: RTCRtpTransceiver, …}
logger.js:14 [LOG] [ontrack] Audio element created, source set to incoming track.
logger.js:14 [LOG] [startAgent] Remote description set successfully.
logger.js:14 [LOG] [updateButtonVisibility] Updating button visibility for status: running
logger.js:14 [LOG] [startTimer] Starting agent run timer…
logger.js:14 [LOG] [startAgent] WebRTC agent started successfully.
logger.js:14 [LOG] [pc.connectionstatechange] Connection state: connecting
logger.js:14 [LOG] [pc.iceconnectionstatechange] ICE connection state: disconnected
logger.js:15 [WARN] [pc.iceconnectionstatechange] ICE connection failed or disconnected. Potential network issues.
console.warn @ logger.js:15
(anonymous) @ webrtcAgent.js:56Understand this warningAI
logger.js:14 [LOG] [pc.connectionstatechange] Connection state: failed
logger.js:16 [ERROR] [pc.connectionstatechange] RTCPeerConnection failed. Will attempt to stop agent.
console.error @ logger.js:16
(anonymous) @ webrtcAgent.js:63Understand this errorAI
logger.js:14 [LOG] [doFinalStopAgent] Finalizing stop of the agent…
logger.js:14 [LOG] [doFinalStopAgent] Closing data channel…
logger.js:14 [LOG] [doFinalStopAgent] Closing peer connection…

Are you using the OpenAI WebRTC library?

The logging information doesn’t have enough technical details to debug.

@RonaldGRuckus

I am following OpenAI’s documentation on the site and built it off of this:

Solution:

I ran into the same “Invalid SDP offer” issue when using the Realtime API. In my setup, I was using a relay server to (1) request the ephemeral token from OpenAI and (2) forward the SDP offer/answer. That caused the error:

{"error": {"message":"Invalid SDP offer. Please try again with a WHIP-compliant offer.","type":"invalid_request_error","param":null,"code":"invalid_offer"}}

How I Fixed It:

  1. Use the Relay Server Only for Ephemeral Token
    I changed my relay server so it only handles retrieving the ephemeral token from OpenAI:
// Relay server (simplified example)
// 1. Receive request from frontend
// 2. Use your OpenAI API key to call the ephemeral token endpoint
// 3. Return the ephemeral token to frontend
  1. Send SDP Offers Directly to OpenAI from the Frontend
    Once I received the ephemeral token in my frontend, I sent the SDP offer directly to:
https://api.openai.com/v1/realtime

with the ephemeral token for authentication. This got rid of the “Invalid SDP offer” error.

By separating the two steps—(a) retrieving the ephemeral token via the relay server, then (b) sending the actual offer from the client to OpenAI—my WebRTC session now starts correctly.

1 Like