Skip to content

fix: migrate OpenAI realtime websocket to GA#1005

Merged
milovate merged 2 commits into
masterfrom
fix/openai-realtime-ga
Jun 13, 2026
Merged

fix: migrate OpenAI realtime websocket to GA#1005
milovate merged 2 commits into
masterfrom
fix/openai-realtime-ga

Conversation

@milovate

@milovate milovate commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator
  • OpenAI rejected Realtime websocket connections that still sent the beta negotiation header, and the old flat session/event shape could fail after the connection moved to the GA interface.

  • Remove the beta header, send the session audio config in the GA shape, and keep legacy event names alongside GA names so existing streaming and Twilio paths continue to work.

https://developers.openai.com/api/docs/guides/realtime#beta-to-ga-migration

Q/A checklist

  • I have tested my UI changes on mobile and they look acceptable
  • I have tested changes to the workflows in both the API and the UI
  • I have done a code review of my changes and looked at each line of the diff + the references of each function I have changed
  • My changes have not increased the import time of the server
How to check import time?

time python -c 'import server'

You can visualize this using tuna:

python3 -X importtime -c 'import server' 2> out.log && tuna out.log

To measure import time for a specific library:

$ time python -c 'import pandas'

________________________________________________________
Executed in    1.15 secs    fish           external
   usr time    2.22 secs   86.00 micros    2.22 secs
   sys time    0.72 secs  613.00 micros    0.72 secs

To reduce import times, import libraries that take a long time inside the functions that use them instead of at the top of the file:

def my_function():
    import pandas as pd
    ...

Legal Boilerplate

Look, I get it. The entity doing business as “Gooey.AI” and/or “Dara.network” was incorporated in the State of Delaware in 2020 as Dara Network Inc. and is gonna need some rights from me in order to utilize my contributions in this PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Dara Network Inc can use, modify, copy, and redistribute my contributions, under its choice of terms.

- OpenAI rejected Realtime websocket connections that still sent the beta negotiation header, and the old flat session/event shape could fail after the connection moved to the GA interface.

- Remove the beta header, send the session audio config in the GA shape, and keep legacy event names alongside GA names so existing streaming and Twilio paths continue to work.

Co-authored-by: Cursor <cursoragent@cursor.com>
@milovate

Copy link
Copy Markdown
Collaborator Author

@codex review

@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 32af3399-e6c2-4965-a3c6-0a81f23966f1

📥 Commits

Reviewing files that changed from the base of the PR and between a361848 and 1dba329.

📒 Files selected for processing (2)
  • daras_ai_v2/language_model.py
  • daras_ai_v2/language_model_openai_audio.py
💤 Files with no reviewable changes (2)
  • daras_ai_v2/language_model.py
  • daras_ai_v2/language_model_openai_audio.py

📝 Walkthrough

Walkthrough

This PR updates the OpenAI realtime integration to conform to a newer API schema. Audio format initialization switches from g711_ulaw to audio/pcmu (PCM u-law). The session configuration is restructured to nest audio settings under an audio object with input and output configuration. Event type names are updated throughout—matching and dispatching on response.output_audio_transcript.delta, response.output_text.delta, and response.output_audio.delta instead of the older event type names. These changes are made in the audio module's session initialization and streaming logic, plus the realtime session's event dispatcher.

Suggested reviewers

  • devxpy
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: migrating OpenAI realtime websocket to GA, which aligns with the primary objectives of removing the beta header and updating to the GA payload format.
Description check ✅ Passed The description provides context about the migration (beta header removal, GA payload shape, legacy event name preservation) and includes the required Q/A checklist and legal boilerplate, though all checklist items remain unchecked.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: a361848156

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@milovate milovate requested a review from devxpy June 12, 2026 17:52
@milovate milovate self-assigned this Jun 12, 2026

@devxpy devxpy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — the beta→GA migration matches OpenAI's official migration guide (beta header removed, session.type: "realtime", nested audio.input/audio.output, audio/pcmu format objects, and the response.output_* event renames). Verified the migration is complete across the codebase (no lingering old event names or beta header), and CI is green.

One follow-up (non-blocking): we should stop accepting temperature in run_openai_audio. GA removed temperature as a model parameter, so it's correctly gone from the session payload — but run_openai_audio still clamps it to the old beta range (0.6, 1.2) and threads it into init_ws_session, which no longer uses it. It's now dead plumbing. Recommend dropping the clamp and the temperature param from init_ws_session (and the temperature= kwarg at the call site in language_model.py) so it's clear the value is intentionally not sent.

Realtime GA session setup does not use chat temperature; drop the unused
param and clamp logic from the audio websocket flow.

Co-authored-by: Cursor <cursoragent@cursor.com>
@milovate milovate merged commit 1a1e0d7 into master Jun 13, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants