one-balance  by glidea

AI key rotation for smarter, secure API access

Created 2 months ago
351 stars

Top 79.3% on SourcePulse

GitHubView on GitHub
Project Summary

One Balance is a Cloudflare Worker-based API key load balancer designed to maximize the utilization of AI service quotas and enhance security. It targets developers and power users who manage multiple API keys for services like Google AI Studio or OpenAI, offering intelligent key rotation, rate limiting, and automatic key blocking to reduce costs and prevent service disruptions.

How It Works

The system leverages Cloudflare AI Gateway for routing and adds intelligent key management. It sits as a proxy, receiving client requests and forwarding them to the AI Gateway, which then uses the appropriate API key. Key states (active, cooling down, blocked) are managed in a D1 database. The core innovation lies in its granular rate-limiting detection, distinguishing between minute-level and day-level quotas for specific models (e.g., Google AI Studio) and implementing differentiated cooldown periods, alongside automatic blocking of permanently banned keys.

Quick Start & Requirements

  • Install: Clone the repository, install dependencies with pnpm install, and deploy using pnpm run deploycf (requires Cloudflare account and wrangler CLI).
  • Prerequisites: Node.js, pnpm, Cloudflare account, Cloudflare AI Gateway setup.
  • Setup: Deployment involves cloning, installing dependencies, and running a deploy script that handles Cloudflare setup.
  • Links: Cloudflare AI Gateway Documentation

Highlighted Details

  • Reduces API key ban risk by routing through Cloudflare AI Gateway.
  • Implements model-level rate limiting with differentiated cooldowns for minute/day quotas.
  • Automatically blocks permanently banned keys (403 errors).
  • Supports Gemini TTS key rotation, claimed as a unique feature.
  • Built on Cloudflare Workers and D1, leveraging free tier resources.

Maintenance & Community

The project is maintained by glidea. There are no explicit mentions of community channels like Discord/Slack or a public roadmap in the provided README.

Licensing & Compatibility

The repository does not explicitly state a license. This is a significant omission for evaluating commercial use or closed-source linking.

Limitations & Caveats

The project lacks an explicit license, making its usage terms unclear. Access to the management UI might be restricted for users in mainland China due to network access. The README also notes that sharing keys can negatively impact the system's ability to manage global call information, potentially increasing rate limit errors.

Health Check
Last Commit

1 week ago

Responsiveness

Inactive

Pull Requests (30d)
1
Issues (30d)
5
Star History
49 stars in the last 30 days

Explore Similar Projects

Feedback? Help us improve.