A beautiful, feature-rich command-line interface for the Perplexity AI API with interactive arrow navigation โ Cross-platform (Linux, macOS, Windows)
- Beautiful Terminal UI - ASCII art "PERPLEXITY CLI" banner, colored output, status bars, and formatted messages
- Arrow Navigation Menus - Interactive settings and model selection with โโ keys
- Interactive Chat Mode - Full REPL with slash commands and conversation history
- Markdown Formatting - Supports bold, italic, code blocks, headers, and lists
- Rich Text Output - Syntax highlighting, colored code blocks, and styled links
- Real-time Streaming - Watch answers generate with proper word wrapping
- Conversation Persistence - Save/load chats and export to Markdown
- Custom System Prompts - Create custom AI personas
- Citations Support - View source citations for research answers
- Secure API Keys -
.envfile support for secure API key management
# Install dependencies
pip install openai python-dotenv
# Copy the script
cp perplexity ~/.local/bin/perplexity
chmod +x ~/.local/bin/perplexity
# Add to PATH (if not already)
export PATH="$HOME/.local/bin:$PATH"
# Start chatting!
perplexity --chat# Install dependencies
pip install openai python-dotenv
# Copy the script to a folder in your PATH
# Common locations:
# C:\Users\%USERNAME%\AppData\Local\Programs\Python\Python3xx\Scripts\
# C:\Users\%USERNAME%\AppData\Local\Microsoft\WindowsApps\
Copy-Item perplexity $env:USERPROFILE\perplexity.py
# Create an alias (add to your PowerShell profile)
# Run `notepad $PROFILE` and add:
# function perplexity { python $env:USERPROFILE\perplexity.py @args }
# Start chatting!
perplexity --chatREM Install dependencies
pip install openai python-dotenv
REM Copy to a folder in PATH, e.g.:
COPY perplexity C:\Users\%USERNAME%\AppData\Local\Programs\Python\Python3xx\Scripts\perplexity.py
REM Create batch wrapper (one-time):
echo @python "%USERPROFILE%\perplexity.py" %* > C:\Windows\perplexity.bat
REM Start chatting!
perplexity --chatGet your API key from perplexity.ai/settings/api
export PERPLEXITY_API_KEY="your-api-key-here"Linux / macOS:
mkdir -p ~/.perplexity
cat > ~/.perplexity/.env << 'EOF'
PERPLEXITY_API_KEY=your-api-key-here
EOFWindows (PowerShell):
New-Item -Path "$env:USERPROFILE\.perplexity" -ItemType Directory -Force
Set-Content -Path "$env:USERPROFILE\.perplexity\.env" -Value "PERPLEXITY_API_KEY=your-api-key-here"Windows (Command Prompt):
mkdir "%USERPROFILE%\.perplexity"
echo PERPLEXITY_API_KEY=your-api-key-here > "%USERPROFILE%\.perplexity\.env"perplexity --chat # or -c
perplexity --chat --stream
perplexity --chat --model sonar-medium-online
perplexity --chat --system "You are a sarcastic comedian"perplexity "What is the capital of France?"
perplexity "Explain quantum physics" --stream
perplexity "Latest AI news" --search
perplexity "Debug this code" --system "You are a Python expert"| Command | Description |
|---|---|
/menu |
โญ Open interactive settings menu (arrow keys) |
/model |
Switch AI model with arrow selection |
/help |
Show interactive help box |
/clear |
Clear conversation history |
/save |
Save current conversation |
/export |
Export conversation to Markdown |
/history |
List all saved conversations |
/load |
Load a saved conversation |
/status |
Show current session info |
/quit |
Exit chat mode |
/exit |
Exit chat mode |
/q |
Exit chat mode |
Keyboard Shortcuts:
Ctrl+C- Interrupt current responseCtrl+D- Exit chat modeโโ- Navigate menusENTER- Select menu itemESC- Cancel/close menu
| Option | Short | Description | Default |
|---|---|---|---|
query |
- | Your question or search query | - |
--chat |
-c |
Enter interactive chat mode | - |
--model |
- | Model to use | sonar-pro |
--search |
- | Use research-focused mode | - |
--stream |
- | Stream responses in real-time | - |
--system |
-s |
Custom system prompt | - |
--api-key |
- | Override API key | - |
--no-color |
- | Disable colored output | - |
| Model | Best For | Speed |
|---|---|---|
sonar-pro |
General queries with web citations | โญโญ |
sonar-medium-online |
Faster responses | โญโญโญ |
sonar-small-online |
Quick answers | โญโญโญโญ |
$ perplexity "What is the capital of Australia?"
โโ Perplexity โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Canberra, located in the Australian Capital Territory.
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ$ perplexity "Latest developments in AI agents" --search
โโ Perplexity โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ AI agents are evolving rapidly with new capabilities...
๐ Sources
[1] https://perplexity.ai/blog/ai-agents
[2] https://openai.com/research/agents
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ$ perplexity -s "You are a sarcastic pirate captain" "Tell me a joke"
โโ Perplexity โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Arrr, why did the pirate go to medical school?
โ Because he wanted to study "arrr-thritis", ye scallywag!
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโConversations are saved automatically to ~/.cache/perplexity/ as JSON files.
# List saved conversations
You: /history
๐ Saved Conversations
โข chat_20240203_153045.json (5 msgs) - 2024-02-03T15:30:45
โข chat_20240203_140000.json (12 msgs) - 2024-02-03T14:00:00
# Load a conversation
You: /load
[1] chat_20240203_153045.json (5 msgs)
[2] chat_20240203_140000.json (12 msgs)
Load which one? (number or 'cancel'): 1
โ Loaded 5 messages.
# Export to Markdown
You: /export
Output filename (e.g. chat.md): my_research.md
โ Exported to: my_research.md โโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโ โโโโโโโโ
โโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โโโ โโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโ
โโโ โโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโ
โโโโโโโโโโโโโโโโโโโโ โโโโโโ โโโโโโโโโโโ
โโโโโโโ โโโโโโโโโโโ โโโโโโ โโโโโโโโโโโ
CLI v2.0
โโโ Model: SONAR PRO 2024-02-03 03:30 PM โโโ
MENU OPTIONS:
Type '/menu' to open settings
Type '/help' for all commands
Quick Commands:
/menu Open settings menu (arrow navigation)
/model Switch AI model
/clear Clear conversation
/save Save conversation
/export Export to Markdown
/history List saved chats
/load Load saved chat
/quit Exit
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ PERPLEXITY CLI โข SETTINGS โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โบ ๐ค Change Model
๐ง API Settings
๐พ Conversation History
๐ค Export Conversation
โน๏ธ About
โ Back to Chat
โโ Navigate โข ENTER Select โข ESC Cancel
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ PERPLEXITY CLI โข SELECT MODEL โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Sonar Pro (Best) โโ Recommended for complex queries
โ Sonar Medium โโ Faster responses
โ Cancel
โโ Navigate โข ENTER Select โข ESC Cancel
โโ You โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ What is quantum computing?
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โโ Perplexity โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Quantum computing is a revolutionary field that uses
โ quantum mechanics to process information in ways
โ classical computers cannot...
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ Sources
[1] https://example.com/quantum-intro
[2] https://example.com/qubits-explained
| File/Folder | Linux/macOS | Windows | Purpose |
|---|---|---|---|
.env |
~/.perplexity/.env |
%USERPROFILE%\.perplexity\.env |
API key configuration |
| Conversations | ~/.cache/perplexity/ |
%USERPROFILE%\.cache\perplexity\ |
Saved chat history |
| Script | ~/.local/bin/perplexity |
%USERPROFILE%\perplexity.py |
CLI executable |
-
Custom Personas: Use
--systemto create different AI personalities"You are a sarcastic comedian""You are a senior code reviewer""You explain things like I'm 5"
-
Faster Responses: Use
sonar-small-onlinefor quick answers -
Interrupting: Press
Ctrl+Cto interrupt long responses -
Research: Use
--searchfor complex topics requiring citations -
Documentation: Export chats to Markdown for documentation
Error: API key not found. Set PERPLEXITY_API_KEY or create ~/.perplexity/.envSolution: Create an .env file or set the environment variable.
ModuleNotFoundError: No module named 'openai'Solution: Install dependencies with pip install openai python-dotenv
Linux/macOS: Colors are automatically disabled when piping to a file or using --no-color.
Windows: If colors aren't showing:
- Use Windows Terminal or PowerShell 7+ (supports ANSI colors)
- For older Command Prompt, colors may not work - use
perplexity --no-color - Use PowerShell 5.1+: Install Windows Terminal for best experience
MIT License - see LICENSE for details.
Contributions are welcome! Feel free to:
- Open an issue for bugs or feature requests
- Submit a pull request with improvements
- Share your creative prompt ideas
- Built with Perplexity AI API
- Inspired by Ollama CLI
- ASCII art generated with
figlet
Made with โฅ by Dodothereal
