Perplexity CLI Agent
A command-line interface for Perplexity AI.
- Query Perplexity AI directly from your terminal
- Supports multiple models (e.g., sonar-pro, mistral-7b-instruct)
- Simple, scriptable, and fast
- pplx - supports default models for non-pro perplexity users.
- pplxpro - supports additional models for perplexity pro users.
- sonar-small-online
- sonar-medium-online
- sonar-small-chat
- sonar-medium-chat
- mistral-7b-instruct
- llama-3.1-sonar-small-128k-online
- llama-3.1-sonar-large-128k-online
- sonar-pro
- gpt-4-omni
- claude-3.5-sonnet
- gemini-2.0-flash
- macOS Sequoia (or similar Unix-like system)
- Python 3.6 or later
git
- Perplexity API key
- Perlexity API URL endpoint
git clone https://github.com/naelmohammad/pplx.git
cd pplx
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
mv pplx > ~/.local/bin/pplx
mv pplxpro > ~/.local/bin/pplxpro
chmod +x ~/.local/bin/pplx
chmod +x ~/.local/bin/pplxpro
Ensure ~/.local/bin
is in your PATH.
For bash:
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
For zsh (default on recent macOS):
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc
Generate your API key at: Perplexity API Docs
Export your API key as an environment variable:
For bash:
echo 'export PPLX_API_KEY="your-api-key"' >> ~/.bashrc
echo 'export PPLX_API_URL="your-api-URL-endpoint"' >> ~/.bashrc
For zsh:
echo 'export PPLX_API_KEY="your-api-key"' >> ~/.zshrc
echo 'export PPLX_API_URL="your-api-URL-endpoint"' >> ~/.zshrc
Reload your shell configuration:
source ~/.bashrc # or source ~/.zshrc
Ask a question from your terminal:
pplx "What is the purpose of epoch format?"
pplxpro "What is the purpose of epoch format?"
Specify a model:
pplx -m sonar-pro "Explain Moore's Law"
pplxpro -m llama-3.1-sonar-small-128k-online "What is Moore's Law?"
Show help and options:
pplx -h
pplxpro -h
usage: pplx [-h] [-m {sonar-pro,mistral-7b-instruct,sonar-small,sonar-medium}] query [query ...]
positional arguments:
query Your search query (no quotes needed)
options:
-h, --help Show this help message and exit
-m, --model Model to use (default: sonar-pro)
usage: pplxpro [-h] [-m {sonar-small-online,sonar-medium-online,sonar-small-chat,sonar-medium-chat,mistral-7b-instruct,llama-3.1-sonar-small-128k-online,llama-3.1-sonar-large-128k-online,sonar-pro,gpt-4-omni,claude-3.5-sonnet,gemini-2.0-flash}] query [query ...]
- Ensure your API key is set and your shell is reloaded.
- Make sure
~/.local/bin
is in your PATH. - For issues, open an issue on GitHub.
GPL V3 License
Happy querying!