pub struct RealtimeClient { /* private fields */ }Expand description
Entry point for the realtime API.
Construct with RealtimeClient::new, optionally switch to JWT auth via
RealtimeClient::with_jwt, then start a session with
RealtimeClient::session.
use zai_rs::{model::GLM4_voice, realtime::RealtimeClient};
let session = RealtimeClient::new(key)
.session(GLM4_voice {})
.build()
.await?;Implementations§
Source§impl RealtimeClient
impl RealtimeClient
Sourcepub fn new(api_key: impl Into<String>) -> Self
pub fn new(api_key: impl Into<String>) -> Self
Create a realtime client using Bearer auth and the default endpoints.
Sourcepub fn with_jwt(self, ttl_seconds: i64) -> Self
pub fn with_jwt(self, ttl_seconds: i64) -> Self
Switch to client-side JWT auth, signing tokens valid for ttl_seconds.
Sourcepub fn with_bearer(self) -> Self
pub fn with_bearer(self) -> Self
Switch (back) to server-side Bearer auth.
Sourcepub fn with_endpoint_config(self, config: EndpointConfig) -> Self
pub fn with_endpoint_config(self, config: EndpointConfig) -> Self
Override the full endpoint config (base URLs).
Sourcepub fn with_realtime_base(self, base: impl Into<String>) -> Self
pub fn with_realtime_base(self, base: impl Into<String>) -> Self
Override only the realtime base URL (wss://...).
Sourcepub fn session<M: RealtimeModel>(&self, model: M) -> SessionBuilder
pub fn session<M: RealtimeModel>(&self, model: M) -> SessionBuilder
Begin building a realtime session for model.
The model bound is checked at compile time via super::RealtimeModel.
Sourcepub fn realtime_url(&self) -> String
pub fn realtime_url(&self) -> String
The resolved realtime WebSocket URL.
Trait Implementations§
Source§impl Clone for RealtimeClient
impl Clone for RealtimeClient
Source§fn clone(&self) -> RealtimeClient
fn clone(&self) -> RealtimeClient
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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 RealtimeClient
impl RefUnwindSafe for RealtimeClient
impl Send for RealtimeClient
impl Sync for RealtimeClient
impl Unpin for RealtimeClient
impl UnsafeUnpin for RealtimeClient
impl UnwindSafe for RealtimeClient
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