use std::env;
use std::time::Duration;
use valyu::ValyuClient;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
dotenvy::dotenv().ok();
let api_key = env::var("VALYU_API_KEY")
.expect("VALYU_API_KEY must be set in .env file");
let http_client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.user_agent("valyu-rust-sdk-example/0.1.0")
.build()?;
let client = ValyuClient::with_client(api_key, http_client);
println!("🔍 Searching with custom HTTP client configuration...\n");
let response = client
.search("machine learning frameworks")
.await?;
println!("✅ Success!");
if let Some(results) = &response.results {
println!("📚 Found {} results", results.len());
for (idx, result) in results.iter().take(3).enumerate() {
println!("\n[{}] {}", idx + 1, result.title.as_deref().unwrap_or("Untitled"));
if let Some(url) = &result.url {
println!(" {}", url);
}
}
}
Ok(())
}