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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
//! # 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(())
//! # }
//! ```
//!
//! For Vertex AI, switch the transport endpoint and auth mode:
//!
//! ```rust,no_run
//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
//! use gemini_live::session::{ReconnectPolicy, Session, SessionConfig};
//! use gemini_live::transport::{Auth, Endpoint, TransportConfig};
//! use gemini_live::types::*;
//!
//! let mut session = Session::connect(SessionConfig {
//! transport: TransportConfig {
//! endpoint: Endpoint::VertexAi {
//! location: "us-central1".into(),
//! },
//! auth: Auth::BearerToken(std::env::var("VERTEX_AI_ACCESS_TOKEN")?),
//! ..Default::default()
//! },
//! setup: SetupConfig {
//! model: std::env::var("VERTEX_MODEL")?,
//! generation_config: Some(GenerationConfig {
//! response_modalities: Some(vec![Modality::Text]),
//! ..Default::default()
//! }),
//! ..Default::default()
//! },
//! reconnect: ReconnectPolicy::default(),
//! })
//! .await?;
//! # drop(session);
//! # Ok(())
//! # }
//! ```
//!
//! Enable the optional `vertex-auth` crate feature if you want the library to
//! obtain Vertex bearer tokens from Google Cloud Application Default
//! Credentials instead of passing a static token string.
// Re-export the most commonly used items at the crate root for convenience.
pub use *;
pub use ;
pub use VertexAiApplicationDefaultCredentials;
pub use ;
pub use *;