Real-time multimodal interaction flow
This topic describes the real-time multimodal interaction flow between the server and the client.
VAD mode
To enable VAD mode, set the session.turn_detection parameter of the client event to "server_vad". In this mode, the server performs Voice Activity Detection (VAD) on incoming audio and responds when it detects speech. This mode is the default and is designed for scenarios where the client continuously sends audio to the server.
-
The server sends the
input_audio_buffer.speech_startedevent when it detects the start of speech. -
The client can append audio to the buffer at any time by sending an
input_audio_buffer.appendevent. -
The server sends the
input_audio_buffer.speech_stoppedevent when it detects the end of speech. -
The server commits the input audio buffer by sending an
input_audio_buffer.committedevent. -
The server sends a
conversation.item.createdevent, which contains the user message item created from the audio buffer.
Tool calling flow
In VAD mode, when a server-generated response requires a tool call, the following interaction flow occurs:
-
After detecting the end of speech and generating a response, the server determines that a tool call is required.
-
The server sends a
response.function_call_arguments.deltaevent, which contains incremental data for the tool call arguments. -
The server sends a
response.function_call_arguments.doneevent to indicate that all tool call arguments have been sent. -
The client executes the tool call and obtains the result.
-
The client sends a
conversation.item.createevent that contains the tool call result. -
The server automatically generates a response based on the tool call result.
Manual mode
To enable Manual mode, set the session.turn_detection parameter of the client event to null. In this mode, the client requests a server response by explicitly sending input_audio_buffer.commit and response.create events. This mode is suitable for push-to-talk scenarios, such as sending voice messages in chat applications.
-
The client can append audio to the buffer by sending an
input_audio_buffer.appendevent. -
The client commits the input audio buffer by sending an
input_audio_buffer.commitevent. This commit creates a new user message item in the conversation. -
The server responds by sending an
input_audio_buffer.committedevent. -
The client sends a
response.createevent to trigger the model to generate the final response. -
The server responds by sending a
conversation.item.createdevent.
Tool calling flow
In Manual mode, when a server-generated response requires a tool call, the following interaction flow occurs:
-
After the client sends a
response.createevent, the server generates a response and detects that a tool call is required. -
The server sends a
response.function_call_arguments.deltaevent, which contains incremental data for the tool call arguments. -
The server sends a
response.function_call_arguments.doneevent to indicate that the transfer of tool call arguments is complete. -
The client executes the tool call and obtains the result.
-
The client sends the tool call result using a
conversation.item.createevent. -
The client sends a
response.createevent to trigger the model to generate the final response. -
The server generates a response based on the tool call result and sends it to the client using
response.audio.deltaorresponse.text.deltaevents.