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
64mod endpoints;
65
66pub use auth::AuthConfig;
67pub use client::RainyClient;
68pub use error::{ApiErrorDetails, ApiErrorResponse, RainyError, Result};
69pub use models::*;
70pub use retry::{retry_with_backoff, RetryConfig};
71
72// Re-export Cowork types for convenience
73pub use cowork::{CoworkCapabilities, CoworkFeatures, CoworkPlan, CoworkUsage};
74// Backward compatibility aliases
75#[allow(deprecated)]
76pub use cowork::{CoworkLimits, CoworkTier};
77pub use endpoints::cowork::get_offline_capabilities;
78
79// Re-export commonly used types
80/// Re-export of the `reqwest` crate for convenience.
81///
82/// This allows users of the SDK to use `reqwest` types without adding it
83/// as a direct dependency to their project.
84pub use reqwest;
85/// Re-export of the `serde_json` crate for convenience.
86///
87/// This allows users of the SDK to use `serde_json` types for serialization
88/// and deserialization without adding it as a direct dependency.
89pub use serde_json;
90
91/// The current version of the Rainy SDK.
92///
93/// This value is read from the `CARGO_PKG_VERSION` environment variable at compile time.
94pub const VERSION: &str = env!("CARGO_PKG_VERSION");
95
96/// The default base URL for the Rainy API.
97///
98/// This constant is used by the `RainyClient` as the default API endpoint.
99pub const DEFAULT_BASE_URL: &str = "https://api.enosislabs.com";