This article was drafted with AI help and reviewed by the author.
Picture a Flutter app with a talk button. Tap it, and the app opens a WebRTC connection to OpenAI's Realtime API, using a package such as flutter_webrtc, so the user can speak to an assistant. Your backend mints a short-lived client secret, and the phone uses that to connect.
Now look at OpenAI's deprecations page. Two of the older realtime IDs, gpt-realtime-mini and gpt-realtime, stop on 20 January 2027. Then gpt-realtime-2 goes on 1 June 2027. If any of those strings is compiled into your app, the fix needs a store release, and some users won't install it.
This post is about keeping that choice on the server, and about the one screen state most voice features forget. It is based on OpenAI's Realtime and WebRTC guides, the client secrets reference and the deprecations page, plus Supabase's Edge Function secrets docs, as published on 3 December 2026. Package names, table names and values below are examples.
Where the model is actually set
OpenAI's docs describe two ways for a browser or mobile client to connect. In both, your server holds the standard API key and sends the session settings. With ephemeral keys, the server asks OpenAI for a client secret and includes the session configuration, model included, in that request. The phone only receives the secret.
That means the app never needs to know the model. If it does know, it is because someone put it there.
A common way that happens: the first prototype calls a generic mint endpoint and passes the model and voice from the app, because it was quick. The prototype ships. Two releases later, the model name is in every build on every phone.
Before and after
Here is a made up before and after for the same feature.
Before
- App build 2.3.0 sends agent support, model gpt-realtime-mini, voice marin to your mint endpoint.
- The endpoint passes all three straight through to OpenAI.
- On 20 January 2027, every user on 2.3.0 gets a failed session. Users on newer builds are fine only if those builds were updated.
After
- The app sends agent support and its own app version. Nothing else.
- A Supabase Edge Function looks up the agent in a small config table and builds the session settings itself.
- The function ignores any model or voice field a client sends, including fields from older builds.
- Changing the model is a row update. Every build, old or new, gets the new model on its next tap.
A sample config row:
- agent: support
- model: gpt-realtime-2.1
- voice: marin
- enabled: true
- fallback: offer typing and a call-back request
Keep the OpenAI key as an Edge Function secret. Supabase's docs cover setting it separately for local and production, and keeping the local env file out of Git.
Short-lived means short
The client secrets reference says you can set an expiry. It also says the expiry only limits creating new sessions, and that one secret can start more than one session until it expires. A session that has already started can keep going past it.
So for a phone, mint the secret on tap, use it right away, and set a short expiry. Don't cache it in shared preferences to save a round trip. A cached secret that outlives its purpose is just a smaller version of the key problem you were avoiding.
While you are in that function, OpenAI recommends a safety identifier for apps that know who their users are. For ephemeral tokens, it goes on the server side request that creates the secret. A hashed user id from Supabase auth works.
The state your voice screen is missing
Voice screens are usually designed around connecting, live and dropped. Fewer plan for the case where a session can't be created at all. That is exactly what a retired model looks like from the phone.
Give the screen four states.
- Connecting. Spinner, with a cancel button.
- Live. The normal talking view.
- Dropped. The connection was working and then broke. Offer to reconnect.
- Voice unavailable. The server could not create a session. Don't retry in a loop. Show a plain message and the fallback from the config row, such as a text chat or a call-back request.
The Edge Function decides which one the app sees. If OpenAI refuses the session, or the agent row says enabled false, the function returns a clear unavailable response. The app maps that to state 4. Model names, OpenAI error bodies and keys stay on the server.
This also gives you a kill switch. If a new model misbehaves after a change, set enabled to false. Users see the fallback within one tap, with no release.
Changing models without a release
With the model in a table, a migration can be gradual.
- Add a second row, such as support-next, with the new model.
- In the function, send a slice of users to it. A stable rule works, such as users whose hashed id ends in 0 or 1.
- Watch your own logs for failed session starts and dropped calls, by row.
- When it looks right, change the main row and remove the extra one.
Test on real devices before widening the slice. OpenAI's guidance is to run the same requests against both models and compare. On a phone, that means speaking over the assistant mid-sentence, spelling an email address, and trying it on a weak mobile connection. A desktop browser on office Wi-Fi won't show you the problems your users will hit.
Sessions that are already live when you flip the row will most likely carry on with the settings they started with. The docs read here don't spell that out, so test it before you count on it.
Old builds still matter
Even with all of this, check what old builds send. If any shipped version talks to OpenAI with its own logic, such as a fixed session update after connecting, it may still mention a model or settings. Find the oldest build that is still active in your store console and read what it does on tap. If it can't be fixed from the server, that build needs a forced update prompt before January.
Takeaways
- The model is set by the server when it creates the session or client secret. Keep it there.
- Put the model in a config table read by an Edge Function, not in the app.
- Make the function ignore model fields sent by any client.
- Mint secrets on tap, with a short expiry, and never cache them.
- Add a voice unavailable state with a real fallback, and use the config row as a kill switch.
For the full list of retiring voice models and dates, the guide on OpenAI realtime model deprecations for voice agents has the details this post leaves out.