1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
//! # Valyu Rust SDK
//!
//! Official Rust SDK for the [Valyu AI API](https://valyu.ai).
//!
//! Valyu provides advanced AI-powered search capabilities, combining web search
//! with proprietary data sources to deliver comprehensive, relevant results.
//!
//! ## Quick Start
//!
//! Add this to your `Cargo.toml`:
//!
//! ```toml
//! [dependencies]
//! valyu = "0.1"
//! tokio = { version = "1", features = ["full"] }
//! ```
//!
//! ## Basic Usage
//!
//! ```no_run
//! use valyu::ValyuClient;
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! // Create a client with your API key
//! let client = ValyuClient::new("your-api-key");
//!
//! // Perform a simple search
//! let response = client.search("quantum computing").await?;
//!
//! // Process results
//! 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(())
//! }
//! ```
//!
//! ## Advanced Usage
//!
//! Use the builder pattern for more control over search parameters:
//!
//! ```no_run
//! use valyu::{ValyuClient, DeepSearchRequest};
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let client = ValyuClient::new("your-api-key");
//!
//! let request = DeepSearchRequest::new("artificial intelligence")
//! .with_max_results(10)
//! .with_search_type("web")
//! .with_fast_mode(true)
//! .with_response_length("medium")
//! .with_date_range("2024-01-01", "2024-12-31");
//!
//! let response = client.deep_search(&request).await?;
//!
//! println!("Transaction ID: {}", response.tx_id.as_deref().unwrap_or("N/A"));
//! println!("Cost: ${:.4}", response.total_deduction_dollars.unwrap_or(0.0));
//!
//! Ok(())
//! }
//! ```
//!
//! ## Features
//!
//! - **Type-safe API**: Full type coverage with serde support
//! - **Async/await**: Built on tokio and reqwest for async operations
//! - **Builder pattern**: Fluent interface for constructing requests
//! - **Comprehensive error handling**: Detailed error types for all failure cases
//! - **Well documented**: Extensive documentation and examples
//!
//! ## Error Handling
//!
//! The SDK uses a custom [`ValyuError`] type for all errors:
//!
//! ```no_run
//! use valyu::{ValyuClient, ValyuError};
//!
//! #[tokio::main]
//! async fn main() {
//! let client = ValyuClient::new("your-api-key");
//!
//! match client.search("test").await {
//! Ok(response) => println!("Success!"),
//! Err(ValyuError::InvalidApiKey) => eprintln!("Invalid API key"),
//! Err(ValyuError::RateLimitExceeded) => eprintln!("Rate limit exceeded"),
//! Err(e) => eprintln!("Error: {}", e),
//! }
//! }
//! ```
// Re-export public API
pub use ValyuClient;
pub use ;
pub use ;