Files
geologia/examples/generate-content.rs
Andre Cipriani Bandarra 414299cdc7 Add Apache 2.0 license
- Add LICENSE file with Apache 2.0 text
- Add license field to Cargo.toml
- Add copyright and SPDX headers to all source files
- Add License section to README.md
2026-04-18 08:07:11 +01:00

30 lines
886 B
Rust

// Copyright 2026 Andre Cipriani Bandarra
// SPDX-License-Identifier: Apache-2.0
use std::{env, error::Error};
use geologia::prelude::{Content, GeminiClient, GenerateContentRequest, Role};
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
tracing_subscriber::fmt().init();
let _ = dotenvy::dotenv();
let api_key = env::var("GEMINI_API_KEY")?;
let gemini_client = GeminiClient::new(api_key);
let prompt = vec![
Content::builder()
.role(Role::User)
.add_text_part("What is the airspeed of an unladen swallow?")
.build(),
];
let request = GenerateContentRequest::builder().contents(prompt).build();
let response = gemini_client
.generate_content(&request, "gemini-3-pro-preview")
.await?;
println!("Response: {:?}", response.candidates[0].get_text().unwrap());
Ok(())
}