Realtime API: WebSocket connection with call_id returns 404 when listening to WebRTC session from server

I’m trying to set up a server-side listener for a WebRTC Realtime session using the OpenAI Realtime API.

According to the OpenAI Realtime docs

However, every time I try this, I get:

Connection error: server rejected WebSocket connection: HTTP 404

Or in similar code on the frontend

“error”: {
“message”: “No session found for the provided call_id”,
“type”: “invalid_request_error”,
“code”: “call_id_not_found”,
“param”: “”
}

Frontend code for obtaining the CALL ID:

this.callId = sdpResponse.headers.get(“Location”)?.split(“/”).pop();
if (!this.callId) {
this.log(“⚠️ Call ID not found in response headers”);
} else {
this.log(“✅ Call started”, { callId: this.callId });
}

I’m sure the call_id is valid (taken directly from the WebRTC client’s Location header).

Is there something I’m missing in the server-side setup? Do I need an additional header or a different URL format for connecting with call_id

Hey there and welcome to the forum!

Hmmmm… node has never been my forte, but that error makes me think one of two issues might be happening:

1 - check your firewall / routing rules to ensure your server can actually be accessed and access other endpoints

2 - the url you are passing is incorrect. At least from the exact docs you linked to, it’s mentioning the endpoint is "``https://api.openai.com/v1/realtime/calls``". That may have an effect here.

It’s possible there may also be issues with the way in which you’re parsing things to collect the call ID (or even just combining the strings - idk how picky node can be but some languages get very particular about that).

Have you tried just directly pasting the id itself as a test to see if it works? If it doesn’t, it’s an endpoint / url problem. If it does, it’s a parsing problem.

Hey, thanks a lot for taking the time to reply :folded_hands:

Just to clarify a couple of points:

And yes — I already tried pasting the call_id directly to rule out any parsing problems, but I still get the same result. So it doesn’t look like a parsing issue.

Really appreciate your guidance on this!