+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 disablTop issues
#137Dify如何使用本项目的api?10 comments · 2025-05-28#377我架在clawcloud run上,更新了2.2.8,似乎就出现错误信息了,该怎么解?9 comments · 2025-10-03#389使用 zeabur 部署成功以后,第二天谷歌提示网址危险。8 comments · 2025-11-06#328服务器直接请求google接口正常,用balance验证都报400-User location is not supported for the API use.8 comments · 2025-08-21#287异常空回,后台无报错信息8 comments · 2025-08-06#221请求模型列表时返回500错误8 comments · 2025-07-18#384docker部署的,使用中转key时提示Invalid key and missing x-goog-api-key header。求助下怎么弄7 comments · 2025-10-15#272自定义联网模型7 comments · 2025-07-31
Latest release
v2.2.8 v2.2.8 2025-09-23- no changes