rainy_sdk/
lib.rs

1//! # Rainy SDK
2//!
3//! The official Rust SDK for the Rainy API by Enosis Labs.
4//!
5//! This SDK provides a clean, idiomatic Rust interface for interacting with
6//! the Rainy API, which unifies multiple AI providers under a single API.
7//!
8//! ## Features
9//!
10//! - **Idiomatic Rust API**: Clean, type-safe interfaces
11//! - **Automatic Authentication**: API key and admin key management
12//! - **Rate Limiting**: Built-in rate limit handling
13//! - **Error Handling**: Comprehensive error types and handling
14//! - **Async Support**: Full async/await support with Tokio
15//!
16//! ## Quick Start
17//!
18//! ```rust,no_run
19//! use rainy_sdk::RainyClient;
20//!
21//! #[tokio::main]
22//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
23//!     // Create client with API key - automatically connects to api.enosislabs.com
24//!     let client = RainyClient::with_api_key("your-api-key")?;
25//!
26//!     // Check API health
27//!     let health = client.health_check().await?;
28//!     println!("API Status: {:?}", health.status);
29//!
30//!     Ok(())
31//! }
32//! ```
33//!
34//! ## Authentication
35//!
36//! The SDK uses API key authentication:
37//!
38//! ### API Key Authentication
39//!
40//! ```rust,no_run
41//! # use rainy_sdk::RainyClient;
42//! # #[tokio::main]
43//! # async fn main() -> Result<(), Box<dyn std::error::Error>> {
44//! // Simplest way to create a client
45//! let client = RainyClient::with_api_key("ra-20250125143052Ab3Cd9Ef2Gh5Ik8Lm4Np7Qr")?;
46//! # Ok(())
47//! # }
48//! ```
49//!
50
51/// Handles authentication and API key management.
52pub mod auth;
53/// The main client for interacting with the Rainy API.
54pub mod client;
55/// Cowork integration: tiers, capabilities, and feature gating.
56pub mod cowork;
57/// Defines error types and result aliases for the SDK.
58pub mod error;
59/// Contains the data models for API requests and responses.
60pub mod models;
61/// Implements retry logic with exponential backoff.
62pub mod retry;
63/// Web search types and options for Tavily-powered search.
64pub mod search;
65
66mod endpoints;
67
68pub use auth::AuthConfig;
69pub use client::RainyClient;
70pub use error::{ApiErrorDetails, ApiErrorResponse, RainyError, Result};
71pub use models::*;
72pub use retry::{retry_with_backoff, RetryConfig};
73
74// Re-export Cowork types for convenience
75pub use cowork::{CoworkCapabilities, CoworkFeatures, CoworkPlan, CoworkUsage};
76// Backward compatibility aliases
77// #[allow(deprecated)]
78// pub use cowork::{CoworkLimits, CoworkTier};
79pub use endpoints::cowork::get_offline_capabilities;
80
81// Re-export Search types for convenience
82pub use search::{ExtractResponse, ExtractedContent, SearchOptions, SearchResponse, SearchResult};
83
84// Re-export commonly used types
85/// Re-export of the `reqwest` crate for convenience.
86///
87/// This allows users of the SDK to use `reqwest` types without adding it
88/// as a direct dependency to their project.
89pub use reqwest;
90/// Re-export of the `serde_json` crate for convenience.
91///
92/// This allows users of the SDK to use `serde_json` types for serialization
93/// and deserialization without adding it as a direct dependency.
94pub use serde_json;
95
96/// The current version of the Rainy SDK.
97///
98/// This value is read from the `CARGO_PKG_VERSION` environment variable at compile time.
99pub const VERSION: &str = env!("CARGO_PKG_VERSION");
100
101/// The default base URL for the Rainy API.
102///
103/// This constant is used by the `RainyClient` as the default API endpoint.
104pub const DEFAULT_BASE_URL: &str = "https://rainy-api-v2-179843975974.us-west1.run.app";