AG is a powerful command-line interface (CLI) tool that allows you to interact with OpenAI-compatible AI models directly from your terminal. It supports both single-query mode and interactive chat sessions, with advanced features like file/URL content integration, command execution, and grep-like filtering.
- Multi-API Compatibility: Works with any OpenAI-compatible API (including Ollama, LiteLLM, etc.)
- Dual Model Support: Optimized for both OpenAI-style and Gemini-style model behaviors
- Smart Content Integration:
@file(path)- Directly include file contents@url(URL)- Fetch and process webpage content@search(query)- Web search results integration
- Built-in Command Execution:
- Execute shell commands with
!commandsyntax - View output directly in your session
- Execute shell commands with
- Intelligent Text Filtering:
- AI-powered grep with natural language patterns (
-gflag) - Pipe-aware input handling
- AI-powered grep with natural language patterns (
- Enhanced Terminal Experience:
- Real-time streaming responses
- Optional reasoning visibility
- Full terminal control with proper TTY management
pip install openai requests beautifulsoup4 wcwidthag "Your question here"agcat file.txt | ag "Your question about the file content"cat logfile.txt | ag -g "error messages related to database connections"@file(/path/to/file.txt)
@url(https://example.com)
@search(your search content)
@file(path): Include content from a file@url(URL): Include content from a webpage
!command: Execute a shell command!clear: Clear the conversation history
| Option | Description | Default |
|---|---|---|
--api-url |
API endpoint URL | http://localhost:11434/v1 |
--model |
Model name to use | deepseek-reasoner |
--model-type |
Model API type (openai or gemini) |
openai |
--api-key |
API key | sk-... or OPENAI_API_KEY env var |
--max-tokens |
Maximum tokens for response | 4096 |
--frequency-penalty |
Frequency penalty (0.0-2.0, -1 to disable) | 0.5 |
--presence-penalty |
Presence penalty (0.0-2.0, -1 to disable) | 0.5 |
-g/--grep-enabled |
Enable AI-powered grep filter mode | False |
-r/--hide-reasoning |
Hide model reasoning content | False |
- Query about local files:
ag "@file(~/projects/notes.txt) summarize the key points"- Research a webpage:
ag "@url(https://en.wikipedia.org/wiki/Machine_learning) what are the three main types of machine learning?"- Interactive research session:
ag
> @url(https://news.ycombinator.com/)
> what are today's top AI stories?
> !curl https://api.example.com/data | jq .stats
> analyze these statistics
- Web search integration:
ag "@search(2024 AI trends) summarize top 3 trends"
- Ctrl+D: Submit current input
- Ctrl+C: Cancel current input or exit if input is empty
- Tab: Auto-completion (when readline is available)