A comprehensive Rust client for Google's Gemini API with full feature support.
- ποΈ Structured Output - Type-safe JSON schema generation
- π§ Thinking Mode - Gemini 2.5's reasoning capabilities
- π§ Function Calling - Parallel and compositional functions
- π Grounding - Google Search and URL context
- πΎ Context Caching - Efficient token management
- π Streaming - Real-time response streaming
- π Automatic Retries - With exponential backoff
- π¦ 100% Rust - Type-safe and memory-safe
Add to your Cargo.toml:
[dependencies]
gemini-rust = "0.1"Or with specific features:
[dependencies]
gemini-rust = { version = "0.1", features = ["grounding", "caching"] }use gemini_rust::prelude::*;
#[tokio::main]
async fn main() -> Result<()> {
// Create client from GEMINI_API_KEY environment variable
let client = GeminiClient::from_env()?;
// Generate content
let response = client
.generate_content(None, GenerateContentRequest {
contents: vec![Content::user("Hello, Gemini!")],
..Default::default()
})
.await?;
println!("{:?}", response);
Ok(())
}Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE)