snailyp /gemini-balance

Gemini polling proxy service (gemini轮询代理服务)

★ 5,771⑂ 1,147👁 19⑃ 89● 315▤ 74
PythonNOASSERTIONCreated 2024-12-12gb-docs.snaily.top
下载:v2.2.8v2.2.8 ↓2.2.82025-09-23
+0
日增长
5,771
stars
1,147
forks
19
watchers
89
prs
315
issues
74
releases

README

Read this document in Chinese

 Gemini Balance - Gemini API Proxy and Load Balancer


  
    
  



  
  
  
  


 ⚠️ Important: This project is licensed under the CC BY-NC 4.0 license. Any form of commercial resale service is prohibited.
 I have never sold this service on any platform. If you encounter someone selling this service, they are a reseller. Please do not be deceived.

---

 📖 Project Introduction

Gemini Balance is an application built with Python FastAPI, designed to provide proxy and load balancing functions for the Google Gemini API. It allows you to manage multiple Gemini API Keys and implement key rotation, authentication, model filtering, and status monitoring through simple configuration. Additionally, the project integrates image generation and multiple image hosting upload functions, and supports proxying in the OpenAI API format.


📂 View Project Structure

plaintext
app/
├── config/        Configuration management
├── core/          Core application logic (FastAPI instance creation, middleware, etc.)
├── database/      Database models and connections
├── domain/        Business domain objects
├── exception/     Custom exceptions
├── handler/       Request handlers
├── log/           Logging configuration
├── main.py        Application entry point
├── middleware/    FastAPI middleware
├── router/        API routes (Gemini, OpenAI, status page, etc.)
├── scheduler/     Scheduled tasks (e.g., Key status check)
├── service/       Business logic services (chat, Key management, statistics, etc.)
├── static/        Static files (CSS, JS)
├── templates/     HTML templates (e.g., Key status page)
└── utils/         Utility functions



---

 ✨ Feature Highlights

   Multi-Key Load Balancing: Supports configuring multiple Gemini API Keys (API_KEYS) for automatic sequential polling.
   Visual Configuration: Configurations modified through the admin backend take effect immediately without restarting.
    !Configuration Panel
   Dual Protocol API Compatibility: Supports both Gemini and OpenAI CHAT API formats.
       OpenAI Base URL: http://localhost:8000(/hf)/v1
       Gemini Base URL: http://localhost:8000(/gemini)/v1beta
   Image-Text Chat & Modification: Configure models with IMAGE_MODELS to support image-text chat and editing. Use the configured_model-image model name to invoke.
    !Chat with Image Generation
    !Modify Image
   Web Search: Configure models with SEARCH_MODELS to support web search. Use the configured_model-search model name to invoke.
    !Web Search
   Key Status Monitoring: Provides a /keys_status page (authentication required) for real-time monitoring.
    !Monitoring Panel
   Detailed Logging: Provides detailed error logs for easy troubleshooting.
    !Call Details
    !Log List
    !Log Details
   Flexible Key Addition: Add keys in batches using the gemini_key regex, with automatic deduplication.
    !Add Key
   Failure Retry & Auto-Disable: Automatically retries failed API requests (MAX_RETRIES) and disabl

Top issues

Latest release

v2.2.8 v2.2.8 2025-09-23
- no changes

Snapshot: 2026-11-16T09:23:14Z · Data license Apache-2.0 · JSON