Skip to main content

ClientEvent

Enum ClientEvent 

Source
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.

Fields

§event_id: Option<String>
§

ConversationItemCreate

Add a new item to the conversation.

Fields

§event_id: Option<String>
§previous_item_id: Option<String>
§

ConversationItemDelete

Remove an item from the conversation history.

Fields

§item_id: String
§event_id: Option<String>
§

ConversationItemRetrieve

Retrieve the server’s representation of a conversation item.

Fields

§item_id: String
§event_id: Option<String>
§

ConversationItemTruncate

Truncate a previous assistant message’s audio.

Fields

§audio_end_ms: u32
§content_index: u32
§item_id: String
§event_id: Option<String>
§

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.

Fields

§audio: String
§event_id: Option<String>
§

InputAudioBufferClear

Clear the input audio buffer.

Fields

§event_id: Option<String>
§

InputAudioBufferCommit

Commit the input audio buffer as a user message.

Fields

§event_id: Option<String>
§

OutputAudioBufferClear

Cut off the current audio response.

Fields

§event_id: Option<String>
§

ResponseCancel

Cancel an in-progress response.

Fields

§event_id: Option<String>
§response_id: Option<String>
§

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

Source

pub fn session_update(event_id: Option<String>, session: SessionConfig) -> Self

Build a session.update event.

Source

pub fn conversation_item_create( event_id: Option<String>, previous_item_id: Option<String>, item: RealtimeConversationItem, ) -> Self

Build a conversation.item.create event.

Source

pub fn conversation_item_delete( event_id: Option<String>, item_id: impl Into<String>, ) -> Self

Build a conversation.item.delete event.

Source

pub fn conversation_item_retrieve( event_id: Option<String>, item_id: impl Into<String>, ) -> Self

Build a conversation.item.retrieve event.

Source

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.

Source

pub fn input_audio_buffer_append( event_id: Option<String>, audio: impl Into<String>, ) -> Self

Build an input_audio_buffer.append event.

Source

pub fn input_audio_buffer_clear(event_id: Option<String>) -> Self

Build an input_audio_buffer.clear event.

Source

pub fn input_audio_buffer_commit(event_id: Option<String>) -> Self

Build an input_audio_buffer.commit event.

Source

pub fn output_audio_buffer_clear(event_id: Option<String>) -> Self

Build an output_audio_buffer.clear event.

Source

pub fn response_cancel( event_id: Option<String>, response_id: Option<String>, ) -> Self

Build a response.cancel event.

Source

pub fn response_create( event_id: Option<String>, response: Option<RealtimeResponseCreateParams>, ) -> Self

Build a response.create event.

Source§

impl ClientEvent

Source

pub fn event_type(&self) -> &str

Returns the event type string (e.g. "session.update").

For unknown events, returns "unknown".

Source

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

Source§

fn clone(&self) -> ClientEvent

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ClientEvent

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for ClientEvent

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for ClientEvent

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,