Realtime API Pydantic Models incomplete for RealtimeResponseStatus type
Confirm this is an issue with the Python library and not an underlying OpenAI API
- [x] This is an issue with the Python library --> It is both and I have informed the issue via https://help.openai.com/en
Describe the bug
And I have got errors like this when using latest Azure deployments of OpenAI Realtime model
{
"type": "response.done",
"event_id": "event_BvlnvdNtqw7LLGP7xDfyA",
"response": {
"object": "realtime.response",
"id": "resp_BvlnvRcuxxRLrr5FBygyo",
"status": "failed",
"status_details": {
"type": "failed",
"error": {
"type": "invalid_request_error",
"code": "inference_rate_limit_exceeded",
"message": "We're currently processing too many requests — please try again later."
}
},
"output": [],
"conversation_id": "conv_Bvlm1z1fjvrisuRsPx8hC",
"modalities": ["text", "audio"],
"voice": "sage",
"output_audio_format": "pcm16",
"temperature": 0.6,
"max_output_tokens": "inf",
"usage": {
"total_tokens": 0,
"input_tokens": 0,
"output_tokens": 0,
"input_token_details": {
"text_tokens": 0,
"audio_tokens": 0,
"cached_tokens": 0,
"cached_tokens_details": {
"text_tokens": 0,
"audio_tokens": 0
}
},
"output_token_details": {
"text_tokens": 0,
"audio_tokens": 0
}
},
"metadata": {
"client_event_id": "response_create_6448171658c7"
}
}
}
I have seen online others report errors like this: https://community.openai.com/t/realtime-api-errors-in-both-playground-and-api-calls/1007933 or here https://github.com/pipecat-ai/pipecat/issues/2106#issue-3193722974 etc.
The problem is that the pydantic model for Error is wrong - it does not include the message field (e.g. "We're currently processing too many requests — please try again later." in the above example). This seems to be the case in the API reference itself too https://platform.openai.com/docs/api-reference/realtime-server-events/response/done
A side effect of this is that pydantic validated code sometimes will omit the message which is quite helpeful for debugging.
To Reproduce
Create a response that fails to complete, e.g. due to exceeding the rate limit of your server
The issue is present even in latest code base of openai repo: https://github.com/openai/openai-python/blob/e6c6757553bbdb777c31d0daf5916fb9e2b47ff8/src/openai/types/beta/realtime/realtime_response_status.py#L11
Code snippets
OS
Linux
Python version
3.13
Library version
1.84.0
hmm maybe I should make this issue in a more general place as it affects the general API too - will close it
I contacted OpenAI via the bot on https://help.openai.com/en to report this documentation/type mismatch issue but it said it was unable to provide me updates on the progress of the bug fix, so I will keep this issue open until it is addressed. If there is a better way to track open bugs for the OpenAI API reference itself, please keep me informed and I will close this
Specifically the bot said to me
the openai/openai-openapi repository is no longer actively maintained, as you’ve noticed, and the README suggests not to open issues there. Here’s the best approach currently: API Documentation/Behavior Mismatches:
If the openai-openapi repo is not active, unfortunately there is no dedicated, public OpenAI GitHub repo for documentation or API-side bugs at this moment. Your Options: If you feel it’s causing significant confusion or breaking something, you can still point out the issue on the OpenAI Developer Forum. Staff do monitor and forward major API documentation issues reported there. If you use the openai-python GitHub repo despite the limitation, clarify in the issue description that it’s not an SDK but an API doc mismatch, and reference the lack of a better channel. Sometimes, maintainers will label and redirect such issues appropriately. Summary:
Thanks I have replied on the PR https://github.com/LuminaX-alt/openai-python/commit/4aa669cde1c26264a5f3098bc2819d1abf1682e6#commitcomment-163212994
@RobertCraigie thanks for helping get the visibility on this one, I see @LuminaX-alt has made a PR labelled as addressing this but I wanted to clarify that it is not currently fixing the issue raised for the reason explained here - are you able to make sure that gets visiblity too?
thanks !
Audited against current main: src/openai/types/beta/realtime/realtime_response_status.py still defines Error with only code and type; there is no open PR currently attached to #2502. The reported wire payload contains a human-readable message, so Pydantic drops information that users need for diagnosis.
Proposed minimal fix (generated-model compatible): add message: Optional[str] = None with the same generated-field style, then add a focused model regression that validates a failed RealtimeResponseStatus payload containing error.message and asserts the value is preserved. Also assert omission remains valid (Error(code=...) => message is None).
Correct invariant:
wire.error.message -> Error.message -> consumer
with no behavioral change when the field is absent.
I would keep this limited to the schema/model layer; no runtime exception handling or transport changes are needed. Because this file is generated, the durable fix should also update the generator/OpenAPI source (or whatever generated-source contract produces this model) rather than relying on a handwritten edit that could be overwritten.
This is intentionally a two-line semantic correction plus a regression test: low regression surface, directly tied to the public Realtime payload contract, and easy to review.
Implementation-ready patch prepared against current main: add message: Optional[str] = None to RealtimeResponseStatus.Error, preserving the wire-level human-readable error, plus regression tests for present and omitted message.
The invariant is wire.error.message -> Error.message -> consumer; absent message remains None. This is intentionally limited to schema preservation. Because the model file is generated, the durable upstream source should be updated at the generator/OpenAPI contract so regeneration reproduces the field. I did not modify the upstream repository because the integration has no write permission there.