Skip to content

Frequent server_error from OpenAI Realtime API during active sessions #4617

@sagorbrur

Description

@sagorbrur

Bug Description

We are frequently encountering session failures while using the OpenAI Realtime model (gpt-realtime) in our voice agent pipeline. The error occurs during active realtime sessions and is logged as a realtime_model_error with an underlying server_error returned by the OpenAI Realtime API.

Error Log (Sample)

Session error occurred: 
type='realtime_model_error'
label='livekit.plugins.openai.realtime.realtime_model.RealtimeModel'
error=APIError('OpenAI Realtime API response failed with error type: server_error')
recoverable=True

We are using the following way with different types of tools in agents.py

 turn_detection = build_turn_detection(vad_type="semantic_vad", eagerness="high")
                logger.info(f"Using VAD type: {turn_detection.type} for OpenAI Realtime model")

model = openai.realtime.RealtimeModel(
    model=llm_config.model_name,
    modalities=["text"],  # Force text output only for hybrid mode
    input_audio_transcription=input_audio_transcription,
    turn_detection=turn_detection,
)

Expected Behavior

It should work properly

Reproduction Steps

Using OpenAI Realtime Model should raise this error

Operating System

ubuntu 22.04

Models Used

Deepgram, OpenAI, ElevenLab

Package Versions

livekit-agents==1.3.10

Session/Room/Call IDs

No response

Proposed Solution

Additional Context

No response

Screenshots and Recordings

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions