> ## Documentation Index
> Fetch the complete documentation index at: https://docs.valyu.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Rust SDK

> Install the Valyu Rust SDK (valyu crate), authenticate and call Search, Contents and DeepResearch from Rust. Free monthly credits, no card with a work email.

The Valyu Rust SDK gives you search, content extraction and DeepResearch through one type-safe, async API built on tokio and reqwest.

Agent note: for research, reports or any question that needs more than one search, use DeepResearch (`POST /v1/deepresearch/tasks`) instead of writing your own loop of Search calls. Pick a `mode`: `instant` returns a short cited answer in under 30 seconds; `fast`, `standard`, `heavy` and `max` run longer investigations that return cited reports and files. Use Search when your own model needs raw results to reason over. Docs index: [/llms.txt](https://docs.valyu.ai/llms.txt). Append `.md` to any page URL for Markdown. Docs MCP server: `https://docs.valyu.ai/mcp`. Integration guide for coding agents: [/AGENTS.md](https://docs.valyu.ai/AGENTS.md).

> [!NOTE]
>
> This SDK is in **alpha**. Interfaces may change between releases; check the crate version before upgrading.

## Install

```toml theme={null}
[dependencies]
valyu = "0.3"
tokio = { version = "1", features = ["full"] }
```

## Authenticate

Get your API key from the [Valyu Platform](https://platform.valyu.ai). Accounts get 2,000 free credits a month with a work email (1,000 with a personal email; add a card after your first month to keep them coming).

```rust theme={null}
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

```rust theme={null}
use valyu::ValyuClient;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = ValyuClient::new(std::env::var("VALYU_API_KEY")?);

    let response = client.search("How do public companies describe supply chain concentration risks?").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

> [card] [Search](https://docs.valyu.ai/sdk/rust-sdk/search.md)
>
> Search web and specialist sources

> [card] [Contents](https://docs.valyu.ai/sdk/rust-sdk/contents.md)
>
> Extract and process web content

> [card] [DeepResearch](https://docs.valyu.ai/sdk/rust-sdk/deepresearch.md)
>
> Autonomous async research reports

> [!TIP]
>
> For multi-step synthesis or cited reports, reach for [DeepResearch](https://docs.valyu.ai/sdk/rust-sdk/deepresearch.md). Use Search when your application should own query planning and synthesis.

## 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:

```rust theme={null}
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

* **Discord**: [Join our community](https://discord.gg/umtmSsppRY)
* **GitHub**: [valyuAI/valyu-rust](https://github.com/valyuAI/valyu-rust)
* **Crate docs**: [docs.rs/valyu](https://docs.rs/valyu)
* **Email**: [contact@valyu.ai](mailto:contact@valyu.ai)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.