A command-line tool for analyzing text using OpenRouter API with language models.
3G-CLI Suite: Glean (text analysis) | Glimpse (image analysis) | Graft (image generation and editing)
- Clone this repository
- Set up a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
- Install dependencies:
pip install -r requirements.txt
- The script is now ready to use! It's directly executable without needing to specify the Python interpreter.
Create a ~/.glean_cfg file in your home directory with the following format:
[openrouter]
# Required setting
api_key = your_api_key_here
# Optional settings (defaults shown)
model = google/gemini-2.0-flash-exp
temperature = 0.4 # Controls randomness (0.0 to 1.0, lower is more deterministic)
system_prompt = You are a helpful assistant. # Optional system prompt for all requests
http_proxy = http://localhost:8888 # Optional HTTP proxy for API requestsOnly the API key is mandatory. If model, temperature, system_prompt, or http_proxy are not specified, default values will be used (no system prompt or proxy by default).
glean/
├── glean.py # Main executable script
├── requirements.txt # Python dependencies
├── venv/ # Virtual environment (created during setup)
├── .gitignore # Git ignore file
└── README.md # This file
From a file:
./glean.py document.txt
./glean.py notes.mdFrom stdin:
echo "Analyze this text" | ./glean.py
cat article.txt | ./glean.pyWith a custom prompt:
./glean.py document.txt --prompt "Summarize the key points"
cat article.md | ./glean.py -p "Extract all action items"Override the model:
./glean.py notes.txt --model anthropic/claude-3.5-haikuOverride the temperature setting:
./glean.py document.md --temperature 0.8Combining options:
./glean.py report.txt -m openai/gpt-4o-mini -t 0.2 -p "What are the main risks mentioned?"List available models (names only):
./glean.py --list-modelsList available models with detailed information:
./glean.py --list-models-with-detailsWhen using Glean in shell scripts, be aware that it captures stdin. For processing multiple prompts or files, you need to redirect stdin appropriately:
#!/bin/bash
# Single prompt in a script
./glean.py -p "Analyze this data" < /dev/null
# Process multiple prompts from a file (handles prompts with spaces)
while read -r p; do
./glean.py -p "$p" < /dev/null
done < prompts.txt
# Process multiple files with the same prompt
for file in *.txt; do
./glean.py "$file" -p "Summarize this document" < /dev/null
done
# Combine with other commands (redirect stdin to avoid conflicts)
echo "Processing files..." | while read -r line; do
./glean.py -p "What is the main topic?" < /dev/null
doneImportant: Always use < /dev/null when calling Glean in loops or scripts to prevent it from consuming stdin that should be used by the loop itself.
- Plain text (.txt)
- Markdown (.md)
- Text from stdin
Without a custom prompt, Glean will provide a comprehensive analysis of the text including summary, key points, and insights.