A powerful CLI tool for the Perplexity AI API - search the web and chat with AI from your terminal
npm install pplx-cliA powerful CLI tool for the Perplexity AI API - search the web and chat with AI from your terminal.
- 🔍 Web Search - Search the web with advanced filtering options
- 💬 AI Chat - Chat with Perplexity's AI models with web-grounded responses
- 🌊 Streaming - Real-time streaming responses
- 📚 Citations - See sources for AI-generated responses
- 🎯 Multiple Models - Support for Sonar, Sonar Pro, and Reasoning models
- ⚙️ Easy Configuration - Simple API key management
``bashUsing npm
npm install -g pplx-cli
Quick Start
1. Get your API key from Perplexity API Portal
2. Configure the CLI:
`bash
pplx config set-key pplx-xxxxxxxxxxxxxxxx
`3. Start asking questions:
`bash
pplx ask "What are the latest developments in AI?"
`Commands
$3
Manage your configuration.
`bash
Save your API key
pplx config set-key Show current configuration
pplx config showClear configuration
pplx config clear
`$3
Ask a single question to Perplexity AI.
`bash
Basic usage
pplx ask "What is the weather in Tokyo?"Use a specific model
pplx ask "Explain quantum computing" --model sonar-proStream the response in real-time
pplx ask "Latest tech news" --streamFilter by recency
pplx ask "Breaking news" --recency hourFilter by domain
pplx ask "Climate research" --domain nature.com --domain science.orgOutput as JSON
pplx ask "Hello world" --jsonHide citations
pplx ask "Quick question" --no-citationsCustom system prompt
pplx ask "Summarize this topic" --system "You are a concise summarizer"
`Options:
-
-m, --model - Model to use (sonar, sonar-pro, sonar-reasoning, sonar-reasoning-pro)
- -s, --stream - Stream the response in real-time
- -j, --json - Output raw JSON response
- -c, --citations - Show source citations (default: true)
- --no-citations - Hide source citations
- -r, --recency - Filter by recency (hour, day, week, month, year)
- -d, --domain - Filter by domain(s)
- --system - Custom system prompt$3
Search the web using Perplexity.
`bash
Basic search
pplx search "climate change research"Academic search
pplx search "machine learning papers" --mode academicLimit results
pplx search "tech news" --limit 5Filter by recency
pplx search "breaking news" --recency dayFilter by domain
pplx search "AI news" --domain techcrunch.comOutput as JSON
pplx search "query" --json
`Options:
-
-l, --limit - Maximum number of results (default: 10)
- -m, --mode - Search mode (web, academic, sec)
- -r, --recency - Filter by recency (hour, day, week, month, year)
- -d, --domain - Filter by domain(s)
- -j, --json - Output raw JSON response$3
Start an interactive chat session.
`bash
Start chat
pplx chatUse a specific model
pplx chat --model sonar-proWith custom system prompt
pplx chat --system "You are a helpful coding assistant"
`In-chat commands:
-
/clear - Clear conversation history
- /exit or /quit - Exit the chat
- /help - Show helpOptions:
-
-m, --model - Model to use
- --system - Custom system prompt
- -r, --recency - Filter by recency
- -d, --domain - Filter by domain(s)Available Models
| Model | Description |
|-------|-------------|
|
sonar | Fast, cost-effective model (default) |
| sonar-pro | Advanced model with better quality |
| sonar-reasoning | Model with reasoning capabilities |
| sonar-reasoning-pro | Advanced reasoning model |Environment Variables
-
PERPLEXITY_API_KEY - Your Perplexity API key (alternative to config file)The config file takes precedence over the environment variable.
Configuration File
The configuration is stored at
~/.config/pplx-cli/config.json`.MIT
- Perplexity API Documentation
- GitHub Repository
- Report Issues