Skip to main content

ServerEvent

Enum ServerEvent 

Source
pub enum ServerEvent {
Show 47 variants SessionCreated { event_id: String, session: Box<SessionConfig>, }, SessionUpdated { event_id: String, session: Box<SessionConfig>, }, ConversationCreated { conversation: Conversation, event_id: String, }, ConversationItemCreated { event_id: String, item: RealtimeConversationItem, previous_item_id: Option<String>, }, ConversationItemAdded { event_id: String, item: RealtimeConversationItem, previous_item_id: Option<String>, }, ConversationItemDone { event_id: String, item: RealtimeConversationItem, previous_item_id: Option<String>, }, ConversationItemDeleted { event_id: String, item_id: String, }, ConversationItemRetrieved { event_id: String, item: RealtimeConversationItem, }, ConversationItemTruncated { audio_end_ms: u32, content_index: u32, event_id: String, item_id: String, }, InputAudioTranscriptionCompleted { content_index: u32, event_id: String, item_id: String, transcript: String, usage: TranscriptionUsage, logprobs: Option<Vec<LogProbProperties>>, }, InputAudioTranscriptionDelta { event_id: String, item_id: String, content_index: Option<u32>, delta: Option<String>, logprobs: Option<Vec<LogProbProperties>>, }, InputAudioTranscriptionFailed { content_index: u32, error: TranscriptionError, event_id: String, item_id: String, }, InputAudioTranscriptionSegment { id: String, content_index: u32, end: f32, event_id: String, item_id: String, speaker: String, start: f32, text: String, }, InputAudioBufferCleared { event_id: String, }, InputAudioBufferCommitted { event_id: String, item_id: String, previous_item_id: Option<String>, }, InputAudioBufferSpeechStarted { audio_start_ms: u32, event_id: String, item_id: String, }, InputAudioBufferSpeechStopped { audio_end_ms: u32, event_id: String, item_id: String, }, InputAudioBufferTimeoutTriggered { audio_end_ms: u32, audio_start_ms: u32, event_id: String, item_id: String, }, InputAudioBufferDtmfEventReceived { event: String, received_at: i64, }, OutputAudioBufferStarted { event_id: String, response_id: String, }, OutputAudioBufferStopped { event_id: String, response_id: String, }, OutputAudioBufferCleared { event_id: String, response_id: String, }, ResponseCreated { event_id: String, response: Box<RealtimeResponse>, }, ResponseDone { event_id: String, response: Box<RealtimeResponse>, }, ResponseOutputItemAdded { event_id: String, item: RealtimeConversationItem, output_index: u32, response_id: String, }, ResponseOutputItemDone { event_id: String, item: RealtimeConversationItem, output_index: u32, response_id: String, }, ResponseContentPartAdded { content_index: u32, event_id: String, item_id: String, output_index: u32, part: ResponseContentPart, response_id: String, }, ResponseContentPartDone { content_index: u32, event_id: String, item_id: String, output_index: u32, part: ResponseContentPart, response_id: String, }, ResponseOutputTextDelta { content_index: u32, delta: String, event_id: String, item_id: String, output_index: u32, response_id: String, }, ResponseOutputTextDone { content_index: u32, event_id: String, item_id: String, output_index: u32, response_id: String, text: String, }, ResponseOutputAudioDelta { content_index: u32, delta: String, event_id: String, item_id: String, output_index: u32, response_id: String, }, ResponseOutputAudioDone { content_index: u32, event_id: String, item_id: String, output_index: u32, response_id: String, }, ResponseOutputAudioTranscriptDelta { content_index: u32, delta: String, event_id: String, item_id: String, output_index: u32, response_id: String, }, ResponseOutputAudioTranscriptDone { content_index: u32, event_id: String, item_id: String, output_index: u32, response_id: String, transcript: String, }, ResponseFunctionCallArgumentsDelta { call_id: String, delta: String, event_id: String, item_id: String, output_index: u32, response_id: String, }, ResponseFunctionCallArgumentsDone { arguments: String, call_id: String, event_id: String, item_id: String, name: String, output_index: u32, response_id: String, }, ResponseMcpCallArgumentsDelta { delta: String, event_id: String, item_id: String, output_index: u32, response_id: String, obfuscation: Option<String>, }, ResponseMcpCallArgumentsDone { arguments: String, event_id: String, item_id: String, output_index: u32, response_id: String, }, ResponseMcpCallInProgress { event_id: String, item_id: String, output_index: u32, }, ResponseMcpCallCompleted { event_id: String, item_id: String, output_index: u32, }, ResponseMcpCallFailed { event_id: String, item_id: String, output_index: u32, }, McpListToolsInProgress { event_id: String, item_id: String, }, McpListToolsCompleted { event_id: String, item_id: String, }, McpListToolsFailed { event_id: String, item_id: String, }, RateLimitsUpdated { event_id: String, rate_limits: Vec<RealtimeRateLimit>, }, Error { error: RealtimeError, event_id: String, }, Unknown,
}
Expand description

