gemini_chat_api/lib.rs
1//! Async Rust client for the Gemini web chat endpoints.
2//!
3//! This crate talks to the same web endpoints used by Gemini's browser UI and
4//! authenticates with browser cookies. It does not use API keys.
5//!
6//! **Key points**
7//! - Async-first (`reqwest` + `tokio`).
8//! - Requires `__Secure-1PSID`; `__Secure-1PSIDTS` is expected but may be rotated if missing.
9//! - Stateful: the client keeps conversation IDs between calls.
10//!
11//! # Quick start
12//! ```no_run
13//! use gemini_chat_api::{AsyncChatbot, Model, Result, load_cookies};
14//!
15//! #[tokio::main]
16//! async fn main() -> Result<()> {
17//! let (psid, psidts) = load_cookies("cookies.json")?;
18//! let mut chatbot = AsyncChatbot::new(&psid, &psidts, Model::default(), None, 30).await?;
19//!
20//! let response = chatbot.ask("Hello! Tell me a joke.", None).await?;
21//! println!("{}", response.content);
22//! Ok(())
23//! }
24//! ```
25//!
26//! # Image input
27//! ```no_run
28//! use gemini_chat_api::{AsyncChatbot, Model, Result, load_cookies};
29//!
30//! #[tokio::main]
31//! async fn main() -> Result<()> {
32//! let (psid, psidts) = load_cookies("cookies.json")?;
33//! let mut chatbot = AsyncChatbot::new(&psid, &psidts, Model::default(), None, 30).await?;
34//!
35//! let image = std::fs::read("image.png")?;
36//! let response = chatbot.ask("Describe this image.", Some(&image)).await?;
37//! println!("{}", response.content);
38//! Ok(())
39//! }
40//! ```
41
42pub mod client;
43pub mod enums;
44pub mod error;
45pub mod utils;
46
47// Re-exports for convenience
48pub use client::{AsyncChatbot, ChatResponse, Choice, SavedConversation};
49pub use enums::{Endpoint, Model};
50pub use error::{Error, Result};
51pub use utils::load_cookies;