Skip to main content

A lightweight CLI wrapper for Google Gemini & OpenAI — built for Termux and Linux terminals.

Project description

Termai

Termai is a lightweight, zero-dependency CLI wrapper for Google's Gemini AI, built for Termux on Android and general Linux environments. It brings the power of Large Language Models (LLMs) directly to your command line, following the Unix philosophy of piping and standard streams.

Features

  • Lightweight: Uses standard Python requests. No heavy SDKs or complex dependencies.
  • Unix Compatible: Supports piping (stdin). Feed logs, code, or text files directly into the AI.
  • Configurable: Built-in JSON configuration system (ai --config) to edit System Prompts, Temperature, and Models.
  • Fast: Defaults to gemini-2.5-flash for instant responses.
  • Clean UI: Minimalist output with syntax-highlighted green text.

Installation

You can install Termai as a global Python package using pipx (recommended for isolated environments like Termux) or standard pip.

# Using pipx (recommended)
pipx install termask-ai

# Or using pip
pip install termask-ai

After installation, the global commands ai and termai will be available in your terminal.

Setup

On the very first run, Termai will ask for your Google Gemini API Key.

  • Get a free API key here: Google AI Studio
  • Run the command:
ai "hello"
  • Paste your key when prompted. It will be saved locally.

Usage

  1. Basic Questions Ask anything directly from the terminal.
ai "How do I untar a file in Linux?"
  1. Piping (The Power Move) Feed output from other commands into Termai. Debug an error log:
cat error.log | ai "Explain what caused this crash"

Explain a file:

cat README.md | ai "Summarize this project in one sentence"

Generate code and save it:

ai "Write a Python hello world script" > hello.py
  1. Saving Outputs (With Terminal Output) You can save the response to a file while still viewing the output in your terminal:
# Save a single-query response
ai "Explain machine learning in 1 sentence" -o ml_concept.txt

# Automatically save a chat session transcript when you exit
ai chat -o chat_session.md
  1. Interactive Chat Start an interactive, multi-turn chat session with memory:
ai chat
  • Rich Terminal Aesthetics: Interactive chat features a beautiful slate-blue header card and full-width royal-purple highlight blocks for user messages (properly aligned even when emojis are used).
  • Conversation Snapshots: Save your chat transcript in clean Markdown format at any point during the conversation by typing:
    save snapshot.md
    

Profile Management

Termai supports multiple AI provider configurations. You can manage them using the profile subcommand:

  • List profiles:
    ai profile
    
    (Alias: ai profile list)
  • Switch default active profile:
    ai profile use [profile_name]
    
    (Launches an interactive selection list if no profile name is provided)
  • Add a new profile:
    ai profile add <name>
    
  • Remove a profile:
    ai profile remove <name>
    
    (Alias: ai profile rm)
  • Run query with temporary profile:
    ai -p <profile_name> "your query"
    

Configuration

Termai comes with a built-in configuration editor. You can change the AI provider, model, and personality. Run:

ai --config

This opens config.json in your preferred editor. The editor is chosen based on the following priority:

  1. The $EDITOR environment variable.
  2. vim (if installed).
  3. nano (as a fallback).

The configuration file looks like this:

{
    "provider": "gemini",
    "proxy": "http://user:pass@127.0.0.1:1080",
    "gemini_config": {
        "api_key": "YOUR_GEMINI_KEY",
        "model_name": "gemini-2.5-flash",
        "system_instruction": "You are a CLI assistant for Termux...",
        "generation_config": {
            "temperature": 0.7,
            "maxOutputTokens": 1024
        }
    },
    "openai_config": {
        "api_key": "YOUR_OPENAI_KEY",
        "model_name": "gpt-4o",
        "system_instruction": "You are a helpful assistant.",
        "temperature": 0.7,
        "max_tokens": 1024
    }
}
  • provider: Set to "gemini" or "openai" to choose your AI provider.
  • proxy: (Optional) Set an HTTP or HTTPS proxy for all requests.
  • gemini_config: Settings for when provider is "gemini".
    • model_name: Change to gemini-2.5-pro or other available models.
    • system_instruction: Give the AI a persona.
    • temperature: Set to 1.0 for creative answers, 0.1 for precise logic.
  • openai_config: Settings for when provider is "openai".
    • model_name: Change to gpt-3.5-turbo, etc.
    • system_instruction: A different persona for ChatGPT.
    • temperature: Controls randomness.
    • max_tokens: The maximum number of tokens to generate.

Shell Auto-Completion

Termai includes built-in dynamic shell autocompletion for subcommands, options, profile names, and models.

To enable shell auto-completion, add one of the following commands to your shell profile file (like ~/.bashrc or ~/.zshrc):

  • Bash (add to ~/.bashrc):
    source <(ai completion bash)
    
  • Zsh (add to ~/.zshrc):
    source <(ai completion zsh)
    

Help & Troubleshooting

Command List:

ai --help

Re-configure API Keys:

To reset and re-enter your API keys, use the --reinstall flag.

ai --reinstall

Debug Mode:

If the AI isn't responding or you are getting errors, run:

ai --debug "your question"

This will print the raw server response and error codes.

Debug Configuration: If you are having issues with your configuration, you can use the --debug-config flag to print the loaded configuration. API keys will be redacted for security.

ai --debug-config

Uninstallation

To remove Termai completely:

# If installed via pipx
pipx uninstall termask-ai

# If installed via pip
pip uninstall termask-ai

# Optional: Remove configuration files
rm -rf ~/.config/termai
rm -rf ~/.local/share/termai

License

This project is licensed under the MIT License. You are free to use, modify, and distribute this software. See the LICENSE file for more details.

Made for CLI enthusiasts

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

termask_ai-1.0.0.tar.gz (19.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

termask_ai-1.0.0-py3-none-any.whl (17.3 kB view details)

Uploaded Python 3

File details

Details for the file termask_ai-1.0.0.tar.gz.

File metadata

  • Download URL: termask_ai-1.0.0.tar.gz
  • Upload date:
  • Size: 19.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for termask_ai-1.0.0.tar.gz
Algorithm Hash digest
SHA256 72c48d2e2ec384f3ec32ce2b6839dbfdb3aeec149d3eb527b7a77402d84438d1
MD5 1cd362cb7fc856af22ca05c234dc3513
BLAKE2b-256 da43e6a87746905012f9386e378ef9e88eb5681795c2d9913028ed1881ed4152

See more details on using hashes here.

File details

Details for the file termask_ai-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: termask_ai-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 17.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for termask_ai-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d82322716663f6c467c023b22c7b089e6921db0befb0aa6a4d076761bb307b65
MD5 5229c7031d414040d0005e89aa00cb47
BLAKE2b-256 4721fe407dbf157b92e7bc249aa3ba4885d8dcfadeaaf2e3b6f267e3e594da0f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page