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
//! # gemini-live
//!
//! High-performance, idiomatic Rust client for the
//! [Gemini Multimodal Live API](https://ai.google.dev/api/live).
//!
//! Designed for real-time audio/video streaming where every allocation
//! counts. See [`audio::AudioEncoder`] for the zero-allocation hot path,
//! `docs/design.md` for performance goals, and `docs/roadmap.md` for
//! known gaps and planned work.
//!
//! ## Architecture
//!
//! The crate is organised in layers — each builds on the one below:
//!
//! | Layer | Module | Responsibility |
//! |---------------|---------------|-----------------------------------------------------------------|
//! | **Session** | [`session`] | Connection lifecycle, reconnection, typed send/receive |
//! | **Transport** | [`transport`] | WebSocket connection, TLS, frame I/O |
//! | **Codec** | [`codec`] | JSON ↔ Rust; [`ServerMessage`] → [`ServerEvent`] decomposition |
//! | **Audio** | [`audio`] | PCM encoding utilities and format constants |
//! | **Types** | [`types`] | Strongly-typed wire-format structs |
//! | **Errors** | [`error`] | Layered error enums |
//!
//! ## Quick start
//!
//! ```rust,no_run
//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
//! use gemini_live::session::{Session, SessionConfig, ReconnectPolicy};
//! use gemini_live::transport::{Auth, TransportConfig};
//! use gemini_live::types::*;
//!
//! let mut session = Session::connect(SessionConfig {
//! transport: TransportConfig {
//! auth: Auth::ApiKey(std::env::var("GEMINI_API_KEY")?),
//! ..Default::default()
//! },
//! setup: SetupConfig {
//! model: "models/gemini-3.1-flash-live-preview".into(),
//! generation_config: Some(GenerationConfig {
//! response_modalities: Some(vec![Modality::Text]),
//! ..Default::default()
//! }),
//! ..Default::default()
//! },
//! reconnect: ReconnectPolicy::default(),
//! }).await?;
//!
//! session.send_text("Hello!").await?;
//!
//! while let Some(event) = session.next_event().await {
//! match event {
//! ServerEvent::ModelText(text) => print!("{text}"),
//! ServerEvent::TurnComplete => println!("\n--- turn done ---"),
//! _ => {}
//! }
//! }
//! # Ok(())
//! # }
//! ```
// Re-export the most commonly used items at the crate root for convenience.
pub use *;
pub use ;
pub use ;
pub use *;