explaingit

snailyp/gemini-balance

5,887PythonAudience · developerComplexity · 3/5LicenseSetup · moderate

TLDR

A proxy server that pools multiple Google Gemini API keys and load-balances requests across them, so you can combine free-tier key limits into a single higher-capacity endpoint that also accepts OpenAI-compatible requests.

Mindmap

mindmap
  root((gemini-balance))
    What it does
      Key rotation
      Load balancing
      Failover logic
    API formats
      Gemini native
      OpenAI-compatible
    Features
      Web search
      Image generation
      Admin dashboard
    Setup
      Docker
      SQLite or MySQL
      Env config
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Pool multiple free Gemini API keys to get higher combined rate limits for a personal or research project.

USE CASE 2

Point any OpenAI-compatible tool or library at Gemini without rewriting any integration code.

USE CASE 3

Monitor the health and status of multiple Gemini API keys from a single admin dashboard.

USE CASE 4

Add web search or image generation capabilities to Gemini chat requests through one endpoint.

Tech stack

PythonDockerMySQLSQLite

Getting it running

Difficulty · moderate Time to first run · 30min

Requires Docker and either MySQL or SQLite, all Gemini API keys must be configured in an environment file before starting.

Creative Commons BY-NC 4.0, free for personal and educational use, but you cannot sell or commercially redistribute this service.

In plain English

Gemini Balance is a proxy server that sits between your application and Google's Gemini AI API. Its main job is to manage multiple Gemini API keys at once, cycling through them automatically so no single key takes all the load. If one key fails too many times, the service disables it and moves on. This is useful for developers or teams who have collected multiple free-tier API keys and want to pool their usage limits into a single endpoint. The service accepts requests in two formats: Google's own Gemini API format and the OpenAI-compatible API format. That second option matters because many tools and libraries are already built to talk to OpenAI, so this lets you point those tools at Gemini without rewriting any integration code. It covers chat, text embeddings, and image generation endpoints. Beyond key rotation, Gemini Balance adds features that the base Gemini API does not provide directly. It can attach web search to supported models, enable image generation and image editing through chat, and handle image uploads to external hosting services. There is also an admin web interface for managing configuration in real time without restarting the server, and a monitoring page for checking the status of all configured API keys. Setup is available through Docker (both AMD and ARM images are provided), Docker Compose, or a standard Python local install. Configuration lives in an environment file. The application needs either a MySQL or SQLite database to store logs and key status. The project is licensed under Creative Commons BY-NC 4.0, which allows free personal use but explicitly prohibits commercial resale. The README includes a note that the author has never sold this service and warns against resellers.

Copy-paste prompts

Prompt 1
I have five free Gemini API keys and want to use gemini-balance to pool them. Write a docker-compose.yml that sets up the service with SQLite and show me the environment variables I need.
Prompt 2
Using gemini-balance OpenAI-compatible endpoint, write a Python snippet using the openai library to send a chat message through Gemini.
Prompt 3
How do I configure gemini-balance to automatically disable a Gemini API key after it fails three times in a row?
Prompt 4
I want to monitor my Gemini API key statuses in gemini-balance. How do I access the admin panel and what can I configure there without restarting the server?
Open on GitHub → Explain another repo

← snailyp on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.