Download docs/README_EN.md from nst1/gemini: direct link, hf CLI and curl.
- Browser
- Download file 16.3 kB
-
https://huggingface.co/spaces/nst1/gemini/resolve/main/docs/README_EN.md
- Command line
-
hf download hf://spaces/nst1/gemini/docs/README_EN.md
-
curl -L -o README_EN.md https://huggingface.co/spaces/nst1/gemini/resolve/main/docs/README_EN.md
๏ปฟ
Gemini Business2API
Empowering AI with seamless integration
็ฎไฝไธญๆ | English
Convert Gemini Business to OpenAI-compatible API with multi-account load balancing, image generation, video generation, multimodal capabilities, and built-in admin panel.
๐ License & Disclaimer
License: Cooperative Non-Commercial License (CNC-1.0) - See LICENSE for details
โ ๏ธ Prohibited Use & Anti-Abuse Policy
This tool is strictly prohibited for:
- Commercial use or profit-making activities
- Batch operations or automated abuse of any scale
- Market disruption or malicious competition
- Violations of Google's Terms of Service
- Violations of Microsoft's Terms of Service
Consequences: Violations may result in permanent account suspension and legal liability. All consequences are the sole responsibility of the user.
Legitimate Use Only: Personal learning, technical research, and non-commercial educational purposes only.
๐ Full Disclaimer: DISCLAIMER_EN.md
โจ Features
- โ Full OpenAI API compatibility - Seamless integration with existing tools
- โ Multi-account load balancing - Round-robin with automatic failover
- โ Automated account management - Auto registration & login, multiple temp email providers, headless browser mode
- โ Streaming output - Real-time responses
- โ Multimodal input - 100+ file types (images, PDF, Office docs, audio, video, code, etc.)
- โ Image generation & image-to-image - Configurable models, Base64 or URL output
- โ Video generation - Dedicated model with HTML/URL/Markdown output formats
- โ Smart file handling - Auto file type detection, supports URL and Base64
- โ Logging & monitoring - Real-time status and statistics
- โ Proxy support - Configure via admin settings panel
- โ Built-in admin panel - Online configuration and account management
- โ PostgreSQL / SQLite storage - Persistent accounts/settings/stats
๐ค Model Capabilities
| Model ID | Vision | Native Web | File Multimodal | Image Gen | Video Gen |
|---|---|---|---|---|---|
gemini-auto |
โ | โ | โ | Optional | - |
gemini-2.5-flash |
โ | โ | โ | Optional | - |
gemini-2.5-pro |
โ | โ | โ | Optional | - |
gemini-3-flash-preview |
โ | โ | โ | Optional | - |
gemini-3-pro-preview |
โ | โ | โ | Optional | - |
gemini-3.1-pro-preview |
โ | โ | โ | Optional | - |
gemini-imagen |
โ | โ | โ | โ | - |
gemini-veo |
โ | โ | โ | - | โ |
gemini-imagen: Dedicated image generation model ยทgemini-veo: Dedicated video generation model
๐ Quick Start
Method 1: Docker Compose (Recommended)
Supports ARM64 and AMD64 architectures
git clone https://github.com/Dreamy-rain/gemini-business2api.git
cd gemini-business2api
cp .env.example .env
# Edit .env to set ADMIN_KEY
docker compose up -d
# View logs
docker compose logs -f
# Update to latest version
docker compose pull && docker compose up -d
Method 2: Setup Script
Prerequisites: Git, Node.js & npm (for frontend build). Script auto-installs Python 3.11 and uv.
Linux / macOS / WSL:
git clone https://github.com/Dreamy-rain/gemini-business2api.git
cd gemini-business2api
bash setup.sh
# Edit .env to set ADMIN_KEY
source .venv/bin/activate
python main.py
# Background with pm2
pm2 start main.py --name gemini-api --interpreter ./.venv/bin/python3
Windows:
git clone https://github.com/Dreamy-rain/gemini-business2api.git
cd gemini-business2api
setup.bat
# Edit .env to set ADMIN_KEY
.venv\Scripts\activate.bat
python main.py
# Background with pm2
pm2 start main.py --name gemini-api --interpreter ./.venv/Scripts/python.exe
The script handles: uv install, Python 3.11 download, dependency install, frontend build, .env creation.
To update, simply re-run the same script.
Method 3: Manual Deployment
git clone https://github.com/Dreamy-rain/gemini-business2api.git
cd gemini-business2api
curl -LsSf https://astral.sh/uv/install.sh | sh
uv python install 3.11
cd frontend && npm install && npm run build && cd ..
uv venv --python 3.11 .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate.bat
uv pip install -r requirements.txt
cp .env.example .env
# Edit .env to set ADMIN_KEY
python main.py
Access
- Admin Panel:
http://localhost:7860/(Login withADMIN_KEY) - API Endpoint:
http://localhost:7860/v1/chat/completions
๐๏ธ Database Persistence
By default, do not set DATABASE_URL. Use local SQLite (data.db) directly (recommended).
Use an online database only when necessary (for example: multi-instance shared data, or cloud platforms without persistent volume mounts).
Configuration:
- Local deployment โ add to
.env - Cloud platforms โ set in platform environment variables
DATABASE_URL=postgresql://user:password@host/dbname?sslmode=require
Local Refresh Service Recommendation (refresh-worker)
- Recommended topology: deploy
mainon cloud, runrefresh-workerlocally for browser-based refresh jobs. - Prefer local SQLite (
data.db) as refresh-side cache for better stability under network jitter. - If your local refresh worker needs to connect to the remote admin panel directly, use remote interface +
ADMIN_KEY:
REMOTE_PROJECT_BASE_URL=https://your-beta-domain.example
REMOTE_PROJECT_PASSWORD=your_admin_key
Online PostgreSQL (Optional):
| Service | Free Tier | How to Get |
|---|---|---|
| Neon | 512MB / 100 CPUH/month | Sign up โ Create Project โ Copy Connection string |
| Aiven | More generous | Sign up โ Create PostgreSQL service โ Copy connection string |
Both
postgres://andpostgresql://formats are supported natively.
โ ๏ธ FAQ: Periodic save failure / ConnectionDoesNotExistError
If you see errors like:
ERROR [COOLDOWN] Save failed: connection was closed in the middle of operation
asyncpg.exceptions.ConnectionDoesNotExistError: connection was closed in the middle of operation
This happens when free PostgreSQL providers (e.g., Aiven free tier) close idle connections. It does not affect normal usage โ the next operation will auto-reconnect. If frequent, consider switching to Neon or upgrading your database plan.
๐ฆ Database Migration (Upgrading from older versions)
If you have legacy local files (accounts.json / settings.yaml / stats.json), run:
python scripts/migrate_to_database.py
The script auto-detects the environment (PostgreSQL / SQLite) and renames old files after migration.
๐ก API Endpoints
Fully OpenAI API compatible. Works with ChatGPT-Next-Web, LobeChat, OpenCat, and other clients.
| Endpoint | Method | Description |
|---|---|---|
/v1/chat/completions |
POST | Chat completions (streaming supported) |
/v1/models |
GET | List available models |
/v1/images/generations |
POST | Image generation (text-to-image) |
/v1/images/edits |
POST | Image editing (image-to-image) |
/health |
GET | Health check |
Example:
curl http://localhost:7860/v1/chat/completions \
-H "Authorization: Bearer your-api-key" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-2.5-flash",
"messages": [{"role": "user", "content": "Hello"}],
"stream": true
}'
API_KEYis configured in Admin Panel โ System Settings. Leave empty for public access. Multiple keys supported (comma-separated).
๐ง Email Provider Configuration
The project supports 6 temporary email providers for automatic account registration. Switch and configure them in Admin Panel โ System Settings โ Temp Email Provider.
Moemail (Default)
Open-source temporary email service, ready to use out of the box.
- Project: github.com/beilunyang/moemail
- Website: moemail.app
- Config: API URL + API Key + Domain (optional)
DuckMail
Temporary email API service. Custom domain recommended.
- Domain Management: domain.duckmail.sbs
- Config: API URL + API Key + Registration Domain
GPTMail
Temporary email API service, no password required.
- Default URL:
https://mail.chatgpt.org.uk - Default API Key:
gpt-test - Config: API URL + API Key + Domain (optional)
Freemail
Self-hosted temporary email service, for users with their own servers.
- Project: github.com/idinging/freemail
- Config: Self-hosted service URL + JWT Token + Domain (optional)
Cloudflare Mail (CFMail)
Cloudflare-based temporary email service, suitable for self-hosted or lightweight deployments.
- Project: github.com/dreamhunter2333/cloudflare_temp_email
- Admin Panel Path: System Settings โ Temp Email Provider =
cfmail - Config:
- Cloudflare Mail API URL (
cfmail_base_url) - Access password (
cfmail_api_key, can be empty if your instance does not require it) - Email domain (
cfmail_domain, optional, without@)
- Cloudflare Mail API URL (
- Import format (optional):
cfmail----you@example.com----jwtToken- The third field is the mailbox JWT token used to fetch verification codes.
Sample Mail
Lightweight self-hosted temporary email based on Cloudflare Workers + D1. No API Key required; the email domain is determined by the Worker environment variable.
- Project: github.com/bestK/sample-mail
- Admin Panel Path: System Settings โ Temp Email Provider =
samplemail - Configuration:
- Sample Mail Worker URL (
samplemail_base_url, required) - SSL verification (
samplemail_verify_ssl, enabled by default)
- Sample Mail Worker URL (
- Note: Domain selection and API Key are not supported. The email domain is set via the
EMAIL_DOMAINenvironment variable in your Worker.
Tip: All email settings are configured in the admin panel. Microsoft email login is also handled through the admin panel.
๐ Recommended Deployment Platforms
In addition to local Docker Compose, these platforms support Docker image deployment:
| Platform | Free Tier | Features |
|---|---|---|
| Render | โ Yes | Docker support, auto SSL, free PostgreSQL |
| Railway | $5/month credit | One-click Docker deploy, built-in database |
| Fly.io | โ Yes | Global edge deployment, persistent volumes |
| Claw Cloud | โ Yes | Container cloud, simple and easy |
| Self-hosted VPS (Recommended) | โ | Full control with Docker Compose |
Docker image:
cooooookk/gemini-business2api:latestSet
ADMIN_KEYfirst. ConfigureDATABASE_URLonly when needed (localdata.dbis the default recommendation).
Zeabur Deployment Guide
Fork this repository to your GitHub
Log in to Zeabur โ Create Project โ Shared Cluster โ Deploy New Service โ Connect GitHub โ Select your forked repo
Add environment variables:
Variable Required Description ADMIN_KEYโ Admin panel login key DATABASE_URLOptional PostgreSQL connection string (configure only when online DB is required) Persistent Storage (Important):
Add persistent storage in service settings:
Disk ID Mount Path data/app/dataClick Redeploy to apply settings
Update: GitHub repo โ Sync fork โ Update branch, Zeabur will auto-redeploy.
๐ Standalone Refresh Service
To deploy the account refresh service separately from the main API, use the refresh-worker branch:
git clone -b refresh-worker https://github.com/Dreamy-rain/gemini-business2api.git gemini-refresh-worker
cd gemini-refresh-worker
cp .env.example .env
# Edit .env (default local data.db; set DATABASE_URL only when needed)
docker compose up -d
This service reads accounts from the database and runs scheduled credential refresh independently. Supports cron scheduling, batch processing, and cooldown deduplication.
๐ฟ Branch Guide
To keep deployment logic clear, choose branches by scenario:
main: stable line (recommended for production API + admin panel)beta: pre-release line (new features land here first)refresh-worker: standalone refresh service branch (ideal for local refresh worker + remote API)clash-proxy: Clash proxy branch (for registration/refresh in proxy-constrained networks)
Recommended setup:
- Deploy
main/betaon cloud for API + admin panel - Run
refresh-workerlocally for account registration/refresh - Use
clash-proxywhen your network path relies on Clash proxy routing
Clash Proxy Deployment Example
git clone -b clash-proxy https://github.com/Dreamy-rain/gemini-business2api.git gemini-business2api-clash
cd gemini-business2api-clash
cp .env.example .env
# Edit .env and proxy settings in the admin panel, then start
docker compose up -d
๐ Socks5 Free Proxy Pool
Configure a proxy when auto-registering/refreshing accounts to improve success rates:
- Project: github.com/Dreamy-rain/socks5-proxy
- Note: Free proxies are not very stable, but can help improve registration success rates
- Usage: Configure in Admin Panel โ System Settings โ Proxy Settings
๐ธ Screenshots
Admin System
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Image Effects
![]() |
![]() |
![]() |
![]() |
Documentation
- Supported file types: SUPPORTED_FILE_TYPES.md
โญ Star History
If this project helps you, please give it a โญ Star!









