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/// Defines error types and result aliases for the SDK.
56pub mod error;
57/// Contains the data models for API requests and responses.
58pub mod models;
59/// Implements retry logic with exponential backoff.
60pub mod retry;
61
62mod endpoints;
63
64pub use auth::AuthConfig;
65pub use client::RainyClient;
66pub use error::{ApiErrorDetails, ApiErrorResponse, RainyError, Result};
67pub use models::*;
68pub use retry::{retry_with_backoff, RetryConfig};
69
70// Re-export commonly used types
71/// Re-export of the `reqwest` crate for convenience.
72///
73/// This allows users of the SDK to use `reqwest` types without adding it
74/// as a direct dependency to their project.
75pub use reqwest;
76/// Re-export of the `serde_json` crate for convenience.
77///
78/// This allows users of the SDK to use `serde_json` types for serialization
79/// and deserialization without adding it as a direct dependency.
80pub use serde_json;
81
82/// The current version of the Rainy SDK.
83///
84/// This value is read from the `CARGO_PKG_VERSION` environment variable at compile time.
85pub const VERSION: &str = env!("CARGO_PKG_VERSION");
86
87/// The default base URL for the Rainy API.
88///
89/// This constant is used by the `RainyClient` as the default API endpoint.
90pub const DEFAULT_BASE_URL: &str = "https://api.enosislabs.com";