pub struct SessionBuilder { /* private fields */ }realtime only.Expand description
Builder for an RealtimeSession.
Produced by super::client::RealtimeClient::session. Configure the
session defaults, then SessionBuilder::build opens the WebSocket and
sends the initial session.update.
Implementations§
Source§impl SessionBuilder
impl SessionBuilder
Sourcepub fn instructions(self, instructions: impl Into<String>) -> Self
pub fn instructions(self, instructions: impl Into<String>) -> Self
System instructions guiding the model.
Sourcepub fn turn_detection(self, vad: TurnDetectionType) -> Self
pub fn turn_detection(self, vad: TurnDetectionType) -> Self
VAD strategy (defaults to client-VAD).
Sourcepub fn create_response_on_vad(self, enabled: bool) -> Self
pub fn create_response_on_vad(self, enabled: bool) -> Self
Configure whether server VAD automatically creates a response at the end of a detected speech turn.
Sourcepub fn interrupt_response_on_vad(self, enabled: bool) -> Self
pub fn interrupt_response_on_vad(self, enabled: bool) -> Self
Configure whether server VAD interrupts an in-progress response when new speech begins.
Sourcepub fn vad_threshold(self, threshold: f64) -> Self
pub fn vad_threshold(self, threshold: f64) -> Self
Configure the server-VAD activation threshold (0.0..=1.0).
Sourcepub fn vad_prefix_padding_ms(self, milliseconds: u32) -> Self
pub fn vad_prefix_padding_ms(self, milliseconds: u32) -> Self
Configure how much audio before detected speech is retained.
Sourcepub fn vad_silence_duration_ms(self, milliseconds: u32) -> Self
pub fn vad_silence_duration_ms(self, milliseconds: u32) -> Self
Configure how much silence ends a server-VAD turn.
Sourcepub fn input_audio_format(self, format: InputAudioFormat) -> Self
pub fn input_audio_format(self, format: InputAudioFormat) -> Self
Input audio format (defaults to 16 kHz WAV).
Sourcepub fn output_audio_format(self, format: OutputAudioFormat) -> Self
pub fn output_audio_format(self, format: OutputAudioFormat) -> Self
Output audio format (defaults to PCM).
Sourcepub fn modalities(
self,
modalities: impl IntoIterator<Item = RealtimeModality>,
) -> Self
pub fn modalities( self, modalities: impl IntoIterator<Item = RealtimeModality>, ) -> Self
Output modalities (text, audio, or both).
Sourcepub fn voice(self, voice: RealtimeVoice) -> Self
pub fn voice(self, voice: RealtimeVoice) -> Self
Voice used for generated audio.
Sourcepub fn temperature(self, temperature: f64) -> Self
pub fn temperature(self, temperature: f64) -> Self
Sampling temperature. Values outside 0.0..=1.0 are rejected by
Self::build before a connection is opened.
Sourcepub fn max_response_output_tokens(self, tokens: u16) -> Self
pub fn max_response_output_tokens(self, tokens: u16) -> Self
Maximum response text-token count. Values above 1024 are rejected by
Self::build before a connection is opened.
Sourcepub fn input_audio_noise_reduction(self, profile: NoiseReductionType) -> Self
pub fn input_audio_noise_reduction(self, profile: NoiseReductionType) -> Self
Configure input-audio noise reduction for the microphone placement.
Sourcepub fn auto_search(self, enabled: bool) -> Self
pub fn auto_search(self, enabled: bool) -> Self
Enable/disable the server-side built-in web search.
Sourcepub fn greeting_config(self, greeting: GreetingConfig) -> Self
pub fn greeting_config(self, greeting: GreetingConfig) -> Self
Configure an optional server-generated greeting.
Sourcepub fn tools(self, tools: Vec<RealtimeTool>) -> Self
pub fn tools(self, tools: Vec<RealtimeTool>) -> Self
Register function tools.
Sourcepub fn session_config(self, config: SessionConfig) -> Self
pub fn session_config(self, config: SessionConfig) -> Self
Override the entire session config.
The model is still taken from RealtimeClient::session
and replaces config.model during Self::build.
Sourcepub async fn build(self) -> ZaiResult<RealtimeSession>
pub async fn build(self) -> ZaiResult<RealtimeSession>
Open the WebSocket, send session.update, and spawn the event loop.