Skip to content

Realtime API Pydantic Models incomplete for RealtimeResponseStatus type #2502

@bml1g12

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

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