A lightweight script for interactive CLI conversations with LLM models via OpenAI-compatible APIs.
- Command execution - AI can run system commands with user confirmation
- Markdown rendering (with bat or mdcat -- or python rich library)
- Model switching on the fly (with fzf)
- Context-aware - includes system info (date, distro, shell, editor)
- Interactive chat interface with conversation history
- Readline support - history, arrow keys, ctrl+l to clear
- Clone or download
llm.sh - Make it executable:
chmod +x llm.sh - Install dependencies for better experience:
# For model selection menu sudo pacman -S install fzf # For bash markdown rendering sudo pacman -S bat or mdcat
Edit the script to set your API endpoint and key:
API_BASE="http://your-server:8080/api"
API_KEY="your-api-key"
MODEL="your-model-name"The script uses the OpenAI chat completions format (/v1/chat/completions). It works with:
- Open WebUI - Use your Open WebUI API endpoint and key
- OpenRouter - Should work with
https://openrouter.ai/apiand your OpenRouter key - Any OpenAI-compatible API (Ollama, LM Studio, vLLM, etc.)
The /models command fetches available models from /v1/models endpoint and displays them in an interactive menu (requires fzf). This endpoint returns a list of models in OpenAI format:
{
"data": [
{"id": "model-id", "name": "Model Name"},
...
]
}If your API provider implements this endpoint, model switching will work automatically.
Run the script:
./llm.sh/models- Switch model (interactive menu)/clear- Clear conversation history/exit- Exit (or use Ctrl+D)Ctrl+L- Clear conversationCtrl+C- Cancel current request
The AI can execute system commands using [RUN:command] syntax. You'll be prompted to confirm, deny, or edit each command before execution:
🔧 Command: ls -la
[Y]es / [n]o / [e]dit ?
> what files are in this directory?
[RUN:ls -la]
🔧 Command: ls -la
[Y]es / [n]o / [e]dit ? y
total 48
drwxr-xr-x 6 user user 4096 Oct 3 10:30 .
drwxr-xr-x 20 user user 4096 Oct 3 10:25 ..
-rwxr-xr-x 1 user user 8429 Oct 3 10:30 llm.sh
...
You have several files including the llm.sh script itself,
some hidden git files, and a README.md.
