Skip to content

G4F Launcher for Linux and Termux (Android). One-command installation of g4f with automatic setup.

License

Notifications You must be signed in to change notification settings

gpt4free/g4f.sh

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

14 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿง G4F Launcher for Android

One-command installation of g4f for Linux and Android (via Termux).

License Platform Version

โœจ Features

  • โœ… One-command installation - No manual setup required
  • โœ… Auto-detects your system - Works on Ubuntu, Debian, Arch, Termux, etc.
  • โœ… Silent mode support - Perfect for automation
  • โœ… Automatic updates - Keeps g4f up to date
  • โœ… Optional components - Choose full or slim installation
  • โœ… Works on Android - Via Termux terminal emulator
  • โšก Fast Termux mode - 5-minute quick install option

๐Ÿš€ Quick Start

๐Ÿ“ฑ On Termux (Android)

Option 1: Fast Install (Recommended for Termux)

~5 minutes, minimal features, perfect for testing:

pkg install curl -y
curl -fsSL https://raw.githubusercontent.com/gpt4free/g4f.sh/main/termux-fast.sh -o termux-fast.sh
chmod +x termux-fast.sh
./termux-fast.sh

Option 2: Full Install

~20-40 minutes, all features:

pkg install curl -y
curl -fsSL https://raw.githubusercontent.com/gpt4free/g4f.sh/main/g4f_launcher.sh -o g4f_launcher.sh
chmod +x g4f_launcher.sh
./g4f_launcher.sh

๐Ÿง On Linux (Ubuntu/Debian/Arch)

curl -fsSL https://raw.githubusercontent.com/gpt4free/g4f.sh/main/g4f_launcher.sh -o g4f_launcher.sh
chmod +x g4f_launcher.sh
./g4f_launcher.sh

๐Ÿ“Š Installation Comparison

Version Install Time Size Features Best For
Fast (Termux) ~5 minutes ~150MB Basic API & GUI Quick testing, impatient people ๐Ÿ˜…
Full (Termux) ~20-40 minutes ~600MB All features Daily use, maximum compatibility
Full (Linux) ~5 minutes ~600MB All features Desktop/server deployments

๐Ÿ“ฑ Requirements

Termux (Android)

  • Android 7.0+
  • Termux from F-Droid (NOT Play Store - outdated!)
  • Storage:
    • Fast install: ~200MB free
    • Full install: ~800MB free
  • Note: Your phone may get warm during compilation - this is normal!

Linux

  • Any modern Linux distribution
  • curl or wget
  • Storage: ~800MB free (for full installation)

๐ŸŽฏ Usage

Interactive Mode (Default)

./g4f_launcher.sh

The launcher will:

  1. โœ… Detect your system (Termux/Ubuntu/Debian/Arch/etc.)
  2. โœ… Install Python (if needed)
  3. โœ… Install pip (if needed)
  4. โœ… Ask you to choose between full or optimized g4f installation
  5. โœ… Ask about optional ffmpeg installation
  6. โœ… Start the g4f server

Silent Mode (No Prompts)

./g4f_launcher.sh /silent

Perfect for automation. Installs everything automatically:

  • Full g4f installation (g4f[all])
  • ffmpeg (optional but included)
  • No user prompts
  • Exits cleanly after installation

After Installation

The server runs on http://localhost:8080

Web Interface:

http://localhost:8080/chat/

API Endpoints:

POST http://localhost:8080/v1/chat/completions
POST http://localhost:8080/v1/completions
GET  http://localhost:8080/v1/models

๐Ÿ”ง Advanced

Start Server Later

A launcher script is created at:

  • Termux: ~/g4f-start
  • Linux: ~/.local/bin/g4f-start

Run it anytime:

~/g4f-start  # Termux
# or
g4f-start    # Linux (if ~/.local/bin is in PATH)

Update G4F

Just run the launcher again:

./g4f_launcher.sh

It will detect g4f is installed and update it automatically.

Background Mode (Termux)

python -m g4f.cli api --port 8080 &

Stop with:

pkill -f g4f

๐Ÿ“ฑ Termux-Specific Tips

โšก Why is Termux installation slow?

Termux compiles packages from source on your phone's ARM CPU. This is normal and expected:

  • Fast install: ~5 minutes (minimal compilation)
  • Full install: ~20-40 minutes (compiles Rust, C libraries, etc.)

