██████╗ ██████╗ █████╗ ██╗ ██╔══██╗██╔══██╗██╔══██╗██║ ██████╔╝██║ ██║███████║██║ ██╔══██╗██║ ██║██╔══██║██║ ██║ ██║██████╔╝██║ ██║██║ ╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═╝╚═╝
rdai — Multi-Brain AI Orchestrator
One Python SDK. Any AI Provider. Zero Downtime.
Route requests across Gemini, OpenAI, Groq, Claude and more — with automatic failover, live health checks, and an interactive CLI.
👑 Created by: Ranajit Dhar | 🌐 ranajitdhar.in | 📦 PyPI | Version: v1.0.2
⚡ The Problem
One provider fails (rate limit / crash / timeout)
↓
rdai automatically switches to the next
↓
Your app never goes down
rdai is a self-healing Python SDK that lets you call multiple AI models — Gemini, OpenAI, Claude, DeepSeek, and more — through one unified interface. It auto-discovers your API keys, picks the best provider for your strategy, and silently fails over to a backup the moment something breaks.
🩺 See it in action — rdai doctor
The built-in doctor pings every configured provider live and reports real status, not guesses.
Real provider diagnostics — live authentication, reachability, and latency in one command.
One command tells you exactly which providers are wired up, authenticated, and reachable — before you ship.
📦 Installation
pip install rdai
🚦 Quick Start
rdai init # interactive wizard → choose providers, strategy, generate .env + rdai.yaml
# add your API keys to the generated .env file
rdai doctor # verify every provider is alive
GEMINI_API_KEY=your_key_here
GROQ_API_KEY=your_key_here
OPENAI_API_KEY=your_key_here
# add others as selected...
(Your API keys stay strictly local — never hardcoded, never sent anywhere but the provider you're calling.)
💻 Python SDK Usage
No need to learn ten different SDKs — rdai standardizes everything into one call.
from rdai import AI
ai = AI() # auto-loads your rdai.yaml strategy
response = ai.generate("Write a multi-agent orchestration script in Python.")
print(response)
# Hello! Here's your answer...
If the first model fails, rdai silently falls back to the next one in your chain — no extra code required.
🎯 Overriding Default Models
By default, rdai uses the most stable models for each provider (e.g., gemini-2.5-pro, gpt-4o-mini). However, you have full control to override them by passing a models dictionary:
from rdai import AI
# Override the defaults with your preferred models
ai = AI(models={
"gemini": "gemini-1.5-flash",
"groq": "llama3-8b-8192"
})
response = ai.generate("Hello world!")
---
## 🛠️ Bring Your Own Model (BYOM)
Plug a custom or private API straight into the failover chain:
```python
from rdai.providers.base import BaseProvider
from rdai import AI
import requests
class CustomNexusProvider(BaseProvider):
def __init__(self, api_key):
super().__init__(api_key, "nexus-v1")
def generate(self, prompt: str, **kwargs) -> str:
res = requests.post(
"https://api.nexus.com/v1",
headers={"Key": self.api_key},
json={"text": prompt},
)
return res.json()["reply"]
ai = AI(providers=[CustomNexusProvider(api_key="your_custom_key")])
print(ai.generate("Hello Custom Engine!"))
✨ Why rdai?
| ✔ Interactive CLI | Guided setup wizard, zero config-file hand-editing |
| ✔ Live Doctor | Real pings, real latency, real status — not assumptions |
| ✔ Smart Routing | Picks the best-fit provider per request |
| ✔ Automatic Failover | Rate limits and crashes handled silently |
| ✔ Provider Agnostic | 11+ built-in brains, plus BYOM for anything else |
| ✔ Zero Hardcoding | Keys stay in your .env, never in code |
⚙️ Routing Strategies & Configuration
rdai reads its setup from an optional rdai.yaml in your working directory. Environment variables always take precedence over .env values.
strategy: smart
provider_order:
- gemini
- openai
- groq
smart— selects the ready provider that best fits the specific request.manual— strictly follows theprovider_orderyou define.
Both strategies keep every other ready provider on standby as automatic fallback for transient rate-limit or timeout failures.
🎛️ Supported AI Engines
| Provider | Environment Variable | Backend Logic |
|---|---|---|
| Gemini | GEMINI_API_KEY |
Modern google.genai SDK |
| OpenAI | OPENAI_API_KEY |
Official openai SDK |
| Groq | GROQ_API_KEY |
Official groq SDK |
| VertexAI | VERTEXAI_API_KEY |
GCP Project ID via google.genai |
| Claude | CLAUDE_API_KEY |
Direct Anthropic REST API |
| AWS Bedrock | AWS_BEDROCK_API_KEY |
AWS boto3 SDK |
| DeepSeek | DEEPSEEK_API_KEY |
Direct DeepSeek REST API |
| Qwen | QWEN_API_KEY |
Alibaba DashScope REST API |
| Llama | LLAMA_API_KEY |
Universal OpenAI-compatible API |
| Mistral | MISTRAL_API_KEY |
Direct Mistral REST API |
| HuggingFace | HUGGINGFACE_API_KEY |
HF Serverless Inference API |
🛠️ CLI Command Reference
| Command | Description |
|---|---|
rdai init |
Setup workspace, strategy, and providers |
rdai doctor |
Live .env scan + API health check |
rdai config |
View active routing strategy and failover chain |
rdai benchmark |
Run a latency test across active models |
rdai health |
Check overall internal system health |
rdai about |
Learn about the orchestration architecture |
🗺️ Roadmap
-
✅ v1.0.0 — Multi-brain orchestrator core: Unbreakable Auto-Failover, Gemini/OpenAI/Claude/Groq + custom model support,
rdai initsetup wizard,rdai doctorlive diagnostics -
✅ v1.0.1 — Faster dashboard rendering (loading animation removed), expanded PyPI SEO keywords, corrected GitHub project URLs
-
✅ v1.0.2 — Core architecture unified, missing dependencies resolved, explicit timeouts added for REST providers, and enhanced CLI doctor diagnostics.
-
🟡 v1.1 — Live streaming: brain activity, frontend events, provider timeline
Full version history: CHANGELOG.md
📂 More Examples
Ready-to-run scripts covering failover, BYOM, and each provider live in /examples — clone the repo and run them directly.
git clone https://github.com/ranajitdharpersonal/rdai.git
cd rdai/examples
python basic_usage.py
🤝 Contributing
Issues and PRs are welcome — check open issues or open a new one to discuss a change before submitting a PR.
If rdai saved you from a 3am provider outage, a ⭐ on the repo goes a long way — it's the easiest way to help other developers discover it.
Release files for rdai 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| rdai-1.1.0.tar.gz | 69.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| rdai-1.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 125.0 kB
Release files / rdai-1.1.0.tar.gz
| Download URL | rdai-1.1.0.tar.gz |
|---|---|
| Size | 69.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4f8e994fb88d15cd486948cfb6af5dce0edd4082597c07bcad10883ee484e102
|
|
BLAKE2b-256 checksum How to use checksums |
345e1bbdbe121408d97d00829a83a3db9aec4af1c6af6d312ceafabee43f1429
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.0
|
Release files / rdai-1.1.0-py3-none-any.whl
| Download URL | rdai-1.1.0-py3-none-any.whl |
|---|---|
| Size | 55.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a972a70834526e199961215eb8ebb464263524745bdc8cef134ac22b67bcfca1
|
|
BLAKE2b-256 checksum How to use checksums |
14d385d9063103a168384731e277f656b7002da1452c396adbd83756cb2524f4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.0
|