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(())}
Use the DeepSearchRequest builder for anything beyond a plain query, then call client.deep_search(&request):
use valyu::DeepSearchRequest;// Fast mode - lower latency, shorter contentlet req = DeepSearchRequest::new("quantum computing").with_fast_mode(true);// Restrict to specific sources (datasets, domains, or presets)let req = DeepSearchRequest::new("quantum computing applications") .with_included_sources(vec![ "valyu/valyu-arxiv".to_string(), "valyu/valyu-pubmed".to_string(), ]) .with_response_length("medium");// ...or exclude sources instead (use one or the other, not both)let req = DeepSearchRequest::new(query) .with_excluded_sources(vec!["example.com".to_string()]);// Filter by country and date rangelet req = DeepSearchRequest::new("renewable energy policies") .with_country_code("US") .with_date_range("2024-01-01", "2024-12-31");let response = client.deep_search(&req).await?;println!("Cost: ${:.4}", response.total_deduction_dollars.unwrap_or(0.0));
Building a multi-step research flow on top of Search? Consider DeepResearch - a cost-effective autonomous agent purpose-built for reports, diligence, and market sizings.