#gemini-api #google-gemini #gemini #google-api

gemini_light_rs

A Rust client for interacting with Google's Gemini API

2 releases

Uses new Rust 2024

0.1.1 Sep 2, 2025
0.1.0 Jul 10, 2025

#45 in #gemini-api

MIT/Apache

17KB
255 lines

gemini_light_rs

A Rust client for interacting with Google's Gemini generative language models. Supports conversation memory, stateless calls, and easy integration.

Features

  • Async chat with Gemini models
  • Conversation memory (contextual chat)
  • Simple, ergonomic API

Installation

Add to your Cargo.toml:

[dependencies]
gemini_light_rs = "0.1.0"

API Key Setup

You need a Google Gemini API key pass the key and model as arguments to Client::new.

Example Usage

use gemini_light_rs::Client;

#[tokio::main]
async fn main() {
    let mut c = Client::new("your_api_key", "gemini-2.5-flash");
    let res = c.chat("Hello my name is Max").await;
    if let Err(e) = res {
        panic!("{}", e);
    }
    let res2 = c.chat("Whats my name answer in single word only (answer containing more than 1 word will be treated as incorrect)").await;
    let name = res2.unwrap_or_else(|_| "Error".to_string());
    println!("Gemini answered: {}", name);
    assert_eq!(&name, "Max");
}

API Overview

  • Client::new(api_key, model) – create a new client
  • client.chat(input) – send a message, get a response (with memory)
  • client.chat_once(input) – stateless single message
  • client.clear_memory() – clear conversation history

Dependencies

~6–14MB
~230K SLoC