-
Notifications
You must be signed in to change notification settings - Fork 172
Description
I'm using OpenAI's Realtime API to build a voice-based assistant that integrates with Twilio calls. Everything works smoothly except for one recurring issue: after 30 minutes, I receive the following error and the session terminates:
Error from OpenAI: Your session hit the maximum duration of 30 minutes.
This happens even though I haven’t explicitly set a session timeout or expiration value.
What I'm Trying to Do
I want to automatically reinitialize a new session once the 30-minute limit is approaching, without interrupting the ongoing Twilio call.
Ideally, the assistant should seamlessly carry forward the conversation context so the user doesn’t feel the session restart.
What I’ve Tried
I’ve looked into handling this manually by tracking time and restarting the session using session.update, but I haven’t found an official way to renew or extend the session before it expires, nor a recommended pattern for reinitializing without losing state.
My Questions
Is there an official way to renew or extend the realtime session before it expires?
If not, what’s the best practice to gracefully reinitialize a new session and reinject context from the previous one?
Are there any example implementations or patterns used in production systems for handling this case?
Any guidance or examples would be greatly appreciated!
Thanks in advance 🙏