Skip to content

Realtime ResponseOutputItemDoneEvent model has incorrect type for the item field #2126

Open
@fedirz

Description

@fedirz

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

  • This is an issue with the Python library

Describe the bug

ResponseOutputItemDoneEvent doesn't support item.content[0].type to have a value of "audio" (the value returned by OpenAI's API)

Image

To Reproduce

from openai.types.beta.realtime import ConversationItem, ConversationItemContent, ResponseOutputItemDoneEvent

ResponseOutputItemDoneEvent(
    event_id="event_id",
    response_id="response_id",
    type="response.output_item.done",
    output_index=0,
    item=ConversationItem(content=[ConversationItemContent(type="audio")]),
)

Output:

Traceback (most recent call last):
  File "/home/nixos/code/speaches/src/response_output_item_done_example.py", line 8, in <module>
    item=ConversationItem(content=[ConversationItemContent(type="audio")]),
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/nixos/code/speaches/.venv/lib/python3.12/site-packages/pydantic/main.py", line 214, in __init__
    validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.ValidationError: 1 validation error for ConversationItemContent
type
  Input should be 'input_text', 'input_audio', 'item_reference' or 'text' [type=literal_error, input_value='audio', input_type=str]
    For further information visit https://errors.pydantic.dev/2.10/v/literal_error

Code snippets

OS

Linux

Python version

Python 3.12.5

Library version

openai 1.60.0

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