feat: add admin menu, persistent json config, multi-provider support, and custom model fallback revolver
This commit is contained in:
parent
637a3cf255
commit
1c955619e7
21 changed files with 3742 additions and 388 deletions
46
README.md
46
README.md
|
|
@ -1,15 +1,19 @@
|
|||
# GeiminiRevolver
|
||||
# GeminiRevolver
|
||||
|
||||
An OpenAI v1 compatible API endpoint that rotates Gemini API keys to avoid rate limiting. Built with TypeScript and Node.js.
|
||||
|
||||
## Features
|
||||
|
||||
- 🔐 **Password-based API key authentication** - Clients must provide a configured password as their API key
|
||||
- 🔄 **Automatic API key rotation** - Rotates across multiple Gemini API keys to avoid rate limiting
|
||||
- ⚙️ **Interactive Admin Console (`/admin`)** - Full web interface secured with your master API key for managing providers, keys, and model routing pipelines
|
||||
- 💾 **Single JSON Persistence (`data/revolver-config.json`)** - API keys and provider definitions are persisted cleanly in a single JSON file with atomic writes
|
||||
- 🌐 **Multi-Provider Key Revolver** - Add Google AI Studio (Gemini), Groq Cloud, OpenAI, or any Custom OpenAI-compatible endpoints with multiple rotating API keys
|
||||
- 🎯 **Custom Model Fallback Chains** - Define custom model names with multi-tier failovers:
|
||||
`[Main Model (revolving keys) -> Fallback Tier 1 (revolving keys) -> Fallback Tier 2 ...]`
|
||||
- 📊 **Public statistics dashboard** - Live metrics page at the root (`/`) showing request count (went through, failed, cancelled) and token usage (input + output) with zero-knowledge privacy
|
||||
- 📝 **Request/response logging** - Logs all API requests and responses to JSON files
|
||||
- 🎯 **OpenAI v1 compatible** - Drop-in replacement for OpenAI API endpoints
|
||||
- ⚡ **Rate limit handling** - Automatically handles rate limiting and rotates to available keys
|
||||
- ⚡ **Automated Rate Limit & Error Failover** - Automatically detects `429`, quota exhaustion, or server errors before streaming begins and rotates keys or cascades to fallback tiers
|
||||
- 🧪 **Live Playground & Key Verifier** - Test individual provider keys and inspect step-by-step trace metadata directly from the Admin console
|
||||
- 🐳 **Docker support** - Containerized deployment with Docker and Docker Compose
|
||||
- 🌐 **Cloudflare Tunnel integration** - Securely expose your API via Cloudflare tunnel
|
||||
|
||||
|
|
@ -72,7 +76,7 @@ npm start
|
|||
|
||||
2. **Configure the tunnel:**
|
||||
- Add your domain to the tunnel ingress rules
|
||||
- Set the service to point to `http://geimini-revolver:3000`
|
||||
- Set the service to point to `http://gemini-revolver:3000`
|
||||
|
||||
### Docker Deployment
|
||||
|
||||
|
|
@ -109,7 +113,7 @@ docker-compose down
|
|||
|
||||
- **Build only:** `docker-compose build`
|
||||
- **Rebuild without cache:** `docker-compose build --no-cache`
|
||||
- **View logs:** `docker-compose logs -f geimini-revolver`
|
||||
- **View logs:** `docker-compose logs -f gemini-revolver`
|
||||
- **Restart services:** `docker-compose restart`
|
||||
- **Stop and remove containers:** `docker-compose down -v`
|
||||
|
||||
|
|
@ -122,6 +126,32 @@ With Cloudflare tunnel running, your API will be accessible at:
|
|||
|
||||
Use the same authentication method with your configured `API_PASSWORD`.
|
||||
|
||||
## Admin Console & Model Revolver
|
||||
|
||||
Navigate to `http://localhost:3000/admin` in your web browser.
|
||||
|
||||
1. **Authentication:** Enter your `API_PASSWORD` to unlock the console.
|
||||
2. **Configure Providers:** Add one or more providers:
|
||||
- **Google AI Studio (Gemini):** Uses native `@google/generative-ai` SDK
|
||||
- **Groq Cloud:** High-speed Llama models via OpenAI-compatible endpoint
|
||||
- **OpenAI:** Official OpenAI API
|
||||
- **Custom:** Any OpenAI-compatible provider (e.g. DeepSeek, Ollama, Together, Cerebras)
|
||||
- Paste in your API keys (one per line). Multiple keys will be rotated automatically.
|
||||
- Use the **Test Key** button to immediately verify API credentials.
|
||||
3. **Configure Custom Models:**
|
||||
- Define a custom model name (e.g., `gemini-flash-lite-latest` or `my-smart-pipeline`).
|
||||
- Set up your **Fallback Tiers**:
|
||||
- **Tier 0 (Main):** Select primary provider(s) and model ID.
|
||||
- **Tier 1 (Fallback 1):** Select secondary provider(s) and model ID.
|
||||
- **Tier 2 (Fallback 2):** Additional fallbacks if defined.
|
||||
- Designate a **Default Model** to handle requests that omit or supply an unknown model identifier.
|
||||
4. **Revolver Playground:** Test prompt execution live and inspect trace metadata (which tier, provider, model, key, and latency were used).
|
||||
5. **Live Key Telemetry:** Real-time visibility into active keys, rate-limit cooldown timers, and request/error counters.
|
||||
|
||||
All provider credentials and custom model definitions are persisted automatically in `data/revolver-config.json`.
|
||||
|
||||
---
|
||||
|
||||
## API Usage
|
||||
|
||||
### Authentication
|
||||
|
|
@ -227,7 +257,7 @@ The system uses a round-robin rotation strategy with rate limit awareness:
|
|||
## Project Structure
|
||||
|
||||
```
|
||||
GeiminiRevolver/
|
||||
GeminiRevolver/
|
||||
├── src/
|
||||
│ ├── index.ts # Main server entry point
|
||||
│ ├── config.ts # Configuration management
|
||||
|
|
@ -266,7 +296,7 @@ GeiminiRevolver/
|
|||
|
||||
**Container won't start:**
|
||||
```bash
|
||||
docker-compose logs geimini-revolver
|
||||
docker-compose logs gemini-revolver
|
||||
```
|
||||
|
||||
**Port conflicts:**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue