1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
//! # Realtime API (WebSocket)
//!
//! Realtime text and audio conversations over the GLM-Realtime WebSocket
//! protocol (`wss://open.bigmodel.cn/api/paas/v4/realtime`). The protocol types
//! also model passive-video frames, while
//! [`RealtimeSession`](crate::realtime::RealtimeSession) currently exposes
//! high-level send methods for text and audio.
//!
//! Verified against the official protocol:
//! - <https://github.com/MetaGLM/glm-realtime-sdk/blob/main/GLM-Realtime-doc-for-llm.md>
//! - <https://docs.bigmodel.cn/cn/asyncapi/realtime>
//!
//! ## Quick start
//!
//! ```no_run
//! use zai_rs::{
//! model::GLM4_voice,
//! realtime::{RealtimeClient, TurnDetectionType},
//! };
//!
//! # async fn demo(key: String) -> zai_rs::ZaiResult<()> {
//! let session = RealtimeClient::new(key)
//! .session(GLM4_voice {})
//! .turn_detection(TurnDetectionType::ServerVad)
//! .build()
//! .await?;
//! session.send_text("你好").await?;
//! session.create_response().await?;
//! # Ok(())
//! # }
//! ```
//!
//! ## Auth modes
//!
//! - **Bearer** (default, server-side): `Authorization: Bearer {API_KEY}`.
//! - **JWT**: `.with_jwt(ttl_seconds)` derives a short-lived token locally and
//! sends that token, rather than the raw API key, in the WebSocket handshake.
//! Generating the token on a trusted server before handing it to an untrusted
//! browser or device is still the application's responsibility.
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
use crateModelName;
/// Marker trait for model ids usable in a realtime session.
///
/// Continues the crate's type-state + marker-trait philosophy: only valid
/// realtime model ids satisfy this bound, so
/// [`RealtimeClient::session`](client::RealtimeClient::session) is validated at
/// compile time. Any type generated by [`define_model_type!`] that should be
/// usable over realtime simply implements this marker.
///
/// [`define_model_type!`]: crate::define_model_type