I maintain a Go library for the Perplexity API (perplexity-go). Once it existed, it was almost a sin not to wrap it in a CLI. So pplx is what I reach for when I want a cited, web-aware answer from the shell — and now also a Model Context Protocol server I plug into Claude Code.

Why a CLI for Perplexity

Perplexity’s edge over a typical LLM is real-time web search with citations. That’s wonderful in a browser, less wonderful when you want to script it. pplx exposes the API surface as query, chat, and mcp-stdio subcommands, with shell completion, configuration profiles, and all the search tuning knobs the API exposes.

Installation

# Homebrew
brew tap sgaunet/homebrew-tools
brew install sgaunet/tools/pplx

# Or grab a binary from
# https://github.com/sgaunet/pplx/releases

Set your API key once:

export PERPLEXITY_API_KEY="your-key"

A first query

The smallest useful thing:

pplx query -p "What is the capital of France?"

Add a system prompt to set the AI’s tone:

pplx query -p "Explain quantum computing" -s "You are a physics professor"

Search tuning

This is where pplx earns its keep. Filter by time, by domain, switch to academic mode, get images or related questions back — all from flags:

# Last week's news only
pplx query -p "stock market updates" -r week

# Restrict sources
pplx query -p "climate change research" -d nature.com,science.org

# Academic mode for scholarly sources
pplx query -p "transformer architecture" -a academic

# Include images and related follow-ups
pplx query -p "Famous landmarks in Paris" -i -q

Combined, you get something close to a research assistant in one line:

pplx query -p "Latest developments in quantum computing" \
  -d arxiv.org,nature.com \
  -r month \
  -q \
  -T 1000

Interactive chat

For multi-turn conversations:

pplx chat

Same API key, same flags for model and temperature, but with conversation state.

Profiles: stop typing the same flags

If you find yourself repeating -d arxiv.org,nature.com -a academic -r month every time, switch to a config profile. The interactive wizard sets one up:

pplx config init --interactive

Or pick a template:

pplx config init --template research   # academic-tuned defaults
pplx config init --template creative   # higher temperature, streaming
pplx config init --template news       # last-day recency, news domains

A profile in YAML looks like this:

profiles:
  research:
    defaults:
      model: llama-3.1-sonar-large-128k-online
      temperature: 0.1
      max_tokens: 2000
    search:
      mode: academic
      context_size: high
      recency: month
      domains:
        - arxiv.org
        - nature.com
        - science.org
    output:
      return_related: true

Switch and use:

pplx config profile switch research
pplx query -p "Latest breakthroughs in quantum computing"

CLI flags always override the profile, so one-off queries don’t fight you.

Shell completions

Tab completion isn’t decoration — for a tool with this many flags, it’s the difference between using it daily and forgetting it exists. One command sets it up:

pplx completion install

It auto-detects bash, zsh, fish, or PowerShell, and the completions are dynamic: model names, search modes, recency values, even common search domains all complete by tab.

MCP server for Claude Code

This is the feature I keep getting the most use out of lately. pplx mcp-stdio exposes Perplexity as an MCP tool that Claude Code can call directly. Two lines to wire it up:

claude mcp add perplexity-ai -s user -- pplx mcp-stdio
export PPLX_API_KEY="your-key"

Now Claude Code can perform live web research mid-conversation, with real citations, instead of relying on stale training data. The MCP server exposes the full set of query parameters — search domains, recency, academic mode, structured JSON output, even date-range filtering — so the agent has all the same knobs the CLI does.

Where to go next

It’s MIT-licensed and open source. If you’ve ever wanted Perplexity in your shell, in a script, or wired into Claude Code, this is the path of least resistance.