๐ง๏ธ Rainy SDK v0.6.2
The official Rust SDK for the Rainy API by Enosis Labs - a unified interface for multiple AI providers including OpenAI, Google Gemini, Groq, Cerebras, and Enosis Labs' own Astronomer models. Features advanced thinking capabilities, multimodal support, thought signatures, and full OpenAI compatibility.
โจ Features
- ๐ฏ Full OpenAI Compatibility: Drop-in replacement for OpenAI SDK with enhanced features
- ๐ Unified Multi-Provider API: Single interface for OpenAI, Google Gemini, Groq, Cerebras, and Enosis Labs Astronomer models
- ๐ง Advanced Thinking Capabilities: Gemini 3 and 2.5 series models with configurable reasoning levels and thought signatures
- ๐ Type-Safe Authentication: Secure API key management with the
secrecycrate - โก Async/Await: Full async support with Tokio runtime
- ๐ Rich Metadata: Response times, provider info, token usage, credit tracking, and thinking token counts
- ๐ก๏ธ Enhanced Error Handling: Comprehensive error types with retryability and detailed diagnostics
- ๐ Intelligent Retry: Exponential backoff with jitter for resilience
- ๐ Rate Limiting: Optional governor-based rate limiting
- ๐ง Advanced Parameters: Support for response_format, tools, tool_choice, reasoning_effort, logprobs, and streaming
- ๐ Web Search Integration: Built-in Tavily-powered web search with content extraction
- ๐ฅ Cowork Integration: Tier-based feature gating with Free/GoPlus/Plus/Pro/ProPlus plans
- ๐จ Multimodal Support: Image processing and multimodal capabilities (coming soon)
- ๐ Rich Documentation: Complete API documentation with practical examples
๐ฆ Installation
Add this to your Cargo.toml:
[]
= "0.6.2"
= { = "1.47", = ["full"] }
Or installation with cargo:
Requirements
- Rust: 1.92.0 or later
- Platform Support: macOS, Linux, Windows
Optional Features
Enable additional features as needed:
[]
= { = "0.6.2", = ["rate-limiting", "tracing", "cowork"] }
Available features:
rate-limiting: Built-in rate limiting with thegovernorcratetracing: Request/response logging with thetracingcratecowork: Cowork integration for tier-based feature gating (enabled by default)
๐ฏ OpenAI Compatibility
Rainy SDK v0.6.2 provides 100% OpenAI API compatibility while extending support to additional providers. Use Rainy SDK as a drop-in replacement for the official OpenAI SDK:
use ;
// Works exactly like OpenAI SDK
let client = with_api_key?;
let request = new
.with_temperature
.with_response_format;
let = client.chat_completion.await?;
Supported Models (100% OpenAI Compatible)
| Provider | Models | Features |
|---|---|---|
| OpenAI | gpt-4o, gpt-5, gpt-5-pro, o3, o4-mini |
โ Native OpenAI API |
| Google Gemini 3 | gemini-3-pro-preview, gemini-3-flash-preview, gemini-3-pro-image-preview |
โ Thinking, Thought Signatures, Multimodal |
| Google Gemini 2.5 | gemini-2.5-pro, gemini-2.5-flash, gemini-2.5-flash-lite |
โ Thinking, Dynamic Reasoning |
| Groq | llama-3.1-8b-instant, llama-3.3-70b-versatile |
โ OpenAI-compatible API |
| Cerebras | llama3.1-8b |
โ OpenAI-compatible API |
| Enosis Labs | astronomer-1, astronomer-1-max, astronomer-1.5, astronomer-2, astronomer-2-pro |
โ Native Rainy API |
Advanced OpenAI Features
- Tool Calling: Function calling with
toolsandtool_choice - Structured Output: JSON Schema enforcement with
response_format - Reasoning Control:
reasoning_effortparameter for Gemini models - Log Probabilities:
logprobsandtop_logprobssupport - Streaming: OpenAI-compatible delta format streaming with tool calls
๐ง Advanced Thinking Capabilities
Rainy SDK supports advanced thinking capabilities for Google Gemini 3 and 2.5 series models, enabling deeper reasoning and thought preservation across conversations.
Gemini 3 Thinking Features
use ;
let request = new
.with_thinking_config;
let = client.chat_completion.await?;
println!;
// Access thinking token usage
if let Some = metadata.thoughts_token_count
Thought Signatures
Preserve reasoning context across conversation turns with encrypted thought signatures:
use ;
let mut conversation = vec!;
// New message with preserved reasoning context
let enhanced_message = with_parts;
Gemini 2.5 Dynamic Thinking
let config = gemini_2_5;
let request = new
.with_thinking_config;
๐ Web Search Integration
Built-in web search powered by Tavily for real-time information retrieval:
use ;
let search_options = SearchOptions ;
let search_results = client.search_web.await?;
for result in search_results.results
// Extract content from specific URLs
let extracted = client.extract_content.await?;
println!;
๐ฅ Cowork Integration
Tier-based feature gating with Free/GoPlus/Plus/Pro/ProPlus plans:
use ;
let cowork_client = new;
let status = cowork_client.get_cowork_status.await?;
println!;
println!;
// Check feature availability
if status.can_use_web_research
if status.can_use_document_export
๐ Quick Start
use ;
use Error;
async
๐ API Documentation
Authentication
The SDK uses API key authentication. It's recommended to load the key from an environment variable.
use RainyClient;
// Load API key from environment and create client
let api_key = var.expect;
let client = with_api_key?;
Core Operations
Health Check
Verify the API status.
# use RainyClient;
# async
Chat Completions
Create a standard chat completion.
# use ;
# async
Streaming Chat Completions
Receive the response as a stream of events.
# use ;
# use StreamExt;
# async
Usage Statistics
Get credit and usage statistics.
# use RainyClient;
# async
API Key Management
Manage API keys programmatically.
# use RainyClient;
# async
๐งช Examples
Explore the examples/ directory for comprehensive usage examples:
- Basic Usage (
examples/basic_usage.rs): Complete walkthrough of all SDK features. - Chat Completion (
examples/chat_completion.rs): Advanced chat completion patterns. - Error Handling (
examples/error_handling.rs): Demonstrates how to handle different error types.
Run examples with:
# Set your API key
# Run basic usage example
# Run chat completion example
๐ก๏ธ Security Considerations
-
API Key Management: This SDK utilizes the
secrecycrate to handle the API key, ensuring it is securely stored in memory and zeroed out upon being dropped. However, it is still crucial to manage theRainyClient's lifecycle carefully within your application to minimize exposure. -
Rate Limiting: The optional
rate-limitingfeature is intended as a client-side safeguard to prevent accidental overuse and to act as a "good citizen" towards the API. It is not a security mechanism and can be bypassed by a malicious actor. For robust abuse prevention, you must implement server-side monitoring, usage quotas, and API key management through your Enosis Labs dashboard. -
TLS Configuration: The client is hardened to use modern, secure TLS settings (TLS 1.2+ via the
rustlsbackend) and to only allow HTTPS connections, providing strong protection against network interception.
๐๏ธ Architecture
The SDK is built with a modular architecture:
src/
โโโ auth.rs # Authentication and API key management
โโโ client.rs # Main API client with request handling
โโโ cowork.rs # Tier-based feature gating and capabilities
โโโ endpoints/ # API endpoint implementations (internal)
โโโ error.rs # Comprehensive error handling
โโโ models.rs # Data structures and type definitions
โโโ retry.rs # Retry logic with exponential backoff
โโโ search.rs # Web search and content extraction
โโโ lib.rs # Public API and module exports
Key Modules
client.rs: CoreRainyClientwith async HTTP handling and response processingmodels.rs: Complete type system includingChatCompletionRequest,ThinkingConfig,EnhancedChatMessageauth.rs: Secure authentication with thesecrecycrate for API key managementcowork.rs: Integration with Enosis Labs' tier system (Free/GoPlus/Plus/Pro/ProPlus)search.rs: Tavily-powered web search with content extraction capabilitiesendpoints/: Internal API endpoint implementations (chat, health, keys, usage, user)
๐ค Contributing
We welcome contributions! Please see our Contributing Guide for details on:
- Setting up your development environment
- Code style and standards
- Testing guidelines
- Submitting pull requests
๐ License
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
๐ Contact & Support
- Website: enosislabs.com
- Email: hello@enosislabs.com
- GitHub: github.com/enosislabs
- Documentation: docs.rs/rainy-sdk
โ ๏ธ Disclaimer
This SDK is developed by Enosis Labs and is not officially affiliated with any AI provider mentioned (OpenAI, Anthropic, Google, etc.). The Rainy API serves as an independent gateway service that provides unified access to multiple AI providers.