Class RealtimeServerEvent
-
- All Implemented Interfaces:
public final class RealtimeServerEventA realtime server event.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interfaceRealtimeServerEvent.VisitorAn interface that defines how to map each variant of RealtimeServerEvent to a value of type T.
public final classRealtimeServerEvent.ConversationItemRetrievedReturned when a conversation item is retrieved with
conversation.item.retrieve.public final classRealtimeServerEvent.OutputAudioBufferStartedWebRTC Only: Emitted when the server begins streaming audio to the client. This event is emitted after an audio content part has been added (
response.content_part.added) to the response. Learn more.public final classRealtimeServerEvent.OutputAudioBufferStoppedWebRTC Only: Emitted when the output audio buffer has been completely drained on the server, and no more audio is forthcoming. This event is emitted after the full response data has been sent to the client (
response.done). Learn more.public final classRealtimeServerEvent.OutputAudioBufferClearedWebRTC 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 theoutput_audio_buffer.clearevent to manually cut off the current audio response. Learn more.
-
Method Summary
Modifier and Type Method Description final Optional<ConversationCreatedEvent>conversationCreated()Returned when a conversation is created. final Optional<ConversationItemCreatedEvent>conversationItemCreated()Returned when a conversation item is created. final Optional<ConversationItemDeletedEvent>conversationItemDeleted()Returned when an item in the conversation is deleted by the client with a conversation.item.deleteevent.final Optional<ConversationItemInputAudioTranscriptionCompletedEvent>conversationItemInputAudioTranscriptionCompleted()This event is the output of audio transcription for user audio written to the user audio buffer. final Optional<ConversationItemInputAudioTranscriptionDeltaEvent>conversationItemInputAudioTranscriptionDelta()Returned when the text value of an input audio transcription content part is updated. final Optional<ConversationItemInputAudioTranscriptionFailedEvent>conversationItemInputAudioTranscriptionFailed()Returned when input audio transcription is configured, and a transcription request for a user message failed. final Optional<RealtimeServerEvent.ConversationItemRetrieved>conversationItemRetrieved()Returned when a conversation item is retrieved with conversation.item.retrieve.final Optional<ConversationItemTruncatedEvent>conversationItemTruncated()Returned when an earlier assistant audio message item is truncated by the client with a conversation.item.truncateevent.final Optional<ErrorEvent>error()Returned when an error occurs, which could be a client problem or a server problem. final Optional<InputAudioBufferClearedEvent>inputAudioBufferCleared()Returned when the input audio buffer is cleared by the client with a input_audio_buffer.clearevent.final Optional<InputAudioBufferCommittedEvent>inputAudioBufferCommitted()Returned when an input audio buffer is committed, either by the client or automatically in server VAD mode. final Optional<InputAudioBufferSpeechStartedEvent>inputAudioBufferSpeechStarted()Sent by the server when in server_vadmode to indicate that speech has been detected in the audio buffer.final Optional<InputAudioBufferSpeechStoppedEvent>inputAudioBufferSpeechStopped()Returned in server_vadmode when the server detects the end of speech in the audio buffer.final Optional<RateLimitsUpdatedEvent>rateLimitsUpdated()Emitted at the beginning of a Response to indicate the updated rate limits. final Optional<ResponseAudioDeltaEvent>responseAudioDelta()Returned when the model-generated audio is updated. final Optional<ResponseAudioDoneEvent>responseAudioDone()Returned when the model-generated audio is done. final Optional<ResponseAudioTranscriptDeltaEvent>responseAudioTranscriptDelta()Returned when the model-generated transcription of audio output is updated. final Optional<ResponseAudioTranscriptDoneEvent>responseAudioTranscriptDone()Returned when the model-generated transcription of audio output is done streaming. final Optional<ResponseContentPartAddedEvent>responseContentPartAdded()Returned when a new content part is added to an assistant message item during response generation. final Optional<ResponseContentPartDoneEvent>responseContentPartDone()Returned when a content part is done streaming in an assistant message item. final Optional<ResponseCreatedEvent>responseCreated()Returned when a new Response is created. final Optional<ResponseDoneEvent>responseDone()Returned when a Response is done streaming. final Optional<ResponseFunctionCallArgumentsDeltaEvent>responseFunctionCallArgumentsDelta()Returned when the model-generated function call arguments are updated. final Optional<ResponseFunctionCallArgumentsDoneEvent>responseFunctionCallArgumentsDone()Returned when the model-generated function call arguments are done streaming. final Optional<ResponseOutputItemAddedEvent>responseOutputItemAdded()Returned when a new Item is created during Response generation. final Optional<ResponseOutputItemDoneEvent>responseOutputItemDone()Returned when an Item is done streaming. final Optional<ResponseTextDeltaEvent>responseTextDelta()Returned when the text value of a "text" content part is updated. final Optional<ResponseTextDoneEvent>responseTextDone()Returned when the text value of a "text" content part is done streaming. final Optional<SessionCreatedEvent>sessionCreated()Returned when a Session is created. final Optional<SessionUpdatedEvent>sessionUpdated()Returned when a session is updated with a session.updateevent, unless there is an error.final Optional<TranscriptionSessionUpdatedEvent>transcriptionSessionUpdated()Returned when a transcription session is updated with a transcription_session.updateevent, unless there is an error.final Optional<RealtimeServerEvent.OutputAudioBufferStarted>outputAudioBufferStarted()WebRTC Only: Emitted when the server begins streaming audio to the client. final Optional<RealtimeServerEvent.OutputAudioBufferStopped>outputAudioBufferStopped()WebRTC Only: Emitted when the output audio buffer has been completely drained on the server, and no more audio is forthcoming. final Optional<RealtimeServerEvent.OutputAudioBufferCleared>outputAudioBufferCleared()WebRTC Only: Emitted when the output audio buffer is cleared. final BooleanisConversationCreated()final BooleanisConversationItemCreated()final BooleanisConversationItemDeleted()final BooleanisConversationItemInputAudioTranscriptionCompleted()final BooleanisConversationItemInputAudioTranscriptionDelta()final BooleanisConversationItemInputAudioTranscriptionFailed()final BooleanisConversationItemRetrieved()final BooleanisConversationItemTruncated()final BooleanisError()final BooleanisInputAudioBufferCleared()final BooleanisInputAudioBufferCommitted()final BooleanisInputAudioBufferSpeechStarted()final BooleanisInputAudioBufferSpeechStopped()final BooleanisRateLimitsUpdated()final BooleanisResponseAudioDelta()final BooleanisResponseAudioDone()final BooleanisResponseAudioTranscriptDelta()final BooleanisResponseAudioTranscriptDone()final BooleanisResponseContentPartAdded()final BooleanisResponseContentPartDone()final BooleanisResponseCreated()final BooleanisResponseDone()final BooleanisResponseFunctionCallArgumentsDelta()final BooleanisResponseFunctionCallArgumentsDone()final BooleanisResponseOutputItemAdded()final BooleanisResponseOutputItemDone()final BooleanisResponseTextDelta()final BooleanisResponseTextDone()final BooleanisSessionCreated()final BooleanisSessionUpdated()final BooleanisTranscriptionSessionUpdated()final BooleanisOutputAudioBufferStarted()final BooleanisOutputAudioBufferStopped()final BooleanisOutputAudioBufferCleared()final ConversationCreatedEventasConversationCreated()Returned when a conversation is created. final ConversationItemCreatedEventasConversationItemCreated()Returned when a conversation item is created. final ConversationItemDeletedEventasConversationItemDeleted()Returned when an item in the conversation is deleted by the client with a conversation.item.deleteevent.final ConversationItemInputAudioTranscriptionCompletedEventasConversationItemInputAudioTranscriptionCompleted()This event is the output of audio transcription for user audio written to the user audio buffer. final ConversationItemInputAudioTranscriptionDeltaEventasConversationItemInputAudioTranscriptionDelta()Returned when the text value of an input audio transcription content part is updated. final ConversationItemInputAudioTranscriptionFailedEventasConversationItemInputAudioTranscriptionFailed()Returned when input audio transcription is configured, and a transcription request for a user message failed. final RealtimeServerEvent.ConversationItemRetrievedasConversationItemRetrieved()Returned when a conversation item is retrieved with conversation.item.retrieve.final ConversationItemTruncatedEventasConversationItemTruncated()Returned when an earlier assistant audio message item is truncated by the client with a conversation.item.truncateevent.final ErrorEventasError()Returned when an error occurs, which could be a client problem or a server problem. final InputAudioBufferClearedEventasInputAudioBufferCleared()Returned when the input audio buffer is cleared by the client with a input_audio_buffer.clearevent.final InputAudioBufferCommittedEventasInputAudioBufferCommitted()Returned when an input audio buffer is committed, either by the client or automatically in server VAD mode. final InputAudioBufferSpeechStartedEventasInputAudioBufferSpeechStarted()Sent by the server when in server_vadmode to indicate that speech has been detected in the audio buffer.final InputAudioBufferSpeechStoppedEventasInputAudioBufferSpeechStopped()Returned in server_vadmode when the server detects the end of speech in the audio buffer.final RateLimitsUpdatedEventasRateLimitsUpdated()Emitted at the beginning of a Response to indicate the updated rate limits. final ResponseAudioDeltaEventasResponseAudioDelta()Returned when the model-generated audio is updated. final ResponseAudioDoneEventasResponseAudioDone()Returned when the model-generated audio is done. final ResponseAudioTranscriptDeltaEventasResponseAudioTranscriptDelta()Returned when the model-generated transcription of audio output is updated. final ResponseAudioTranscriptDoneEventasResponseAudioTranscriptDone()Returned when the model-generated transcription of audio output is done streaming. final ResponseContentPartAddedEventasResponseContentPartAdded()Returned when a new content part is added to an assistant message item during response generation. final ResponseContentPartDoneEventasResponseContentPartDone()Returned when a content part is done streaming in an assistant message item. final ResponseCreatedEventasResponseCreated()Returned when a new Response is created. final ResponseDoneEventasResponseDone()Returned when a Response is done streaming. final ResponseFunctionCallArgumentsDeltaEventasResponseFunctionCallArgumentsDelta()Returned when the model-generated function call arguments are updated. final ResponseFunctionCallArgumentsDoneEventasResponseFunctionCallArgumentsDone()Returned when the model-generated function call arguments are done streaming. final ResponseOutputItemAddedEventasResponseOutputItemAdded()Returned when a new Item is created during Response generation. final ResponseOutputItemDoneEventasResponseOutputItemDone()Returned when an Item is done streaming. final ResponseTextDeltaEventasResponseTextDelta()Returned when the text value of a "text" content part is updated. final ResponseTextDoneEventasResponseTextDone()Returned when the text value of a "text" content part is done streaming. final SessionCreatedEventasSessionCreated()Returned when a Session is created. final SessionUpdatedEventasSessionUpdated()Returned when a session is updated with a session.updateevent, unless there is an error.final TranscriptionSessionUpdatedEventasTranscriptionSessionUpdated()Returned when a transcription session is updated with a transcription_session.updateevent, unless there is an error.final RealtimeServerEvent.OutputAudioBufferStartedasOutputAudioBufferStarted()WebRTC Only: Emitted when the server begins streaming audio to the client. final RealtimeServerEvent.OutputAudioBufferStoppedasOutputAudioBufferStopped()WebRTC Only: Emitted when the output audio buffer has been completely drained on the server, and no more audio is forthcoming. final RealtimeServerEvent.OutputAudioBufferClearedasOutputAudioBufferCleared()WebRTC Only: Emitted when the output audio buffer is cleared. final Optional<JsonValue>_json()final <T extends Any> Taccept(RealtimeServerEvent.Visitor<T> visitor)final RealtimeServerEventvalidate()final BooleanisValid()Booleanequals(Object other)IntegerhashCode()StringtoString()final static RealtimeServerEventofConversationCreated(ConversationCreatedEvent conversationCreated)Returned when a conversation is created. final static RealtimeServerEventofConversationItemCreated(ConversationItemCreatedEvent conversationItemCreated)Returned when a conversation item is created. final static RealtimeServerEventofConversationItemDeleted(ConversationItemDeletedEvent conversationItemDeleted)Returned when an item in the conversation is deleted by the client with a conversation.item.deleteevent.final static RealtimeServerEventofConversationItemInputAudioTranscriptionCompleted(ConversationItemInputAudioTranscriptionCompletedEvent conversationItemInputAudioTranscriptionCompleted)This event is the output of audio transcription for user audio written to the user audio buffer. final static RealtimeServerEventofConversationItemInputAudioTranscriptionDelta(ConversationItemInputAudioTranscriptionDeltaEvent conversationItemInputAudioTranscriptionDelta)Returned when the text value of an input audio transcription content part is updated. final static RealtimeServerEventofConversationItemInputAudioTranscriptionFailed(ConversationItemInputAudioTranscriptionFailedEvent conversationItemInputAudioTranscriptionFailed)Returned when input audio transcription is configured, and a transcription request for a user message failed. final static RealtimeServerEventofConversationItemRetrieved(RealtimeServerEvent.ConversationItemRetrieved conversationItemRetrieved)Returned when a conversation item is retrieved with conversation.item.retrieve.final static RealtimeServerEventofConversationItemTruncated(ConversationItemTruncatedEvent conversationItemTruncated)Returned when an earlier assistant audio message item is truncated by the client with a conversation.item.truncateevent.final static RealtimeServerEventofError(ErrorEvent error)Returned when an error occurs, which could be a client problem or a server problem. final static RealtimeServerEventofInputAudioBufferCleared(InputAudioBufferClearedEvent inputAudioBufferCleared)Returned when the input audio buffer is cleared by the client with a input_audio_buffer.clearevent.final static RealtimeServerEventofInputAudioBufferCommitted(InputAudioBufferCommittedEvent inputAudioBufferCommitted)Returned when an input audio buffer is committed, either by the client or automatically in server VAD mode. final static RealtimeServerEventofInputAudioBufferSpeechStarted(InputAudioBufferSpeechStartedEvent inputAudioBufferSpeechStarted)Sent by the server when in server_vadmode to indicate that speech has been detected in the audio buffer.final static RealtimeServerEventofInputAudioBufferSpeechStopped(InputAudioBufferSpeechStoppedEvent inputAudioBufferSpeechStopped)Returned in server_vadmode when the server detects the end of speech in the audio buffer.final static RealtimeServerEventofRateLimitsUpdated(RateLimitsUpdatedEvent rateLimitsUpdated)Emitted at the beginning of a Response to indicate the updated rate limits. final static RealtimeServerEventofResponseAudioDelta(ResponseAudioDeltaEvent responseAudioDelta)Returned when the model-generated audio is updated. final static RealtimeServerEventofResponseAudioDone(ResponseAudioDoneEvent responseAudioDone)Returned when the model-generated audio is done. final static RealtimeServerEventofResponseAudioTranscriptDelta(ResponseAudioTranscriptDeltaEvent responseAudioTranscriptDelta)Returned when the model-generated transcription of audio output is updated. final static RealtimeServerEventofResponseAudioTranscriptDone(ResponseAudioTranscriptDoneEvent responseAudioTranscriptDone)Returned when the model-generated transcription of audio output is done streaming. final static RealtimeServerEventofResponseContentPartAdded(ResponseContentPartAddedEvent responseContentPartAdded)Returned when a new content part is added to an assistant message item during response generation. final static RealtimeServerEventofResponseContentPartDone(ResponseContentPartDoneEvent responseContentPartDone)Returned when a content part is done streaming in an assistant message item. final static RealtimeServerEventofResponseCreated(ResponseCreatedEvent responseCreated)Returned when a new Response is created. final static RealtimeServerEventofResponseDone(ResponseDoneEvent responseDone)Returned when a Response is done streaming. final static RealtimeServerEventofResponseFunctionCallArgumentsDelta(ResponseFunctionCallArgumentsDeltaEvent responseFunctionCallArgumentsDelta)Returned when the model-generated function call arguments are updated. final static RealtimeServerEventofResponseFunctionCallArgumentsDone(ResponseFunctionCallArgumentsDoneEvent responseFunctionCallArgumentsDone)Returned when the model-generated function call arguments are done streaming. final static RealtimeServerEventofResponseOutputItemAdded(ResponseOutputItemAddedEvent responseOutputItemAdded)Returned when a new Item is created during Response generation. final static RealtimeServerEventofResponseOutputItemDone(ResponseOutputItemDoneEvent responseOutputItemDone)Returned when an Item is done streaming. final static RealtimeServerEventofResponseTextDelta(ResponseTextDeltaEvent responseTextDelta)Returned when the text value of a "text" content part is updated. final static RealtimeServerEventofResponseTextDone(ResponseTextDoneEvent responseTextDone)Returned when the text value of a "text" content part is done streaming. final static RealtimeServerEventofSessionCreated(SessionCreatedEvent sessionCreated)Returned when a Session is created. final static RealtimeServerEventofSessionUpdated(SessionUpdatedEvent sessionUpdated)Returned when a session is updated with a session.updateevent, unless there is an error.final static RealtimeServerEventofTranscriptionSessionUpdated(TranscriptionSessionUpdatedEvent transcriptionSessionUpdated)Returned when a transcription session is updated with a transcription_session.updateevent, unless there is an error.final static RealtimeServerEventofOutputAudioBufferStarted(RealtimeServerEvent.OutputAudioBufferStarted outputAudioBufferStarted)WebRTC Only: Emitted when the server begins streaming audio to the client. final static RealtimeServerEventofOutputAudioBufferStopped(RealtimeServerEvent.OutputAudioBufferStopped outputAudioBufferStopped)WebRTC Only: Emitted when the output audio buffer has been completely drained on the server, and no more audio is forthcoming. final static RealtimeServerEventofOutputAudioBufferCleared(RealtimeServerEvent.OutputAudioBufferCleared outputAudioBufferCleared)WebRTC Only: Emitted when the output audio buffer is cleared. -
-
Method Detail
-
conversationCreated
final Optional<ConversationCreatedEvent> conversationCreated()
Returned when a conversation is created. Emitted right after session creation.
-
conversationItemCreated
final Optional<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(roleassistant) or typefunction_call.The input audio buffer has been committed, either by the client or the server (in
server_vadmode). 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.createevent to add a new Item to the Conversation.
-
conversationItemDeleted
final Optional<ConversationItemDeletedEvent> conversationItemDeleted()
Returned when an item in the conversation is deleted by the client with a
conversation.item.deleteevent. This event is used to synchronize the server's understanding of the conversation history with the client's view.
-
conversationItemInputAudioTranscriptionCompleted
final Optional<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_vadmode). 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.
-
conversationItemInputAudioTranscriptionDelta
final Optional<ConversationItemInputAudioTranscriptionDeltaEvent> conversationItemInputAudioTranscriptionDelta()
Returned when the text value of an input audio transcription content part is updated.
-
conversationItemInputAudioTranscriptionFailed
final Optional<ConversationItemInputAudioTranscriptionFailedEvent> conversationItemInputAudioTranscriptionFailed()
Returned when input audio transcription is configured, and a transcription request for a user message failed. These events are separate from other
errorevents so that the client can identify the related Item.
-
conversationItemRetrieved
final Optional<RealtimeServerEvent.ConversationItemRetrieved> conversationItemRetrieved()
Returned when a conversation item is retrieved with
conversation.item.retrieve.
-
conversationItemTruncated
final Optional<ConversationItemTruncatedEvent> conversationItemTruncated()
Returned when an earlier assistant audio message item is truncated by the client with a
conversation.item.truncateevent. 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.
-
error
final Optional<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.
-
inputAudioBufferCleared
final Optional<InputAudioBufferClearedEvent> inputAudioBufferCleared()
Returned when the input audio buffer is cleared by the client with a
input_audio_buffer.clearevent.
-
inputAudioBufferCommitted
final Optional<InputAudioBufferCommittedEvent> inputAudioBufferCommitted()
Returned when an input audio buffer is committed, either by the client or automatically in server VAD mode. The
item_idproperty is the ID of the user message item that will be created, thus aconversation.item.createdevent will also be sent to the client.
-
inputAudioBufferSpeechStarted
final Optional<InputAudioBufferSpeechStartedEvent> inputAudioBufferSpeechStarted()
Sent by the server when in
server_vadmode 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_stoppedevent when speech stops. Theitem_idproperty is the ID of the user message item that will be created when speech stops and will also be included in theinput_audio_buffer.speech_stoppedevent (unless the client manually commits the audio buffer during VAD activation).
-
inputAudioBufferSpeechStopped
final Optional<InputAudioBufferSpeechStoppedEvent> inputAudioBufferSpeechStopped()
Returned in
server_vadmode when the server detects the end of speech in the audio buffer. The server will also send anconversation.item.createdevent with the user message item that is created from the audio buffer.
-
rateLimitsUpdated
final Optional<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.
-
responseAudioDelta
final Optional<ResponseAudioDeltaEvent> responseAudioDelta()
Returned when the model-generated audio is updated.
-
responseAudioDone
final Optional<ResponseAudioDoneEvent> responseAudioDone()
Returned when the model-generated audio is done. Also emitted when a Response is interrupted, incomplete, or cancelled.
-
responseAudioTranscriptDelta
final Optional<ResponseAudioTranscriptDeltaEvent> responseAudioTranscriptDelta()
Returned when the model-generated transcription of audio output is updated.
-
responseAudioTranscriptDone
final Optional<ResponseAudioTranscriptDoneEvent> responseAudioTranscriptDone()
Returned when the model-generated transcription of audio output is done streaming. Also emitted when a Response is interrupted, incomplete, or cancelled.
-
responseContentPartAdded
final Optional<ResponseContentPartAddedEvent> responseContentPartAdded()
Returned when a new content part is added to an assistant message item during response generation.
-
responseContentPartDone
final Optional<ResponseContentPartDoneEvent> responseContentPartDone()
Returned when a content part is done streaming in an assistant message item. Also emitted when a Response is interrupted, incomplete, or cancelled.
-
responseCreated
final Optional<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.
-
responseDone
final Optional<ResponseDoneEvent> responseDone()
Returned when a Response is done streaming. Always emitted, no matter the final state. The Response object included in the
response.doneevent will include all output Items in the Response but will omit the raw audio data.
-
responseFunctionCallArgumentsDelta
final Optional<ResponseFunctionCallArgumentsDeltaEvent> responseFunctionCallArgumentsDelta()
Returned when the model-generated function call arguments are updated.
-
responseFunctionCallArgumentsDone
final Optional<ResponseFunctionCallArgumentsDoneEvent> responseFunctionCallArgumentsDone()
Returned when the model-generated function call arguments are done streaming. Also emitted when a Response is interrupted, incomplete, or cancelled.
-
responseOutputItemAdded
final Optional<ResponseOutputItemAddedEvent> responseOutputItemAdded()
Returned when a new Item is created during Response generation.
-
responseOutputItemDone
final Optional<ResponseOutputItemDoneEvent> responseOutputItemDone()
Returned when an Item is done streaming. Also emitted when a Response is interrupted, incomplete, or cancelled.
-
responseTextDelta
final Optional<ResponseTextDeltaEvent> responseTextDelta()
Returned when the text value of a "text" content part is updated.
-
responseTextDone
final Optional<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.
-
sessionCreated
final Optional<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.
-
sessionUpdated
final Optional<SessionUpdatedEvent> sessionUpdated()
Returned when a session is updated with a
session.updateevent, unless there is an error.
-
transcriptionSessionUpdated
final Optional<TranscriptionSessionUpdatedEvent> transcriptionSessionUpdated()
Returned when a transcription session is updated with a
transcription_session.updateevent, unless there is an error.
-
outputAudioBufferStarted
final Optional<RealtimeServerEvent.OutputAudioBufferStarted> outputAudioBufferStarted()
WebRTC Only: Emitted when the server begins streaming audio to the client. This event is emitted after an audio content part has been added (
response.content_part.added) to the response. Learn more.
-
outputAudioBufferStopped
final Optional<RealtimeServerEvent.OutputAudioBufferStopped> outputAudioBufferStopped()
WebRTC Only: Emitted when the output audio buffer has been completely drained on the server, and no more audio is forthcoming. This event is emitted after the full response data has been sent to the client (
response.done). Learn more.
-
outputAudioBufferCleared
final Optional<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 theoutput_audio_buffer.clearevent to manually cut off the current audio response. Learn more.
-
isConversationCreated
final Boolean isConversationCreated()
-
isConversationItemCreated
final Boolean isConversationItemCreated()
-
isConversationItemDeleted
final Boolean isConversationItemDeleted()
-
isConversationItemInputAudioTranscriptionCompleted
final Boolean isConversationItemInputAudioTranscriptionCompleted()
-
isConversationItemInputAudioTranscriptionDelta
final Boolean isConversationItemInputAudioTranscriptionDelta()
-
isConversationItemInputAudioTranscriptionFailed
final Boolean isConversationItemInputAudioTranscriptionFailed()
-
isConversationItemRetrieved
final Boolean isConversationItemRetrieved()
-
isConversationItemTruncated
final Boolean isConversationItemTruncated()
-
isInputAudioBufferCleared
final Boolean isInputAudioBufferCleared()
-
isInputAudioBufferCommitted
final Boolean isInputAudioBufferCommitted()
-
isInputAudioBufferSpeechStarted
final Boolean isInputAudioBufferSpeechStarted()
-
isInputAudioBufferSpeechStopped
final Boolean isInputAudioBufferSpeechStopped()
-
isRateLimitsUpdated
final Boolean isRateLimitsUpdated()
-
isResponseAudioDelta
final Boolean isResponseAudioDelta()
-
isResponseAudioDone
final Boolean isResponseAudioDone()
-
isResponseAudioTranscriptDelta
final Boolean isResponseAudioTranscriptDelta()
-
isResponseAudioTranscriptDone
final Boolean isResponseAudioTranscriptDone()
-
isResponseContentPartAdded
final Boolean isResponseContentPartAdded()
-
isResponseContentPartDone
final Boolean isResponseContentPartDone()
-
isResponseCreated
final Boolean isResponseCreated()
-
isResponseDone
final Boolean isResponseDone()
-
isResponseFunctionCallArgumentsDelta
final Boolean isResponseFunctionCallArgumentsDelta()
-
isResponseFunctionCallArgumentsDone
final Boolean isResponseFunctionCallArgumentsDone()
-
isResponseOutputItemAdded
final Boolean isResponseOutputItemAdded()
-
isResponseOutputItemDone
final Boolean isResponseOutputItemDone()
-
isResponseTextDelta
final Boolean isResponseTextDelta()
-
isResponseTextDone
final Boolean isResponseTextDone()
-
isSessionCreated
final Boolean isSessionCreated()
-
isSessionUpdated
final Boolean isSessionUpdated()
-
isTranscriptionSessionUpdated
final Boolean isTranscriptionSessionUpdated()
-
isOutputAudioBufferStarted
final Boolean isOutputAudioBufferStarted()
-
isOutputAudioBufferStopped
final Boolean isOutputAudioBufferStopped()
-
isOutputAudioBufferCleared
final Boolean isOutputAudioBufferCleared()
-
asConversationCreated
final ConversationCreatedEvent asConversationCreated()
Returned when a conversation is created. Emitted right after session creation.
-
asConversationItemCreated
final ConversationItemCreatedEvent asConversationItemCreated()
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(roleassistant) or typefunction_call.The input audio buffer has been committed, either by the client or the server (in
server_vadmode). 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.createevent to add a new Item to the Conversation.
-
asConversationItemDeleted
final ConversationItemDeletedEvent asConversationItemDeleted()
Returned when an item in the conversation is deleted by the client with a
conversation.item.deleteevent. This event is used to synchronize the server's understanding of the conversation history with the client's view.
-
asConversationItemInputAudioTranscriptionCompleted
final ConversationItemInputAudioTranscriptionCompletedEvent asConversationItemInputAudioTranscriptionCompleted()
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_vadmode). 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.
-
asConversationItemInputAudioTranscriptionDelta
final ConversationItemInputAudioTranscriptionDeltaEvent asConversationItemInputAudioTranscriptionDelta()
Returned when the text value of an input audio transcription content part is updated.
-
asConversationItemInputAudioTranscriptionFailed
final ConversationItemInputAudioTranscriptionFailedEvent asConversationItemInputAudioTranscriptionFailed()
Returned when input audio transcription is configured, and a transcription request for a user message failed. These events are separate from other
errorevents so that the client can identify the related Item.
-
asConversationItemRetrieved
final RealtimeServerEvent.ConversationItemRetrieved asConversationItemRetrieved()
Returned when a conversation item is retrieved with
conversation.item.retrieve.
-
asConversationItemTruncated
final ConversationItemTruncatedEvent asConversationItemTruncated()
Returned when an earlier assistant audio message item is truncated by the client with a
conversation.item.truncateevent. 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.
-
asError
final ErrorEvent asError()
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.
-
asInputAudioBufferCleared
final InputAudioBufferClearedEvent asInputAudioBufferCleared()
Returned when the input audio buffer is cleared by the client with a
input_audio_buffer.clearevent.
-
asInputAudioBufferCommitted
final InputAudioBufferCommittedEvent asInputAudioBufferCommitted()
Returned when an input audio buffer is committed, either by the client or automatically in server VAD mode. The
item_idproperty is the ID of the user message item that will be created, thus aconversation.item.createdevent will also be sent to the client.
-
asInputAudioBufferSpeechStarted
final InputAudioBufferSpeechStartedEvent asInputAudioBufferSpeechStarted()
Sent by the server when in
server_vadmode 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_stoppedevent when speech stops. Theitem_idproperty is the ID of the user message item that will be created when speech stops and will also be included in theinput_audio_buffer.speech_stoppedevent (unless the client manually commits the audio buffer during VAD activation).
-
asInputAudioBufferSpeechStopped
final InputAudioBufferSpeechStoppedEvent asInputAudioBufferSpeechStopped()
Returned in
server_vadmode when the server detects the end of speech in the audio buffer. The server will also send anconversation.item.createdevent with the user message item that is created from the audio buffer.
-
asRateLimitsUpdated
final RateLimitsUpdatedEvent asRateLimitsUpdated()
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.
-
asResponseAudioDelta
final ResponseAudioDeltaEvent asResponseAudioDelta()
Returned when the model-generated audio is updated.
-
asResponseAudioDone
final ResponseAudioDoneEvent asResponseAudioDone()
Returned when the model-generated audio is done. Also emitted when a Response is interrupted, incomplete, or cancelled.
-
asResponseAudioTranscriptDelta
final ResponseAudioTranscriptDeltaEvent asResponseAudioTranscriptDelta()
Returned when the model-generated transcription of audio output is updated.
-
asResponseAudioTranscriptDone
final ResponseAudioTranscriptDoneEvent asResponseAudioTranscriptDone()
Returned when the model-generated transcription of audio output is done streaming. Also emitted when a Response is interrupted, incomplete, or cancelled.
-
asResponseContentPartAdded
final ResponseContentPartAddedEvent asResponseContentPartAdded()
Returned when a new content part is added to an assistant message item during response generation.
-
asResponseContentPartDone
final ResponseContentPartDoneEvent asResponseContentPartDone()
Returned when a content part is done streaming in an assistant message item. Also emitted when a Response is interrupted, incomplete, or cancelled.
-
asResponseCreated
final ResponseCreatedEvent asResponseCreated()
Returned when a new Response is created. The first event of response creation, where the response is in an initial state of
in_progress.
-
asResponseDone
final ResponseDoneEvent asResponseDone()
Returned when a Response is done streaming. Always emitted, no matter the final state. The Response object included in the
response.doneevent will include all output Items in the Response but will omit the raw audio data.
-
asResponseFunctionCallArgumentsDelta
final ResponseFunctionCallArgumentsDeltaEvent asResponseFunctionCallArgumentsDelta()
Returned when the model-generated function call arguments are updated.
-
asResponseFunctionCallArgumentsDone
final ResponseFunctionCallArgumentsDoneEvent asResponseFunctionCallArgumentsDone()
Returned when the model-generated function call arguments are done streaming. Also emitted when a Response is interrupted, incomplete, or cancelled.
-
asResponseOutputItemAdded
final ResponseOutputItemAddedEvent asResponseOutputItemAdded()
Returned when a new Item is created during Response generation.
-
asResponseOutputItemDone
final ResponseOutputItemDoneEvent asResponseOutputItemDone()
Returned when an Item is done streaming. Also emitted when a Response is interrupted, incomplete, or cancelled.
-
asResponseTextDelta
final ResponseTextDeltaEvent asResponseTextDelta()
Returned when the text value of a "text" content part is updated.
-
asResponseTextDone
final ResponseTextDoneEvent asResponseTextDone()
Returned when the text value of a "text" content part is done streaming. Also emitted when a Response is interrupted, incomplete, or cancelled.
-
asSessionCreated
final SessionCreatedEvent asSessionCreated()
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.
-
asSessionUpdated
final SessionUpdatedEvent asSessionUpdated()
Returned when a session is updated with a
session.updateevent, unless there is an error.
-
asTranscriptionSessionUpdated
final TranscriptionSessionUpdatedEvent asTranscriptionSessionUpdated()
Returned when a transcription session is updated with a
transcription_session.updateevent, unless there is an error.
-
asOutputAudioBufferStarted
final RealtimeServerEvent.OutputAudioBufferStarted asOutputAudioBufferStarted()
WebRTC Only: Emitted when the server begins streaming audio to the client. This event is emitted after an audio content part has been added (
response.content_part.added) to the response. Learn more.
-
asOutputAudioBufferStopped
final RealtimeServerEvent.OutputAudioBufferStopped asOutputAudioBufferStopped()
WebRTC Only: Emitted when the output audio buffer has been completely drained on the server, and no more audio is forthcoming. This event is emitted after the full response data has been sent to the client (
response.done). Learn more.
-
asOutputAudioBufferCleared
final RealtimeServerEvent.OutputAudioBufferCleared asOutputAudioBufferCleared()
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 theoutput_audio_buffer.clearevent to manually cut off the current audio response. Learn more.
-
accept
final <T extends Any> T accept(RealtimeServerEvent.Visitor<T> visitor)
-
validate
final RealtimeServerEvent validate()
-
ofConversationCreated
final static RealtimeServerEvent ofConversationCreated(ConversationCreatedEvent conversationCreated)
Returned when a conversation is created. Emitted right after session creation.
-
ofConversationItemCreated
final static RealtimeServerEvent ofConversationItemCreated(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(roleassistant) or typefunction_call.The input audio buffer has been committed, either by the client or the server (in
server_vadmode). 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.createevent to add a new Item to the Conversation.
-
ofConversationItemDeleted
final static RealtimeServerEvent ofConversationItemDeleted(ConversationItemDeletedEvent conversationItemDeleted)
Returned when an item in the conversation is deleted by the client with a
conversation.item.deleteevent. This event is used to synchronize the server's understanding of the conversation history with the client's view.
-
ofConversationItemInputAudioTranscriptionCompleted
final static RealtimeServerEvent ofConversationItemInputAudioTranscriptionCompleted(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_vadmode). 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.
-
ofConversationItemInputAudioTranscriptionDelta
final static RealtimeServerEvent ofConversationItemInputAudioTranscriptionDelta(ConversationItemInputAudioTranscriptionDeltaEvent conversationItemInputAudioTranscriptionDelta)
Returned when the text value of an input audio transcription content part is updated.
-
ofConversationItemInputAudioTranscriptionFailed
final static RealtimeServerEvent ofConversationItemInputAudioTranscriptionFailed(ConversationItemInputAudioTranscriptionFailedEvent conversationItemInputAudioTranscriptionFailed)
Returned when input audio transcription is configured, and a transcription request for a user message failed. These events are separate from other
errorevents so that the client can identify the related Item.
-
ofConversationItemRetrieved
final static RealtimeServerEvent ofConversationItemRetrieved(RealtimeServerEvent.ConversationItemRetrieved conversationItemRetrieved)
Returned when a conversation item is retrieved with
conversation.item.retrieve.
-
ofConversationItemTruncated
final static RealtimeServerEvent ofConversationItemTruncated(ConversationItemTruncatedEvent conversationItemTruncated)
Returned when an earlier assistant audio message item is truncated by the client with a
conversation.item.truncateevent. 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.
-
ofError
final static RealtimeServerEvent ofError(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.
-
ofInputAudioBufferCleared
final static RealtimeServerEvent ofInputAudioBufferCleared(InputAudioBufferClearedEvent inputAudioBufferCleared)
Returned when the input audio buffer is cleared by the client with a
input_audio_buffer.clearevent.
-
ofInputAudioBufferCommitted
final static RealtimeServerEvent ofInputAudioBufferCommitted(InputAudioBufferCommittedEvent inputAudioBufferCommitted)
Returned when an input audio buffer is committed, either by the client or automatically in server VAD mode. The
item_idproperty is the ID of the user message item that will be created, thus aconversation.item.createdevent will also be sent to the client.
-
ofInputAudioBufferSpeechStarted
final static RealtimeServerEvent ofInputAudioBufferSpeechStarted(InputAudioBufferSpeechStartedEvent inputAudioBufferSpeechStarted)
Sent by the server when in
server_vadmode 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_stoppedevent when speech stops. Theitem_idproperty is the ID of the user message item that will be created when speech stops and will also be included in theinput_audio_buffer.speech_stoppedevent (unless the client manually commits the audio buffer during VAD activation).
-
ofInputAudioBufferSpeechStopped
final static RealtimeServerEvent ofInputAudioBufferSpeechStopped(InputAudioBufferSpeechStoppedEvent inputAudioBufferSpeechStopped)
Returned in
server_vadmode when the server detects the end of speech in the audio buffer. The server will also send anconversation.item.createdevent with the user message item that is created from the audio buffer.
-
ofRateLimitsUpdated
final static RealtimeServerEvent ofRateLimitsUpdated(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.
-
ofResponseAudioDelta
final static RealtimeServerEvent ofResponseAudioDelta(ResponseAudioDeltaEvent responseAudioDelta)
Returned when the model-generated audio is updated.
-
ofResponseAudioDone
final static RealtimeServerEvent ofResponseAudioDone(ResponseAudioDoneEvent responseAudioDone)
Returned when the model-generated audio is done. Also emitted when a Response is interrupted, incomplete, or cancelled.
-
ofResponseAudioTranscriptDelta
final static RealtimeServerEvent ofResponseAudioTranscriptDelta(ResponseAudioTranscriptDeltaEvent responseAudioTranscriptDelta)
Returned when the model-generated transcription of audio output is updated.
-
ofResponseAudioTranscriptDone
final static RealtimeServerEvent ofResponseAudioTranscriptDone(ResponseAudioTranscriptDoneEvent responseAudioTranscriptDone)
Returned when the model-generated transcription of audio output is done streaming. Also emitted when a Response is interrupted, incomplete, or cancelled.
-
ofResponseContentPartAdded
final static RealtimeServerEvent ofResponseContentPartAdded(ResponseContentPartAddedEvent responseContentPartAdded)
Returned when a new content part is added to an assistant message item during response generation.
-
ofResponseContentPartDone
final static RealtimeServerEvent ofResponseContentPartDone(ResponseContentPartDoneEvent responseContentPartDone)
Returned when a content part is done streaming in an assistant message item. Also emitted when a Response is interrupted, incomplete, or cancelled.
-
ofResponseCreated
final static RealtimeServerEvent ofResponseCreated(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.
-
ofResponseDone
final static RealtimeServerEvent ofResponseDone(ResponseDoneEvent responseDone)
Returned when a Response is done streaming. Always emitted, no matter the final state. The Response object included in the
response.doneevent will include all output Items in the Response but will omit the raw audio data.
-
ofResponseFunctionCallArgumentsDelta
final static RealtimeServerEvent ofResponseFunctionCallArgumentsDelta(ResponseFunctionCallArgumentsDeltaEvent responseFunctionCallArgumentsDelta)
Returned when the model-generated function call arguments are updated.
-
ofResponseFunctionCallArgumentsDone
final static RealtimeServerEvent ofResponseFunctionCallArgumentsDone(ResponseFunctionCallArgumentsDoneEvent responseFunctionCallArgumentsDone)
Returned when the model-generated function call arguments are done streaming. Also emitted when a Response is interrupted, incomplete, or cancelled.
-
ofResponseOutputItemAdded
final static RealtimeServerEvent ofResponseOutputItemAdded(ResponseOutputItemAddedEvent responseOutputItemAdded)
Returned when a new Item is created during Response generation.
-
ofResponseOutputItemDone
final static RealtimeServerEvent ofResponseOutputItemDone(ResponseOutputItemDoneEvent responseOutputItemDone)
Returned when an Item is done streaming. Also emitted when a Response is interrupted, incomplete, or cancelled.
-
ofResponseTextDelta
final static RealtimeServerEvent ofResponseTextDelta(ResponseTextDeltaEvent responseTextDelta)
Returned when the text value of a "text" content part is updated.
-
ofResponseTextDone
final static RealtimeServerEvent ofResponseTextDone(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.
-
ofSessionCreated
final static RealtimeServerEvent ofSessionCreated(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.
-
ofSessionUpdated
final static RealtimeServerEvent ofSessionUpdated(SessionUpdatedEvent sessionUpdated)
Returned when a session is updated with a
session.updateevent, unless there is an error.
-
ofTranscriptionSessionUpdated
final static RealtimeServerEvent ofTranscriptionSessionUpdated(TranscriptionSessionUpdatedEvent transcriptionSessionUpdated)
Returned when a transcription session is updated with a
transcription_session.updateevent, unless there is an error.
-
ofOutputAudioBufferStarted
final static RealtimeServerEvent ofOutputAudioBufferStarted(RealtimeServerEvent.OutputAudioBufferStarted outputAudioBufferStarted)
WebRTC Only: Emitted when the server begins streaming audio to the client. This event is emitted after an audio content part has been added (
response.content_part.added) to the response. Learn more.
-
ofOutputAudioBufferStopped
final static RealtimeServerEvent ofOutputAudioBufferStopped(RealtimeServerEvent.OutputAudioBufferStopped outputAudioBufferStopped)
WebRTC Only: Emitted when the output audio buffer has been completely drained on the server, and no more audio is forthcoming. This event is emitted after the full response data has been sent to the client (
response.done). Learn more.
-
ofOutputAudioBufferCleared
final static RealtimeServerEvent ofOutputAudioBufferCleared(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 theoutput_audio_buffer.clearevent to manually cut off the current audio response. Learn more.
-
-
-
-