Introduce item_reference as ConversationItem in realtime types
Confirm this is a feature request for the Python library and not the underlying OpenAI API.
- [x] This is a feature request for the Python library
Describe the feature or improvement you're requesting
Context
RealtimeResponseCreateParams in types.realtime has input parameter which is Optional[List[ConversationItem]]
Issue
Current types of ConversationItem don't include a class to create a conversation item of type item_reference, that can be used to reference previous messages in a realtime conversation, as described in https://platform.openai.com/docs/api-reference/realtime-client-events/response/create#realtime_client_events-response-create-response-input
https://github.com/openai/openai-python/blob/f94256daf8f5d7268f28c2330dc343660a959c3e/src/openai/types/realtime/conversation_item.py#L19-L30
Proposed fix
A new class like this should work:
class RealtimeConversationItemReference(BaseModel):
id: str
"""The unique ID of the conversation item."""
type: Literal["item_reference"]
"""The type of the reference. Always 'item_reference`."""
To be added in the list of possible ConversationItem
Additional context
No response
This makes sense to me. The realtime API already supports item_reference,
but the Python SDK missing it in ConversationItem makes it awkward to use
from typed code.
I can take a look at adding RealtimeConversationItemReference and wiring it
into the ConversationItem union if that would be helpful.
Hi, I’d like to work on adding item_reference support to ConversationItem in the Python SDK. Before implementing, can you confirm:
expected class name (e.g. ItemReferenceConversationItem)? fields required besides type="item_reference" and item_id? whether validation helpers or tests are preferred for this change?
Based on the example here https://platform.openai.com/docs/api-reference/realtime-client-events/response/create, I think just implementing this should be enough:
class RealtimeConversationItemReference(BaseModel):
id: str
"""The unique ID of the conversation item."""
type: Literal["item_reference"]
"""The type of the reference. Always 'item_reference`."""
Ok,can you assign this to me?
I guess this should be fixed on the OpenAPI spec itself. Created https://github.com/openai/openai-openapi/issues/514 hoping that is picked up soon.
@karpetrosyan I just noticed that you added the openapi label few weeks ago. Any idea on how long it might take to get the change in?
Thanks for flagging this and helping track down the missing type. The custom-context example uses item_reference, but the shared schema omits that variant from the generated conversation-item types.
We’re closing this report to keep the work together in openai/openai-openapi#514; the fix will continue to be tracked there. Please follow that issue for the schema correction and subsequent SDK update.