Realtime - mismatching event type for audio transcript event
Confirm this is an issue with the Python library and not an underlying OpenAI API
- [x] This is an issue with the Python library
Describe the bug
I receive an event with type response.audio_transcript.done but the ResponseAudioTranscriptDoneEvent type field expects the type to be set to response.output_audio_transcript.done.
# event_data is a dict
if event_data.type == "response.audio_transcript.done":
ResponseAudioTranscriptDoneEvent.model_validate(event)
Raises this exception:
pydantic_core._pydantic_core.ValidationError: 1 validation error for ResponseAudioTranscriptDoneEvent
type
Input should be 'response.output_audio_transcript.done' [type=literal_error, input_value='response.audio_transcript.done', input_type=str]
For further information visit https://errors.pydantic.dev/2.12/v/literal_error
Note: I am not 100% sure if this is a problem with the Python SDK or with the Realtime API (there is no response.audio_transcript.done in the documentation
To Reproduce
- Use the Realtime API
- Try to parse server events sent over data channel using pydantic
model_validate
# event_data is a Python dict coming from the peerconnection data channel
if event_data.type == "response.audio_transcript.done":
ResponseAudioTranscriptDoneEvent.model_validate(event)
Code snippets
OS
macOS
Python version
Python 3.12.9
Library version
2.5.0
Investigation Findings
Thanks for reporting this issue! I've investigated the codebase and found that this is a systematic naming discrepancy between the beta and non-beta realtime event types, not just isolated to the audio_transcript.done event.
Comparison of Event Type Literals
| Event | types/beta/realtime/ (matches API) |
types/realtime/ (spec mismatch) |
|---|---|---|
| Audio Delta | response.audio.delta |
response.output_audio.delta |
| Audio Done | response.audio.done |
response.output_audio.done |
| Audio Transcript Delta | response.audio_transcript.delta |
response.output_audio_transcript.delta |
| Audio Transcript Done | response.audio_transcript.done |
response.output_audio_transcript.done |
The beta types use the pattern response.audio* which matches what the actual Realtime API sends.
The non-beta types use the pattern response.output_audio* which doesn't match the API response.
Root Cause
Since these files are auto-generated from the OpenAPI spec (as noted in the file headers), this appears to be an issue with the OpenAPI specification for the non-beta realtime types. The spec likely contains response.output_audio* event types while the actual API returns response.audio*.
Workaround
Until this is fixed, users can import from the beta path as a temporary workaround:
# Instead of:
from openai.types.realtime import ResponseAudioTranscriptDoneEvent
# Use:
from openai.types.beta.realtime import ResponseAudioTranscriptDoneEvent
Suggested Fix
The OpenAPI spec for the non-beta realtime types needs to be updated to use the correct event type literals:
response.output_audio.delta → response.audio.delta
response.output_audio.done → response.audio.done
response.output_audio_transcript.delta → response.audio_transcript.delta
response.output_audio_transcript.done → response.audio_transcript.done
This would affect the following files when regenerated:
src/openai/types/realtime/response_audio_delta_event.py
src/openai/types/realtime/response_audio_done_event.py
src/openai/types/realtime/response_audio_transcript_delta_event.py
src/openai/types/realtime/response_audio_transcript_done_event.py
Hi, I'd like to work on this. I'll submit a PR shortly.
Thanks for reporting this. The validation error comes from passing a beta event (response.audio_transcript.done) to the GA model, which expects response.output_audio_transcript.done.
Please migrate the connection and event handlers together using the beta-to-GA guide. We’re closing this as a migration clarification; if a GA connection still emits the beta name, please share a sanitized setup and event sample.