Skip to main content

Crate gemini_chat_api

Crate gemini_chat_api 

Source
Expand description

Async Rust client for Google Gemini Chat API.

This library provides an async HTTP client for interacting with Google Gemini, similar to the Python gemini_client library.

§Example

use gemini_chat_api::{AsyncChatbot, Model, load_cookies};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Load cookies from file
    let (psid, psidts) = load_cookies("cookies.json")?;

    // Create chatbot
    let mut chatbot = AsyncChatbot::new(&psid, &psidts, Model::default(), None, 30).await?;

    // Send message
    let response = chatbot.ask("Hello! Tell me a joke.", None).await?;
    println!("{}", response.content);

    Ok(())
}

Re-exports§

pub use client::AsyncChatbot;
pub use client::ChatResponse;
pub use client::Choice;
pub use client::SavedConversation;
pub use enums::Endpoint;
pub use enums::Model;
pub use error::Error;
pub use error::Result;
pub use utils::load_cookies;

Modules§

client
Async client for Google Gemini Chat API.
enums
Enums and constants for Gemini API endpoints, headers, and models.
error
Error types for the Gemini Chat API client.
utils
Utility functions for cookie loading and file upload.