A simple command-line interface to interact with local AI models from anywhere in your terminal using Ollama. No API keys, no costs β runs entirely on your machine.
- π Global Access: Use
tgptfrom any directory in your terminal - π¬ Simple Syntax: Just type your question after
tgpt - π Fully Local: Powered by Ollama β no internet or API keys required
- π Model Switching: Easily switch between any locally pulled model
- β‘ Fast: Quick responses for terminal workflows
- π‘οΈ Error Handling: Helpful error messages and validation
- Python 3.8 or higher
- Ollama installed and running
- Git (for cloning) and a shell (Bash for Linux/macOS/WSL, Git Bash for Windows)
# Linux / macOS
curl -fsSL https://ollama.com/install.sh | sh
# Windows: download the installer from https://ollama.com/downloadollama pull qwen3-next:80b-cloud
# or any other model: ollama pull mistralollama serveOn macOS and Windows, Ollama usually starts automatically. On Linux, you may need
ollama serveor a systemd service.
git clone https://github.com/Builder-Byte/TGPT
cd TGPTThe bundled updater handles Linux, macOS, WSL, and Windows (via Git Bash):
chmod +x update-tgpt.sh tgpt
./update-tgpt.shWhat the updater does:
- Linux/macOS: installs to
/usr/local/bin/tgptif writable (or viasudo), otherwise to~/.local/bin/tgpt. - Windows (Git Bash/MSYS/WSL): copies the script to
~/.local/bin/tgpt.pyand createstgpt.cmdandtgptshims in the same folder. Add~/.local/binto your PATH for PowerShell/CMD/Git Bash.
If you prefer not to run Bash on Windows:
# From the repo root
$target = "$env:USERPROFILE\.local\bin"
New-Item -ItemType Directory -Force -Path $target | Out-Null
Copy-Item tgpt "$target\tgpt.py"
"@echo off`npython `%~dp0tgpt.py` %*" | Set-Content "$target\tgpt.cmd"
[System.Environment]::SetEnvironmentVariable("Path", "$target;" + [System.Environment]::GetEnvironmentVariable("Path", "User"), "User")Restart your shell, then run tgpt -h.
tgpt "your question here"| Flag | Description | Example |
|---|---|---|
| (default) | Short, concise answers (1-2 sentences or brief paragraph) | tgpt "What is Python?" |
-l |
Long, detailed explanations | tgpt -l "What is Python?" |
-m <model> |
Use a specific Ollama model | tgpt -m mistral "What is Python?" |
--list-models |
Show all locally available models | tgpt --list-models |
-h |
Show help message and usage examples | tgpt -h |
- Default (Short): Gives brief, concise answers perfect for quick terminal queries
- Long (
-l): Provides detailed, comprehensive explanations when you need more context
# Short answers (default behavior)
tgpt "What is the capital of France?"
tgpt "What is Python?"
# Long answers (detailed explanations)
tgpt -l "What is Python?"
tgpt -l "Explain machine learning"
# Use a specific model
tgpt -m mistral "Explain recursion"
tgpt -m llama3.2 "Write a bash one-liner to find large files"
# List all locally available models
tgpt --list-models
# Programming help
tgpt "How do I create a Python virtual environment?"
tgpt -l "How do I create a Python virtual environment?"
# Code generation
tgpt "Write a bash script to backup a directory"
tgpt -l "Write a bash script to backup a directory"
# Help
tgpt -hThe tool handles Ctrl+C gracefully:
- Shows "π€ Thinking..." while processing requests
- Press Ctrl+C to cancel ongoing requests
- Displays user-friendly termination messages
The default model is qwen3-next:80b-cloud. To change it permanently, edit the DEFAULT_MODEL variable at the top of the tgpt script:
DEFAULT_MODEL = "qwen3-next:80b-cloud" # Change to your preferred modelBy default, tgpt connects to Ollama at http://localhost:11434. If you're running Ollama on a different host or port, update OLLAMA_BASE_URL in the script:
OLLAMA_BASE_URL = "http://localhost:11434"The script limits responses to 1000 tokens by default. Adjust num_predict in the query_ai function if you need longer outputs:
"options": { "num_predict": 1000 }-
"command not found: tgpt"
- Make sure the script is in your PATH
- Check:
echo $PATHβ ensure/usr/local/binor~/.local/binis listed - Try the alternative installation method using
~/.local/bin
-
"Error: Ollama is not running"
- Start Ollama:
ollama serve - On Linux, you can set it up as a service:
systemctl enable --now ollama
- Start Ollama:
-
Model not found
- Pull the model first:
ollama pull qwen3-next:80b-cloud - List available models:
tgpt --list-modelsorollama list
- Pull the model first:
-
Slow responses
- Large models require significant RAM/VRAM
- Try a smaller model:
tgpt -m llama3.2 "your question"
-
Permission denied
- Make the script executable:
chmod +x tgpt
- Make the script executable:
# Check if tgpt is accessible
which tgpt
# Check if Ollama is running
curl http://localhost:11434/api/tags
# List available models
tgpt --list-models
# Test with a simple query
tgpt "hello"
# Test with long answer flag
tgpt -l "hello"
# Test with a specific model
tgpt -m mistral "hello"
# Check help
tgpt -hTGPT/
βββ tgpt # Main CLI script
βββ update-tgpt.sh # Cross-platform installer/updater
βββ README.md
Once you update the code, run:
chmod +x $(pwd)/update-tgpt.sh
./update-tgpt.sh- π Migrated from OpenRouter to Ollama (fully local, no API key required)
- π Added
-m <model>flag for per-query model switching - π Added
--list-modelsto browse locally available models - β Removed all external dependencies (pure Python standard library)
- π Added Ollama connectivity check before querying
- β¨ Added
-lflag for long, detailed answers - π― Default behavior now gives short, concise responses
- π‘οΈ Added keyboard interrupt handling (Ctrl+C)
- π Added help system with
-hflag - π¬ Added "Thinking..." indicator during API calls
- π¦ Graceful termination messages
- Initial release with OpenRouter integration