pub struct RealtimeClient { /* private fields */ }realtime only.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::GLM_realtime_flash, realtime::RealtimeClient};
let session = RealtimeClient::new(key)
.session(GLM_realtime_flash {})
.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 JWT auth, signing tokens valid for ttl_seconds.
The value is validated when the session is built and must be between one second and seven days, inclusive.
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 try_with_realtime_base(self, base: impl AsRef<str>) -> ZaiResult<Self>
pub fn try_with_realtime_base(self, base: impl AsRef<str>) -> ZaiResult<Self>
Override only the realtime base URL (wss://...).
Only the realtime family is replaced; all other endpoint overrides are preserved. Invalid or insecure public URLs return an error.
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
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more