Skip to main content

rainy_sdk/
lib.rs

1//! # Rainy SDK
2//!
3//! The official Rust SDK for the Rainy API by Enosis Labs (v3 service).
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 the Rainy API v3 service
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 (legacy compatibility, opt-in feature).
56#[cfg(feature = "cowork")]
57pub mod cowork;
58/// Defines error types and result aliases for the SDK.
59pub mod error;
60/// Contains the data models for API requests and responses.
61pub mod models;
62/// Implements retry logic with exponential backoff.
63pub mod retry;
64/// Web search types and options for Tavily-powered search.
65pub mod search;
66/// JWT/session client for Rainy API v3 dashboard endpoints.
67pub mod session;
68
69mod endpoints;
70
71pub use auth::AuthConfig;
72pub use client::RainyClient;
73pub use error::{ApiErrorDetails, ApiErrorResponse, RainyError, Result};
74pub use models::*;
75pub use retry::{retry_with_backoff, RetryConfig};
76pub use session::{
77    CreatedApiKey, LoginResponse, OrgProfile, RainySessionClient, RefreshResponse,
78    SessionApiKeyListItem, SessionConfig, SessionTokens, SessionUser, UsageCreditsResponse,
79    UsageStatsResponse,
80};
81
82// Re-export Cowork types for convenience
83#[cfg(feature = "cowork")]
84#[deprecated(note = "Cowork types are legacy and retained only for v2 compatibility.")]
85pub use cowork::{CoworkCapabilities, CoworkFeatures, CoworkPlan, CoworkUsage};
86// Backward compatibility aliases
87// #[allow(deprecated)]
88// pub use cowork::{CoworkLimits, CoworkTier};
89#[cfg(feature = "cowork")]
90#[deprecated(note = "Cowork helpers are legacy and retained only for v2 compatibility.")]
91pub use endpoints::cowork::get_offline_capabilities;
92
93// Re-export Research types for convenience
94pub use search::{
95    DeepResearchResponse, ResearchApiResponse, ResearchConfig, ResearchResponse, ResearchResult,
96    ResearchSource,
97};
98
99// Re-export commonly used types
100/// Re-export of the `reqwest` crate for convenience.
101///
102/// This allows users of the SDK to use `reqwest` types without adding it
103/// as a direct dependency to their project.
104pub use reqwest;
105/// Re-export of the `serde_json` crate for convenience.
106///
107/// This allows users of the SDK to use `serde_json` types for serialization
108/// and deserialization without adding it as a direct dependency.
109pub use serde_json;
110
111/// The current version of the Rainy SDK.
112///
113/// This value is read from the `CARGO_PKG_VERSION` environment variable at compile time.
114pub const VERSION: &str = env!("CARGO_PKG_VERSION");
115
116/// The default base URL for the Rainy API v3 service.
117///
118/// Note: the v3 service currently exposes its canonical HTTP API under `/api/v1/*`.
119pub const DEFAULT_BASE_URL: &str = "https://rainy-api-v3-us-179843975974.us-east4.run.app";