Skip to main content
The Valyu Rust SDK gives you search, content extraction, answers, and deep research through one type-safe, async API built on tokio and reqwest.
This SDK is in alpha. The API is stable, but some interfaces may change based on feedback.

Paste into your AI coding assistant to add the Valyu Rust SDK and make your first search call.

Open in Cursor

Install

[dependencies]
valyu = "0.3"
tokio = { version = "1", features = ["full"] }

Authenticate

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.

First call

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(())
}

APIs

Search

Search web and proprietary sources

Contents

Extract and process web content

Answer

Generate cited answers from search

DeepResearch

Autonomous async research reports
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.

Error handling and custom clients

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:
use valyu::ValyuClient;
use std::time::Duration;

let http_client = reqwest::Client::builder()
    .timeout(Duration::from_secs(30))
    .build()?;

let client = ValyuClient::with_client("your-api-key", http_client);

Support