RealtimeEvent.conversationItemCreated constructor

  1. @FreezedUnionValue('conversation.item.created')
const RealtimeEvent.conversationItemCreated({
  1. @JsonKey(name: 'event_id') required String eventId,
  2. @Default(RealtimeEventType.conversationItemCreated) RealtimeEventType type,
  3. @JsonKey(name: 'previous_item_id', includeIfNull: false) String? previousItemId,
  4. required Item item,
})

Returned when a conversation item is created. There are several scenarios that produce this event:

  • The server is generating a Response, which if successful will produce either one or two Items, which will be of type message (role assistant) or type function_call.
  • The input audio buffer has been committed, either by the client or the server (in server_vad mode). The server will take the content of the input audio buffer and add it to a new user message Item.
  • The client has sent a conversation.item.create event to add a new Item to the Conversation.

Implementation

@FreezedUnionValue('conversation.item.created')
const factory RealtimeEvent.conversationItemCreated({
  /// The unique ID of the server event.
  @JsonKey(name: 'event_id') required String eventId,

  /// The type of the event.
  @Default(RealtimeEventType.conversationItemCreated) RealtimeEventType type,

  /// The ID of the preceding item in the Conversation context, allows the client to understand the
  /// order of the conversation.
  @JsonKey(name: 'previous_item_id', includeIfNull: false)
  String? previousItemId,

  /// The item to add to the conversation.
  /// Any of: [ItemMessage], [ItemFunctionCall], [ItemFunctionCallOutput]
  required Item item,
}) = RealtimeEventConversationItemCreated;