Get your API key from the Valyu Platform ($10 free credits, $20 with a work email).
use std::env;use valyu::ValyuClient;let api_key = env::var("VALYU_API_KEY").expect("VALYU_API_KEY must be set");let client = ValyuClient::new(api_key); // or ValyuClient::new("your-api-key")
For local development, load .env with the dotenvy crate (dotenvy::dotenv().ok();) before reading the variable.
use valyu::ValyuClient;#[tokio::main]async fn main() -> Result<(), Box<dyn std::error::Error>> { let client = ValyuClient::new("your-api-key"); let response = client.search("What are the latest developments in quantum computing?").await?; if let Some(results) = &response.results { for result in results { println!("{} - {}", result.title.as_deref().unwrap_or("Untitled"), result.url.as_deref().unwrap_or("No URL")); } } Ok(())}
For multi-step synthesis or cited reports, reach for DeepResearch - a cost-effective autonomous agent built on the Valyu search engine - rather than hand-rolling a search loop.
Errors surface as ValyuError variants (InvalidApiKey, RateLimitExceeded, ServiceUnavailable, InvalidRequest(msg)). To configure timeouts or other HTTP settings, build your own reqwest::Client and pass it in: