A lightweight command-line tool for querying AI models via OpenRouter API, with optional Claude Code integration for direct access to Claude models.
- Dual Backend Support: OpenRouter (default) or Claude Code integration
- Simple Usage: Just type
askfollowed by your question - Multiple Models: Quick shortcuts for various AI models
- Direct Answers: Optimized for command-line usage (no markdown, executable output)
- Web Search: Optional web access for current information (Claude Code only)
- Safety Features: Multiple layers of protection against destructive commands
- Interactive Installer: Choose your preferred setup during installation
- Configurable: Set default models, safety limits, and features via config
# Clone the repository
git clone https://github.com/kagisearch/ask.git
cd ask
# Run the interactive installer
./install.sh
# Choose your installation type:
# 1) OpenRouter only (original functionality)
# 2) Claude Code + OpenRouter (full integration)- No additional dependencies required
- Uses your OpenRouter API key
- Access to Gemini, GPT-4, Qwen, and more
- Requires Python 3.10+ and Node.js
- Installs Claude CLI (
npm install -g @anthropic-ai/claude-code) - Direct access to Claude Haiku, Sonnet, and Opus
- Falls back to OpenRouter if Claude is unavailable
# Use default model (configurable, defaults to Sonnet)
ask "Write hello world in Python"
# Force specific Claude models
ask -h "Quick calculation: 18% of 2450" # Haiku (fast)
ask -s "Explain quantum computing" # Sonnet (balanced)
ask -o "Complex reasoning task" # Opus (powerful)
# Use OpenRouter models
ask -m "Generate code" # Mercury Coder
ask -g "General question" # Gemini Flash# Set your API key
export OPENROUTER_API_KEY="your-key-here"
# Use default model (Mercury Coder)
ask "What is 2+2?"
# Use specific models
ask -g "Explain quantum computing" # Gemini 2.5 Flash
ask -k "Process this document" # Kimi K2
ask -q "Complex analysis" # Qwen 235B| Flag | Model | Backend | Best For |
|---|---|---|---|
| (none) | Configurable | Claude/OpenRouter | General use |
-h |
Claude Haiku | Claude Code | Fast, simple tasks |
-s |
Claude Sonnet | Claude Code | Balanced (default) |
-o |
Claude Opus | Claude Code | Complex reasoning |
-m |
Mercury Coder | OpenRouter | Code generation |
-g |
Gemini 2.5 Flash | OpenRouter | General purpose |
-k |
Kimi K2 | OpenRouter | Long context |
-q |
Qwen 235B | OpenRouter | Large model tasks |
Set your preferred default model in order of preference:
- Command-line flag (
-h,-s,-o) - Environment variable:
export ASK_DEFAULT_MODEL=haiku|sonnet|opus - Config file:
~/.ask/configwithdefault_model=haiku|sonnet|opus - Falls back to
sonnetif not configured
The Claude Code integration includes multiple safety layers:
- System Prompt Safety Rules: Claude is instructed to never execute destructive commands
- Warning Prefixes: Destructive commands are prefixed with
⚠️ DESTRUCTIVE: - Optional Turn Limiting: Set
max_turns=1in~/.ask/configto limit tool execution - Web Search Control: Web access disabled by default, enable with
enable_web=true - Explicit Consent: Installer requires typing "yes" to acknowledge risks
When enabled, Claude can search the web and fetch current information:
# Enable in config
echo "enable_web=true" >> ~/.ask/config
# Use it
ask "what is the top story on hacker news"
ask "current weather in San Francisco"
ask "latest Python version"Web search is disabled by default for privacy and safety. Enable during installation or by editing ~/.ask/config.
To modify settings, edit ~/.ask/config:
default_model=haiku|sonnet|opus- Set default Claude modelmax_turns=1- Limit tool execution (may prevent some features)enable_web=true|false- Enable/disable web search capabilities
For OpenRouter:
curl,jq,bc(usually pre-installed)- OpenRouter API key
For Claude Code (optional):
- Python 3.6+
- Node.js and npm
- Claude CLI:
npm install -g @anthropic-ai/claude-code - Active Claude Code subscription
# Custom system prompt
ask --system "You are a pirate" "Tell me about sailing"
# Disable system prompt (OpenRouter only)
ask -r -m "What is 2+2?"
# Streaming responses (OpenRouter only)
ask --stream "Tell me a long story"
# Pipe input
echo "Fix this code: print('hello world)" | ask
cat script.py | ask "Review this code"# Get executable commands directly
ask "Command to find files larger than 100MB"
# Output: find . -type f -size +100M
ask "ffmpeg command to convert mp4 to gif"
# Output: ffmpeg -i input.mp4 -vf "fps=10,scale=320:-1:flags=lanczos" output.gif
# Safety: Destructive commands get warnings
ask "command to delete all files in /tmp/test"
# Output: ⚠️ DESTRUCTIVE: rm -rf /tmp/test/*# Calculations
ask "What is 18% of 2450?"
# Output: 441
# Technical questions
ask "What port does PostgreSQL use?"
# Output: 5432# Code review with Sonnet
cat script.py | ask -s "Find potential bugs"
# Quick fix with Haiku
echo "def func(x): return x/0" | ask -h "Fix this function"
# Complex refactoring with Opus
cat large_module.py | ask -o "Refactor for better performance"- Fast: Direct CLI calls with
-pflag for non-interactive mode (~3-4s responses) - Flexible: Switch between Claude and OpenRouter models with simple flags
- Clean Output: No markdown or formatting - just executable answers
- Scriptable: Perfect for automation and shell scripts
- Cost-Effective: Use cheaper models for simple tasks, powerful ones when needed
Pull requests are welcome! The installer is designed to be backwards-compatible, so OpenRouter-only users aren't affected by Claude Code integration.
MIT