Skip to content

Realtime API Pydantic Models incomplete for RealtimeResponseStatus type #2502

Closed
LuminaX-alt/openai-python
#1

Description

@bml1g12

Confirm this is an issue with the Python library and not an underlying OpenAI API

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 pipecat-ai/pipecat#2106 (comment) 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:

Code snippets

OS

Linux

Python version

3.13

Library version

1.84.0

Activity

  1. bml1g12 commented on Jul 30, 2025

    @bml1g12
    Author

    hmm maybe I should make this issue in a more general place as it affects the general API too - will close it

  2. bml1g12 commented on Jul 30, 2025

    @bml1g12
    Author

    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:

  3. bml1g12 commented on Jul 31, 2025

    @bml1g12
    Author

    Thanks I have replied on the PR LuminaX-alt@4aa669c#commitcomment-163212994

  4. bml1g12 commented on Aug 7, 2025

    @bml1g12
    Author

    @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 !

  5. fscfede-beep commented on Sep 8, 2026

    @fscfede-beep

    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.

  6. fscfede-beep commented on Sep 8, 2026

    @fscfede-beep

    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.

  7. added a commit that references this issue on Oct 15, 2026
    95dbee9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingopenapi

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions