A minimal no-login chat web app:
- users open the page and start chatting immediately
- the browser sends requests to your server
- the server forwards them to Gemini with
GEMINI_API_KEY - the API key stays on the server
python -m venv .venv
.venv\Scripts\Activate.ps1
pip install -r requirements.txtCreate .env in the project root:
GEMINI_API_KEY=your_real_key
GEMINI_MODEL=gemini-2.5-flash
GEMINI_MODELS=gemini-2.5-flash,gemini-3-flash-preview,gemini-2.5-flash-lite,gemini-3.1-flash-lite-preview
PORT=8000
GEMINI_CONNECT_TIMEOUT=10
GEMINI_READ_TIMEOUT=180Then run:
python app.pyOpen http://127.0.0.1:8000
- default model is
gemini-2.5-flash GEMINI_MODELcan override the defaultGEMINI_MODELScontrols fallback order when a model hits quota or rate limits- the app loads
.envautomatically on startup - long Gemini responses can use
GEMINI_CONNECT_TIMEOUTandGEMINI_READ_TIMEOUT - chat history lives in browser memory and clears on refresh
Upload the project to the server, then run:
chmod +x deploy_ubuntu22.sh
./deploy_ubuntu22.shThe script will:
- switch Ubuntu 22.04 apt sources to Tsinghua Tuna by default
- install Python packages needed on Ubuntu 22.04
- copy the project to
/opt/gemini-web-chat - create a virtual environment
- install dependencies with Tsinghua PyPI by default
- generate a systemd service
If you do not want the script to replace apt sources, run:
USE_TUNA_APT=0 ./deploy_ubuntu22.shIf you do not want to use Tsinghua PyPI, run:
USE_TUNA_PIP=0 ./deploy_ubuntu22.shAfter that:
sudo nano /opt/gemini-web-chat/.env
sudo systemctl enable --now gemini-web-chat
sudo journalctl -u gemini-web-chat -fOpen:
http://your-server-ip:8000