Your phone may get warm - this is normal! Modern phones can handle it.

๐Ÿ” Check if installation is still working:

top

Look for python, pip, rustc, or clang processes - if you see them, it's working!

๐Ÿ’พ Storage issues?

Check available space:

df -h ~

Need at least:

  • Fast install: ~200MB free
  • Full install: ~800MB free

๐Ÿ”‹ Battery optimization

Some Android manufacturers (Samsung, Xiaomi) may kill background processes. To prevent this:

  1. Open Android Settings
  2. Go to Apps โ†’ Termux
  3. Disable battery optimization for Termux

๐Ÿ“ก Access from other devices

Find your phone's IP:

ifconfig wlan0 | grep inet

Then access from another device on the same network:

http://YOUR_PHONE_IP:8080/chat/

๐Ÿ› Troubleshooting

"Permission denied"

chmod +x g4f_launcher.sh
./g4f_launcher.sh  # Note the ./

"Command not found"

Make sure you're in the correct directory:

ls -l g4f_launcher.sh  # Should show the file

Termux: "Package not found"

Update package lists first:

pkg update
pkg upgrade

Termux: Installation takes forever

  • โœ… This is normal! See "Why is Termux installation slow?" above
  • โœ… Try the Fast install instead (5 minutes)
  • โœ… Make sure your phone isn't in power saving mode

"Python installation failed"

Install Python manually:

# Termux
pkg install python

# Ubuntu/Debian
sudo apt install python3 python3-pip

# Arch
sudo pacman -S python python-pip

Compilation errors on Termux

The full launcher auto-installs build dependencies, but if you have issues:

pkg install rust clang make libxml2 libxslt -y

๐Ÿค Related Projects

  • Windows Launcher: g4f.exe - Windows GUI installer by the same author
  • G4F Project: gpt4free - The main g4f project by @xtekky

๐ŸŽฏ Why This Exists

The official g4f installation (pip install g4f) works great for developers, but this launcher:

  • โœ… Handles all dependencies automatically
  • โœ… Works for non-technical users
  • โœ… Optimized for Termux/Android
  • โœ… Provides fast installation option
  • โœ… Creates convenient shortcuts
  • โœ… Supports silent/automated deployments

Official g4f method:

# User must know Python, pip, handle errors, etc.
pip install g4f[all]
python -m g4f.cli api --port 8080

This launcher:

# Just worksโ„ข
./g4f_launcher.sh

๐Ÿ“ Version History

v1.1.0 (2025-01-09)

  • โœจ Added Termux fast install mode (~5 minutes)
  • ๐Ÿ”ง Auto-installs build dependencies on Termux
  • ๐Ÿ› Fixed compilation issues with lxml, primp, and other C dependencies
  • ๐Ÿ“Š Added installation time estimates
  • ๐ŸŒก๏ธ Added thermal warnings for Termux users
  • ๐Ÿ“ Improved error messages and logging

v1.0.0 (2025-01-09)

  • ๐ŸŽ‰ Initial release
  • โœ… Support for Linux and Termux
  • โœ… Auto-detection of system
  • โœ… Silent mode support
  • โœ… Optional components

๐Ÿ“ License

MIT License - See LICENSE file for details


๐Ÿ‘ค Author

jokukiller


โญ Support

If this helped you, consider:

  • โญ Starring this repo
  • โญ Starring the main g4f project
  • ๐Ÿ› Reporting issues
  • ๐Ÿ”ง Contributing improvements
  • ๐Ÿ“ข Sharing with others who might find it useful

๐Ÿ™ Credits

  • H Lohaus (@hlohaus) - Current g4f maintainer
  • xtekky (@xtekky) - Original g4f creator
  • g4f community - For the amazing AI aggregation project

๐Ÿ”ฎ Future Plans

  • ๐Ÿ“ฆ Submit to Termux User Repository (TUR)
  • ๐ŸŽจ Add Termux:Widget support (one-tap launch from home screen)
  • ๐Ÿ”„ Auto-update checker
  • ๐ŸŒ Multi-language support
  • ๐Ÿ“ฑ iOS/iSH support

Enjoy running AI locally on your device! ๐Ÿš€

Questions? Open an issue: GitHub Issues

About

G4F Launcher for Linux and Termux (Android). One-command installation of g4f with automatic setup.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages