pub enum ClientEvent {
SessionUpdate {
session: Box<SessionConfig>,
event_id: Option<String>,
},
ConversationItemCreate {
item: RealtimeConversationItem,
event_id: Option<String>,
previous_item_id: Option<String>,
},
ConversationItemDelete {
item_id: String,
event_id: Option<String>,
},
ConversationItemRetrieve {
item_id: String,
event_id: Option<String>,
},
ConversationItemTruncate {
audio_end_ms: u32,
content_index: u32,
item_id: String,
event_id: Option<String>,
},
InputAudioBufferAppend {
audio: String,
event_id: Option<String>,
},
InputAudioBufferClear {
event_id: Option<String>,
},
InputAudioBufferCommit {
event_id: Option<String>,
},
OutputAudioBufferClear {
event_id: Option<String>,
},
ResponseCancel {
event_id: Option<String>,
response_id: Option<String>,
},
ResponseCreate {
event_id: Option<String>,
response: Option<Box<RealtimeResponseCreateParams>>,
},
Unknown,
}Expand description
A client-to-server event in the OpenAI Realtime API.
Sent by the client over WebSocket, WebRTC, or SIP connections.
Discriminated by the type field in the JSON wire format.
Large payloads (SessionConfig 624 B, RealtimeResponseCreateParams 384 B) are
Box-ed so the enum stays ≈224 bytes instead of ≈648.
Variants§
SessionUpdate
Update the session configuration.
ConversationItemCreate
Add a new item to the conversation.
ConversationItemDelete
Remove an item from the conversation history.
ConversationItemRetrieve
Retrieve the server’s representation of a conversation item.
ConversationItemTruncate
Truncate a previous assistant message’s audio.
InputAudioBufferAppend
Append audio bytes to the input audio buffer.
WARNING: audio contains a base64 audio blob that can be very large.
Avoid logging this variant with Debug in production; prefer
event_type() for structured logging.
InputAudioBufferClear
Clear the input audio buffer.
InputAudioBufferCommit
Commit the input audio buffer as a user message.
OutputAudioBufferClear
Cut off the current audio response.
ResponseCancel
Cancel an in-progress response.
ResponseCreate
Trigger model inference to create a response.
Unknown
Unrecognized event type. Serde automatically deserializes any
unrecognized type value into this variant (no data preserved).
For proxy use, forward the raw frame instead of re-serializing.
Implementations§
Source§impl ClientEvent
impl ClientEvent
Sourcepub fn session_update(event_id: Option<String>, session: SessionConfig) -> Self
pub fn session_update(event_id: Option<String>, session: SessionConfig) -> Self
Build a session.update event.
Sourcepub fn conversation_item_create(
event_id: Option<String>,
previous_item_id: Option<String>,
item: RealtimeConversationItem,
) -> Self
pub fn conversation_item_create( event_id: Option<String>, previous_item_id: Option<String>, item: RealtimeConversationItem, ) -> Self
Build a conversation.item.create event.
Sourcepub fn conversation_item_delete(
event_id: Option<String>,
item_id: impl Into<String>,
) -> Self
pub fn conversation_item_delete( event_id: Option<String>, item_id: impl Into<String>, ) -> Self
Build a conversation.item.delete event.
Sourcepub fn conversation_item_retrieve(
event_id: Option<String>,
item_id: impl Into<String>,
) -> Self
pub fn conversation_item_retrieve( event_id: Option<String>, item_id: impl Into<String>, ) -> Self
Build a conversation.item.retrieve event.
Sourcepub fn conversation_item_truncate(
event_id: Option<String>,
item_id: impl Into<String>,
content_index: u32,
audio_end_ms: u32,
) -> Self
pub fn conversation_item_truncate( event_id: Option<String>, item_id: impl Into<String>, content_index: u32, audio_end_ms: u32, ) -> Self
Build a conversation.item.truncate event.
Sourcepub fn input_audio_buffer_append(
event_id: Option<String>,
audio: impl Into<String>,
) -> Self
pub fn input_audio_buffer_append( event_id: Option<String>, audio: impl Into<String>, ) -> Self
Build an input_audio_buffer.append event.
Sourcepub fn input_audio_buffer_clear(event_id: Option<String>) -> Self
pub fn input_audio_buffer_clear(event_id: Option<String>) -> Self
Build an input_audio_buffer.clear event.
Sourcepub fn input_audio_buffer_commit(event_id: Option<String>) -> Self
pub fn input_audio_buffer_commit(event_id: Option<String>) -> Self
Build an input_audio_buffer.commit event.
Sourcepub fn output_audio_buffer_clear(event_id: Option<String>) -> Self
pub fn output_audio_buffer_clear(event_id: Option<String>) -> Self
Build an output_audio_buffer.clear event.
Sourcepub fn response_cancel(
event_id: Option<String>,
response_id: Option<String>,
) -> Self
pub fn response_cancel( event_id: Option<String>, response_id: Option<String>, ) -> Self
Build a response.cancel event.
Sourcepub fn response_create(
event_id: Option<String>,
response: Option<RealtimeResponseCreateParams>,
) -> Self
pub fn response_create( event_id: Option<String>, response: Option<RealtimeResponseCreateParams>, ) -> Self
Build a response.create event.
Source§impl ClientEvent
impl ClientEvent
Sourcepub fn event_type(&self) -> &str
pub fn event_type(&self) -> &str
Returns the event type string (e.g. "session.update").
For unknown events, returns "unknown".
Sourcepub fn to_event_type(&self) -> Option<RealtimeClientEvent>
pub fn to_event_type(&self) -> Option<RealtimeClientEvent>
Maps this event to its corresponding RealtimeClientEvent constant.
Returns None for Unknown events.
Trait Implementations§
Source§impl Clone for ClientEvent
impl Clone for ClientEvent
Source§fn clone(&self) -> ClientEvent
fn clone(&self) -> ClientEvent
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more