pub struct RealtimeApi { /* private fields */ }Expand description
Realtime API for voice interactions.
Implementations§
Source§impl RealtimeApi
impl RealtimeApi
Sourcepub fn connect(&self, model: impl Into<String>) -> RealtimeSessionBuilder
pub fn connect(&self, model: impl Into<String>) -> RealtimeSessionBuilder
Start building a realtime session.
§Example
use xai_rust::{XaiClient, Voice, AudioFormat};
let client = XaiClient::from_env()?;
let session = client.realtime()
.connect("grok-4")
.voice(Voice::Ara)
.audio_format(AudioFormat::Pcm16)
.instructions("You are a helpful voice assistant.")
.start()
.await?;Sourcepub fn resume(&self, config: SessionConfig) -> RealtimeSessionBuilder
pub fn resume(&self, config: SessionConfig) -> RealtimeSessionBuilder
Resume a realtime session from an existing session configuration.
This is useful when reconnecting after a dropped socket and you want to restore the same voice/tool/instruction settings in one call.
§Example
use xai_rust::{SessionConfig, Voice, XaiClient};
let client = XaiClient::from_env()?;
let config = SessionConfig::new("grok-4")
.voice(Voice::Rex)
.instructions("Resume with prior settings");
let session = client.realtime().resume(config).start().await?;Trait Implementations§
Source§impl Clone for RealtimeApi
impl Clone for RealtimeApi
Source§fn clone(&self) -> RealtimeApi
fn clone(&self) -> RealtimeApi
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for RealtimeApi
impl !RefUnwindSafe for RealtimeApi
impl Send for RealtimeApi
impl Sync for RealtimeApi
impl Unpin for RealtimeApi
impl UnsafeUnpin for RealtimeApi
impl !UnwindSafe for RealtimeApi
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more