A native, lightweight Gemini AI CLI built specifically for Termux on Android
Features β’ Installation β’ Usage β’ Configuration β’ FAQ
This project is inspired by and aims to provide similar functionality to the official Google Gemini CLI, but reimagined from the ground up for Termux on Android.
- Inspired by: google-gemini/gemini-cli - Official Gemini CLI by Google
- Built for: Termux community on Android
- Purpose: Provide a working, native solution for Android users
Note: This is NOT a fork of the official repository. It's a complete rewrite in Python to solve Termux-specific compatibility issues. All credit for the original concept and design goes to the Google Gemini team.
The official @google/gemini-cli doesn't work on Termux due to:
- β Native module compilation failures (node-pty, keytar, etc.)
- β Platform detection issues (Android not recognized)
- β Clipboard integration broken
- β OAuth2 authentication complexity
This project solves these issues by building a native Python solution specifically for Termux, while maintaining the spirit and functionality of the original CLI.
- β Zero Native Dependencies - Pure Python, installs instantly
- β Termux-Optimized - Built specifically for Android/Termux environment
- β Beautiful UI - Rich terminal interface with syntax highlighting
- β Clipboard Integration - Direct Termux-API support
- β Conversation History - Persistent chat sessions
- β File Analysis - Upload images, PDFs, and documents
- β Streaming Responses - Real-time AI output
- β Lightweight - Minimal resource usage, battery-friendly
- β Offline Config - No internet needed for setup
# Install dependencies
pkg update && pkg upgrade -y
pkg install python git termux-api python-grpcio python-pillow python-cryptography -y
# Clone repository
git clone https://github.com/Alex72-py/gemini-cli-termux.git
cd gemini-cli-termux
# Run installer
chmod +x install.sh
./install.shNote: Uses Termux pre-compiled packages for
grpcio,Pillow, andcryptographyto avoid compilation
# Install Python packages
pip install --break-system-packages -r requirements.txt
# Install packages requiring native compilation (use Termux packages)
pkg install python-grpcio python-pillow python-cryptography
# Install google-generativeai (requires system grpcio)
pip install --break-system-packages --no-deps google-generativeai
pip install --break-system-packages google-ai-generativelanguage protobuf
# Install CLI
pip install --break-system-packages -e .
# Setup
gemini-termux setup- Visit Google AI Studio
- Click "Create API Key"
- Copy your API key
# Run setup wizard
gemini-termux setup
# Or set manually
export GEMINI_API_KEY="your-api-key-here"# Interactive chat mode
gemini-termux chat
# Quick question
gemini-termux ask "What is Termux?"
# Analyze an image
gemini-termux chat --image screenshot.pnggemini-termux chatCommands in chat mode:
/exitor/quit- Exit chat/clear- Clear conversation history/history- Show conversation history/copy- Copy last response to clipboard/save- Save conversation to file/model <name>- Switch model/help- Show all commands
# Simple question
gemini-termux ask "Explain quantum computing"
# With file input
gemini-termux ask "What's in this image?" --image photo.jpg
# Stream response
gemini-termux ask "Write a story" --stream# Analyze image
gemini-termux chat --image screenshot.png
# Multiple files
gemini-termux chat --file document.pdf --file data.csv
# Supported: PNG, JPG, WEBP, PDF, TXT, CSV, JSON# View current config
gemini-termux config show
# Set model
gemini-termux config set model gemini-2.0-flash-exp
# Set temperature
gemini-termux config set temperature 0.7
# Reset to defaults
gemini-termux config reset~/.config/gemini-cli/config.toml
[api]
model = "gemini-2.0-flash-exp"
timeout = 60
[generation]
temperature = 0.9
top_p = 0.95
top_k = 40
max_output_tokens = 8192
[ui]
theme = "monokai"
syntax_highlighting = true
show_timestamps = true
streaming = true
[history]
enabled = true
max_entries = 1000
auto_save = true
[clipboard]
use_termux_api = truegemini-2.0-flash-exp- Fast, multimodal (Recommended)gemini-2.0-flash-thinking-exp- Advanced reasoninggemini-1.5-pro- Most capablegemini-1.5-flash- Fast & efficientgemini-1.5-flash-8b- Lightweight
# API Configuration
export GEMINI_API_KEY="your-key"
export GEMINI_MODEL="gemini-2.0-flash-exp"
# Behavior
export GEMINI_STREAMING=true
export GEMINI_DEBUG=false# Process multiple questions
cat questions.txt | while read question; do
gemini-termux ask "$question" >> answers.txt
done
# Analyze all images
for img in *.png; do
gemini-termux ask "Describe this" --image "$img"
done"API key not found"
export GEMINI_API_KEY="your-key-here"
echo 'export GEMINI_API_KEY="your-key"' >> ~/.bashrc"Clipboard not working"
pkg install termux-api"Module not found"
pip install --break-system-packages -r requirements.txt --force-reinstallgemini-termux --debug chat
gemini-termux doctor # Check installationContributions welcome!
- Fork the repository
- Create feature branch (
git checkout -b feature/amazing) - Commit changes (
git commit -m 'Add feature') - Push to branch (
git push origin feature/amazing) - Open Pull Request
MIT License - see LICENSE file for details.
- Google Gemini Team - For creating the original Gemini CLI and the amazing Gemini API
- Official Gemini CLI - Inspiration for features and design
- Termux community - For making Android development possible
- All contributors to this project
This is a complete rewrite designed specifically for Termux:
| Feature | Official CLI | This Project |
|---|---|---|
| Platform | Node.js | Python |
| Native Deps | Yes (node-pty, keytar) | None (pure Python) |
| Installation | npm (requires compilation) | pip (instant) |
| Authentication | OAuth2 + Keychain | API Key + File |
| Clipboard | clipboardy (broken) | Termux-API (native) |
| Termux Support | β Broken | β Native |
| File Size | ~200MB+ | ~50MB |
- Issues: GitHub Issues
- Discussions: GitHub Discussions
Made with β€οΈ for the Termux community