A server-to-client event in the OpenAI Realtime API.

Sent by the server over WebSocket, WebRTC, or SIP connections. Discriminated by the type field in the JSON wire format.

Large payloads (SessionConfig 624 B, RealtimeResponse 352 B) are Box-ed so the enum stays ≈232 bytes instead of ≈656.

Variants§

§

SessionCreated

Emitted when a new connection is established with the default session config.

Fields

§event_id: String
§

SessionUpdated

Emitted after a successful session.update.

Fields

§event_id: String
§

ConversationCreated

Emitted when a conversation is created (right after session creation).

Fields

§conversation: Conversation
§event_id: String
§

ConversationItemCreated

Emitted when a conversation item is created (legacy event).

Fields

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

ConversationItemAdded

Emitted when an item is added to the default conversation.

Fields

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

ConversationItemDone

Emitted when a conversation item is finalized.

Fields

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

ConversationItemDeleted

Emitted when a conversation item is deleted.

Fields

§event_id: String
§item_id: String
§

ConversationItemRetrieved

Emitted in response to conversation.item.retrieve.

§

ConversationItemTruncated

Emitted when an assistant audio message item is truncated.

Fields

§audio_end_ms: u32
§content_index: u32
§event_id: String
§item_id: String
§

InputAudioTranscriptionCompleted

Emitted when input audio transcription completes.

Fields

§content_index: u32
§event_id: String
§item_id: String
§transcript: String
§

InputAudioTranscriptionDelta

Emitted with incremental transcription results.

Fields

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

InputAudioTranscriptionFailed

Emitted when input audio transcription fails.

Fields

§content_index: u32
§event_id: String
§item_id: String
§

InputAudioTranscriptionSegment

Emitted when an input audio transcription segment is identified (used with diarization models).

Fields

§content_index: u32
§end: f32
§event_id: String
§item_id: String
§speaker: String
§start: f32
§text: String
§

InputAudioBufferCleared

Emitted when the input audio buffer is cleared.

Fields

§event_id: String
§

InputAudioBufferCommitted

Emitted when the input audio buffer is committed.

Fields

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

InputAudioBufferSpeechStarted

Emitted when speech is detected in the audio buffer (server VAD mode).

Fields

§audio_start_ms: u32
§event_id: String
§item_id: String
§

InputAudioBufferSpeechStopped

Emitted when the end of speech is detected (server VAD mode).

Fields

§audio_end_ms: u32
§event_id: String
§item_id: String
§

InputAudioBufferTimeoutTriggered

Emitted when the VAD idle timeout triggers.

Fields

§audio_end_ms: u32
§audio_start_ms: u32
§event_id: String
§item_id: String
§

InputAudioBufferDtmfEventReceived

SIP Only: Emitted when a DTMF keypad event is received.

NOTE: This is the only server event without an event_id field per the OpenAI spec. Downstream code that generically extracts event_id from all server events must handle this variant as a special case.

Fields

§event: String
§received_at: i64
§

OutputAudioBufferStarted

Emitted when the server begins streaming audio to the client.

Fields

§event_id: String
§response_id: String
§

OutputAudioBufferStopped

Emitted when the output audio buffer has been completely drained.

Fields

§event_id: String
§response_id: String
§

OutputAudioBufferCleared

Emitted when the output audio buffer is cleared (user interrupt or explicit output_audio_buffer.clear).

Fields

§event_id: String
§response_id: String
§

ResponseCreated

Emitted when a new response is created (status in_progress).

Fields

§event_id: String
§

ResponseDone

Emitted when a response is done streaming.

Fields

§event_id: String
§

ResponseOutputItemAdded

Emitted when a new output item is created during response generation.

Fields

§event_id: String
§output_index: u32
§response_id: String
§

ResponseOutputItemDone

Emitted when an output item is done streaming.

Fields

§event_id: String
§output_index: u32
§response_id: String
§

ResponseContentPartAdded

Emitted when a new content part is added to an assistant message.

Fields

§content_index: u32
§event_id: String
§item_id: String
§output_index: u32
§response_id: String
§

