google_search/
google_search.rs1use gemini_rust::{Gemini, Tool};
2use std::env;
3
4#[tokio::main]
5async fn main() -> Result<(), Box<dyn std::error::Error>> {
6 let api_key = env::var("GOOGLE_API_KEY")
8 .expect("GOOGLE_API_KEY environment variable not set");
9
10 let client = Gemini::new(api_key);
12
13 println!("--- Google Search tool example ---");
14
15 let google_search_tool = Tool::google_search();
17
18 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}