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
//! Async Rust client for the Gemini web chat endpoints.
//!
//! This crate talks to the same web endpoints used by Gemini's browser UI and
//! authenticates with browser cookies. It does not use API keys.
//!
//! **Key points**
//! - Async-first (`reqwest` + `tokio`).
//! - Requires `__Secure-1PSID`; `__Secure-1PSIDTS` is expected but may be rotated if missing.
//! - Stateful: the client keeps conversation IDs between calls.
//!
//! # Quick start
//! ```no_run
//! use gemini_chat_api::{AsyncChatbot, Model, Result, load_cookies};
//!
//! #[tokio::main]
//! async fn main() -> Result<()> {
//! let (psid, psidts) = load_cookies("cookies.json")?;
//! let mut chatbot = AsyncChatbot::new(&psid, &psidts, Model::default(), None, 30).await?;
//!
//! let response = chatbot.ask("Hello! Tell me a joke.", None).await?;
//! println!("{}", response.content);
//! Ok(())
//! }
//! ```
//!
//! # Image input
//! ```no_run
//! use gemini_chat_api::{AsyncChatbot, Model, Result, load_cookies};
//!
//! #[tokio::main]
//! async fn main() -> Result<()> {
//! let (psid, psidts) = load_cookies("cookies.json")?;
//! let mut chatbot = AsyncChatbot::new(&psid, &psidts, Model::default(), None, 30).await?;
//!
//! let image = std::fs::read("image.png")?;
//! let response = chatbot.ask("Describe this image.", Some(&image)).await?;
//! println!("{}", response.content);
//! Ok(())
//! }
//! ```
// Re-exports for convenience
pub use ;
pub use ;
pub use ;
pub use load_cookies;