ResponseContentPartDone

Emitted when a content part is done streaming.

Fields

§content_index: u32
§event_id: String
§item_id: String
§output_index: u32
§response_id: String
§

ResponseOutputTextDelta

Emitted when the text of an output_text content part is updated.

Fields

§content_index: u32
§delta: String
§event_id: String
§item_id: String
§output_index: u32
§response_id: String
§

ResponseOutputTextDone

Emitted when an output_text content part is done streaming.

Fields

§content_index: u32
§event_id: String
§item_id: String
§output_index: u32
§response_id: String
§text: String
§

ResponseOutputAudioDelta

Emitted when model-generated audio is updated.

WARNING: delta contains a base64 audio chunk. Avoid logging this variant with Debug in production; prefer event_type().

Fields

§content_index: u32
§delta: String
§event_id: String
§item_id: String
§output_index: u32
§response_id: String
§

ResponseOutputAudioDone

Emitted when model-generated audio is done.

Fields

§content_index: u32
§event_id: String
§item_id: String
§output_index: u32
§response_id: String
§

ResponseOutputAudioTranscriptDelta

Emitted when the transcription of audio output is updated.

Fields

§content_index: u32
§delta: String
§event_id: String
§item_id: String
§output_index: u32
§response_id: String
§

ResponseOutputAudioTranscriptDone

Emitted when the transcription of audio output is done.

Fields

§content_index: u32
§event_id: String
§item_id: String
§output_index: u32
§response_id: String
§transcript: String
§

ResponseFunctionCallArgumentsDelta

Emitted when function call arguments are updated.

Fields

§call_id: String
§delta: String
§event_id: String
§item_id: String
§output_index: u32
§response_id: String
§

ResponseFunctionCallArgumentsDone

Emitted when function call arguments are done streaming.

Fields

§arguments: String
§call_id: String
§event_id: String
§item_id: String
§name: String
§output_index: u32
§response_id: String
§

ResponseMcpCallArgumentsDelta

Emitted when MCP tool call arguments are updated.

Fields

§delta: String
§event_id: String
§item_id: String
§output_index: u32
§response_id: String
§obfuscation: Option<String>
§

ResponseMcpCallArgumentsDone

Emitted when MCP tool call arguments are finalized.

Fields

§arguments: String
§event_id: String
§item_id: String
§output_index: u32
§response_id: String
§

ResponseMcpCallInProgress

Emitted when an MCP tool call starts.

Fields

§event_id: String
§item_id: String
§output_index: u32
§

ResponseMcpCallCompleted

Emitted when an MCP tool call completes successfully.

Fields

§event_id: String
§item_id: String
§output_index: u32
§

ResponseMcpCallFailed

Emitted when an MCP tool call fails.

Fields

§event_id: String
§item_id: String
§output_index: u32
§

McpListToolsInProgress

Emitted when listing MCP tools is in progress.

Fields

§event_id: String
§item_id: String
§

McpListToolsCompleted

Emitted when listing MCP tools has completed.

Fields

§event_id: String
§item_id: String
§

McpListToolsFailed

Emitted when listing MCP tools has failed.

Fields

§event_id: String
§item_id: String
§

RateLimitsUpdated

Emitted at the beginning of a response with updated rate limit info.

Fields

§event_id: String
§rate_limits: Vec<RealtimeRateLimit>
§

Error

Emitted when an error occurs. Most errors are recoverable.

Fields

§event_id: String
§

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 ServerEvent

Source

pub fn session_created( event_id: impl Into<String>, session: SessionConfig, ) -> Self

Build a session.created event.

Source

pub fn session_updated( event_id: impl Into<String>, session: SessionConfig, ) -> Self

Build a session.updated event.

Source

pub fn conversation_created( event_id: impl Into<String>, conversation: Conversation, ) -> Self

Build a conversation.created event.

Source

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

Build a conversation.item.created event.

Source

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

Build a conversation.item.added event.

Source

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

Build a conversation.item.done event.

Source

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

Build a conversation.item.deleted event.

Source

pub fn conversation_item_retrieved( event_id: impl Into<String>, item: RealtimeConversationItem, ) -> Self

Build a conversation.item.retrieved event.

Source

pub fn conversation_item_truncated( event_id: impl Into<String>, item_id: impl Into<String>, content_index: u32, audio_end_ms: u32, ) -> Self

Build a conversation.item.truncated event.

Source

pub fn input_audio_transcription_completed( event_id: impl Into<String>, item_id: impl Into<String>, content_index: u32, transcript: impl Into<String>, usage: TranscriptionUsage, ) -> Self

Build a conversation.item.input_audio_transcription.completed event.

Source

pub fn input_audio_transcription_completed_with_logprobs( event_id: impl Into<String>, item_id: impl Into<String>, content_index: u32, transcript: impl Into<String>, usage: TranscriptionUsage, logprobs: Vec<LogProbProperties>, ) -> Self

Build a conversation.item.input_audio_transcription.completed event with logprobs.

Source

pub fn input_audio_transcription_delta( event_id: impl Into<String>, item_id: impl Into<String>, content_index: Option<u32>, delta: Option<String>, logprobs: Option<Vec<LogProbProperties>>, ) -> Self

Build a conversation.item.input_audio_transcription.delta event.

Source

pub fn input_audio_transcription_failed( event_id: impl Into<String>, item_id: impl Into<String>, content_index: u32, error: TranscriptionError, ) -> Self

Build a conversation.item.input_audio_transcription.failed event.

Source

pub fn input_audio_transcription_segment( event_id: impl Into<String>, item_id: impl Into<String>, content_index: u32, text: impl Into<String>, id: impl Into<String>, speaker: impl Into<String>, start: f32, end: f32, ) -> Self

Build a conversation.item.input_audio_transcription.segment event.

Source

pub fn input_audio_buffer_cleared(event_id: impl Into<String>) -> Self

Build an input_audio_buffer.cleared event.

Source

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

Build an input_audio_buffer.committed event.

Source

pub fn input_audio_buffer_speech_started( event_id: impl Into<String>, audio_start_ms: u32, item_id: impl Into<String>, ) -> Self

Build an input_audio_buffer.speech_started event.

Source

pub fn input_audio_buffer_speech_stopped( event_id: impl Into<String>, audio_end_ms: u32, item_id: impl Into<String>, ) -> Self

Build an input_audio_buffer.speech_stopped event.

Source

pub fn input_audio_buffer_timeout_triggered( event_id: impl Into<String>, audio_start_ms: u32, audio_end_ms: u32, item_id: impl Into<String>, ) -> Self

Build an input_audio_buffer.timeout_triggered event.

Source

pub fn dtmf_event_received(event: impl Into<String>, received_at: i64) -> Self

Build an input_audio_buffer.dtmf_event_received event.

DTMF events have no event_id per the OpenAI spec.

Source

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

Build an mcp_list_tools.in_progress event.

Source

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

Build an mcp_list_tools.completed event.

Source

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

Build an mcp_list_tools.failed event.

Source

pub fn mcp_call_in_progress( event_id: impl Into<String>, item_id: impl Into<String>, output_index: u32, ) -> Self

Build a response.mcp_call.in_progress event.

Source

pub fn mcp_call_completed( event_id: impl Into<String>, item_id: impl Into<String>, output_index: u32, ) -> Self

Build a response.mcp_call.completed event.

Source

pub fn mcp_call_failed( event_id: impl Into<String>, item_id: impl Into<String>, output_index: u32, ) -> Self

Build a response.mcp_call.failed event.

Source

pub fn rate_limits_updated( event_id: impl Into<String>, rate_limits: Vec<RealtimeRateLimit>, ) -> Self

Build a rate_limits.updated event.

Source

pub fn response_created( event_id: impl Into<String>, response: RealtimeResponse, ) -> Self

Build a response.created event.

Source

pub fn response_done( event_id: impl Into<String>, response: RealtimeResponse, ) -> Self

Build a response.done event.

Source

pub fn error_event(event_id: impl Into<String>, error: RealtimeError) -> Self

Build an error event.

Source§

impl ServerEvent

Source

pub fn event_type(&self) -> &str

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

For known events, returns a &'static str from the event type constants. For unknown events, returns "unknown".

Source

pub fn to_event_type(&self) -> Option<RealtimeServerEvent>

Maps this event to its corresponding RealtimeServerEvent constant.

Returns None for Unknown events.

Source

pub fn is_function_call_done(&self) -> bool

Returns true if this is a response.function_call_arguments.done event.

Source

pub fn get_function_call(&self) -> Option<(&str, &str, &str)>

For response.function_call_arguments.done, returns (call_id, item_id, arguments).

Trait Implementations§

Source§

impl Clone for ServerEvent

Source§

fn clone(&self) -> ServerEvent

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 ServerEvent

Source§

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

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

impl<'de> Deserialize<'de> for ServerEvent

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 ServerEvent

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>,