google_search/
google_search.rs

1use gemini_rust::{Gemini, Tool};
2use std::env;
3
4#[tokio::main]
5async fn main() -> Result<(), Box<dyn std::error::Error>> {
6    // Get API key from environment variable
7    let api_key = env::var("GOOGLE_API_KEY")
8        .expect("GOOGLE_API_KEY environment variable not set");
9
10    // Create client
11    let client = Gemini::new(api_key);
12
13    println!("--- Google Search tool example ---");
14    
15    // Create a Google Search tool
16    let google_search_tool = Tool::google_search();
17
18    // Create a request with Google Search tool
19    let response = client
20        .generate_content()
21        .with_user_message("What is the current Google stock price?")
22        .with_tool(google_search_tool)
23        .execute()
24        .await?;
25
26    println!("Response: {}", response.text());
27
28    Ok(())
29}