Interface RealtimeServerEvent.Visitor

    • Constructor Detail

    • Method Detail

      • visitConversationItemCreated

         abstract T visitConversationItemCreated(ConversationItemCreatedEvent conversationItemCreated)

        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.

      • visitConversationItemDeleted

         abstract T visitConversationItemDeleted(ConversationItemDeletedEvent conversationItemDeleted)

        Returned when an item in the conversation is deleted by the client with a conversation.item.delete event. This event is used to synchronize the server's understanding of the conversation history with the client's view.

      • visitConversationItemInputAudioTranscriptionCompleted

         abstract T visitConversationItemInputAudioTranscriptionCompleted(ConversationItemInputAudioTranscriptionCompletedEvent conversationItemInputAudioTranscriptionCompleted)

        This event is the output of audio transcription for user audio written to the user audio buffer. Transcription begins when the input audio buffer is committed by the client or server (in server_vad mode). Transcription runs asynchronously with Response creation, so this event may come before or after the Response events.

        Realtime API models accept audio natively, and thus input transcription is a separate process run on a separate ASR (Automatic Speech Recognition) model. The transcript may diverge somewhat from the model's interpretation, and should be treated as a rough guide.

      • visitConversationItemTruncated

         abstract T visitConversationItemTruncated(ConversationItemTruncatedEvent conversationItemTruncated)

        Returned when an earlier assistant audio message item is truncated by the client with a conversation.item.truncate event. This event is used to synchronize the server's understanding of the audio with the client's playback.

        This action will truncate the audio and remove the server-side text transcript to ensure there is no text in the context that hasn't been heard by the user.

      • visitError

         abstract T visitError(ErrorEvent error)

        Returned when an error occurs, which could be a client problem or a server problem. Most errors are recoverable and the session will stay open, we recommend to implementors to monitor and log error messages by default.

      • visitInputAudioBufferCommitted

         abstract T visitInputAudioBufferCommitted(InputAudioBufferCommittedEvent inputAudioBufferCommitted)

        Returned when an input audio buffer is committed, either by the client or automatically in server VAD mode. The item_id property is the ID of the user message item that will be created, thus a conversation.item.created event will also be sent to the client.

      • visitInputAudioBufferSpeechStarted

         abstract T visitInputAudioBufferSpeechStarted(InputAudioBufferSpeechStartedEvent inputAudioBufferSpeechStarted)

        Sent by the server when in server_vad mode to indicate that speech has been detected in the audio buffer. This can happen any time audio is added to the buffer (unless speech is already detected). The client may want to use this event to interrupt audio playback or provide visual feedback to the user.

        The client should expect to receive a input_audio_buffer.speech_stopped event when speech stops. The item_id property is the ID of the user message item that will be created when speech stops and will also be included in the input_audio_buffer.speech_stopped event (unless the client manually commits the audio buffer during VAD activation).

      • visitInputAudioBufferSpeechStopped

         abstract T visitInputAudioBufferSpeechStopped(InputAudioBufferSpeechStoppedEvent inputAudioBufferSpeechStopped)

        Returned in server_vad mode when the server detects the end of speech in the audio buffer. The server will also send an conversation.item.created event with the user message item that is created from the audio buffer.

      • visitRateLimitsUpdated

         abstract T visitRateLimitsUpdated(RateLimitsUpdatedEvent rateLimitsUpdated)

        Emitted at the beginning of a Response to indicate the updated rate limits. When a Response is created some tokens will be "reserved" for the output tokens, the rate limits shown here reflect that reservation, which is then adjusted accordingly once the Response is completed.

      • visitResponseCreated

         abstract T visitResponseCreated(ResponseCreatedEvent responseCreated)

        Returned when a new Response is created. The first event of response creation, where the response is in an initial state of in_progress.

      • visitResponseDone

         abstract T visitResponseDone(ResponseDoneEvent responseDone)

        Returned when a Response is done streaming. Always emitted, no matter the final state. The Response object included in the response.done event will include all output Items in the Response but will omit the raw audio data.

      • visitResponseTextDone

         abstract T visitResponseTextDone(ResponseTextDoneEvent responseTextDone)

        Returned when the text value of a "text" content part is done streaming. Also emitted when a Response is interrupted, incomplete, or cancelled.

      • visitSessionCreated

         abstract T visitSessionCreated(SessionCreatedEvent sessionCreated)

        Returned when a Session is created. Emitted automatically when a new connection is established as the first server event. This event will contain the default Session configuration.

      • visitOutputAudioBufferCleared

         abstract T visitOutputAudioBufferCleared(RealtimeServerEvent.OutputAudioBufferCleared outputAudioBufferCleared)

        WebRTC Only: Emitted when the output audio buffer is cleared. This happens either in VAD mode when the user has interrupted (input_audio_buffer.speech_started), or when the client has emitted the output_audio_buffer.clear event to manually cut off the current audio response. Learn more.

      • unknown

         T unknown(JsonValue json)

        Maps an unknown variant of RealtimeServerEvent to a value of type T.

        An instance of RealtimeServerEvent can contain an unknown variant if it was deserialized from data that doesn't match any known variant. For example, if the SDK is on an older version than the API, then the API may respond with new variants that the SDK is unaware of.