Multiply Gemini API Free Credits with Load Balancing
Google offers developers a generous Gemini
API free usage credits through Google AI Studio
It's easy to get an API key. Free packages usually include a per-minute rate limit and total daily Token Call volume. Although the amount of a single key is limited, by registering different accounts to apply for multiple keys, and with the help of load balancing tools, you can effectively break through this limitation and multiply the amount.
In this article, we will present gemini-balance
, a program designed to provide Google Gemini
API provides proxy and load balancing functionality to the application. This project was developed by the developer snailyp
Created, based on Python FastAPI
builds that allow users to manage multiple Gemini
API keys for polling, authentication, model filtering, and state monitoring.
We're going to do that with a free ClawCloud
Container services to deploy gemini-balance
This allows for the creation of a stable, proxy-free system that integrates multiple Gemini
A personal proprietary interface for API keys.
- Project address. https://github.com/snailyp/gemini-balance
- Deployment Documentation. https://gb-docs.snaily.top/guide/setup-clawcloud-sqlite.html
I. Prepare Multiple Gemini API Keys
gain Gemini
API keys are a prerequisite for deploying services.
- interviews
Google AI Studio
Application page: https://aistudio.google.com/ - Sign in with your Google account and create an API key.
- Repeat this process for multiple separate API keys if necessary by registering and logging in to multiple different Google accounts.
Register for a ClawCloud account
ClawCloud
is a cloud computing platform founded in 2024 and headquartered in Singapore, specializing in high-performance cloud infrastructure services for developers. Its ClawCloud Run
is a Platform-as-a-Service (PaaS) offering that greatly simplifies the application deployment process. For users who have been registered on Github for more than 180 days, theClawCloud
Offering a monthly gift of $5.00 is sufficient to support the gemini-balance
Ongoing operation of the project.
- interviews
ClawCloud
official website and use yourGitHub
Account Login. - After logging in, in the user center of the
Account Center
You can view the monthly gifted amount and the current usage.
Deploying gemini-balance in ClawCloud
Next, we'll use the ClawCloud Run
to containerized deployment gemini-balance
The
- Select server area
existClawCloud
main interface, click on the upper left corner of theRegion
Recommended choicesSingapore
. After the page refreshes, make sure the area is preceded by a check mark. - Creating Applications
strike (on the keyboard)App Launchpad
, then click on the top right corner of the pageCreate App
Go to the Application Configuration page. - Configuring Application Parameters
On the configuration page, fill in the parameters as described below:- Image Name:
ghcr.io/snailyp/gemini-balance:latest
- Application Name:
geminibalance
(or whatever name you prefer) - Image:
Public
- Usage:
Fixed
- Replicas:
1
- CPU:
1
- Memory:
512
Note: This configuration applies to the free credit, which provides 10G of free traffic per month. - Network
- Container Port:
8000
- Enable Internet: Tap as
Access
state of affairs
- Container Port:
- Image Name:
- Configuring Environment Variables
existAdvanced Configura
->Environment Variables
section, click on theAdd
, add the following variables. whereAPI_KEYS
cap (a poem)ALLOWED_TOKENS
It needs to be replaced with your own key and access token.DATABASE_TYPE=sqlite SQLITE_DATABASE=default_db API_KEYS=["YOUR_GEMINI_API_KEY_1","YOUR_GEMINI_API_KEY_2"] ALLOWED_TOKENS=["YOUR_ACCESS_TOKEN_1"] AUTH_TOKEN= TZ=Asia/Shanghai
Variable Description.
variable name | clarification | Format and examples |
---|---|---|
API_KEYS |
Gemini API Key lists for load balancing | ["key-1","key-2"] |
ALLOWED_TOKENS |
List of authorization tokens allowed to access this service | ["token-1","token-2"] |
AUTH_TOKEN |
(Optional) Super Administrator token with all privileges. If not filled in, the default is to use the ALLOWED_TOKENS The first value of the |
sk-123456 |
- Configuration Storage
strike (on the keyboard)Add Storage
, set up as shown in the diagram, the container of the/app/db
path is mounted to persistently store the data. - Deploying applications
Return to the top of the page and clickDeploy Application
. In the confirmation pop-up window, selectYes
The - Check deployment status
After waiting for a few seconds, the page will jump to the application status screen. Please make sure the upper left corner showsrunning
. Underneath theNetwork
tab, the public address (Public address
) The initial state may bepending
Please wait for 2-5 minutes until it turns into a Please wait for 2-5 minutes until it becomesAvailable
. At this point, your service can be accessed at this address. - (Optional) Setting up a customized domain name
If you wish to access it using your own domain name, you can do so in theCloudflare
and other DNS providers to add aCNAME
Records, pointing toClawCloud
public network address provided. Then add the address of the public network to theClawCloud
Add your customized domain name to the domain settings of the
IV. Managing and monitoring gemini-balance
gemini-balance
Provides a convenient administration backend for configuring and monitoring API keys.
- Open your deployed public address in a browser and go to the login screen. Enter the values you have specified in the environment variable
ALLOWED_TOKENS
The access token set in theyour-access-token-1
) to log in. - Once logged in, you can dynamically add or remove
Gemini
API key without restarting the service. - The management background also provides monitoring of each key's call status, which is convenient for you to track the usage status.
V. Using Proxy Services in AI Clients
Once the deployment is complete, you can add a new configuration file to any of the supported OpenAI
API-formatted clients use this proxy service. Take Cherry Studio
As an example, it is a multi-platform support AI
desktop client that can easily integrate and switch between different AI
Model.
- Add Provider
existCherry Studio
In it, go to Model Provider Settings and add a new provider with a customizable name. - Configuring Interface Information
- API key: Fill in the information you have in the
gemini-balance
environment variableALLOWED_TOKENS
The access token set in the - API Address: Fill in
ClawCloud
Provide the public access address, taking care not to end with the/
The
- API key: Fill in the information you have in the
- Managing and using models
After saving, click on "Manage" and the client will automatically retrieve the information from yourgemini-balance
The service pulls and displays a list of available models. You are now ready to select and use the model in the clientGemini
model, all requests will be distributed through the load balancing service you have built.