CtrlK
BlogDocsLog inGet started
Tessl Logo

perplexity-cli-commands

Full command syntax, all flags, and worked examples for perplexity-cli search, ask, and chat commands.

62

Quality

74%

Does it follow best practices?

Run evals on this skill

Adds up to 20 points to the overall score

View guide

SecuritybySnyk

Low

Low-risk findings worth noting

Fix and improve this skill with Tessl

tessl review fix ./.claude/skills/web-search-with-perplexity/commands/SKILL.md
SKILL.md
Quality
Evals
Security

perplexity-cli — Command Reference

search — Web Search (no AI answer)

Returns titles, URLs, and snippets. Does not generate an AI answer. Use ask or chat when you need an AI-synthesized response.

OpenRouter fallback: if Perplexity errors or only OPENROUTER_API_KEY is set, search is emulated via perplexity/sonar-pro chat. snippet and date are always null on this path. See root SKILL.md for backend resolution.

Syntax

perplexity-cli [GLOBAL] search [QUERY] [OPTIONS]
perplexity-cli [GLOBAL] search --json 'JSON_STRING'
echo 'JSON_STRING' | perplexity-cli [GLOBAL] search

Arguments

ArgRequiredDescription
QUERYNo*The search query string. *Optional when using --json or stdin.

Options

FlagShortTypeDescription
--mode-mweb|academic|secSource filter. web = general web (default). academic = scholarly/peer-reviewed. sec = SEC filings and financial documents.
--recency-rhour|day|week|month|yearOnly return results published within this window.
--domains-dcomma-separated stringRestrict results to these domains. Example: github.com,stackoverflow.com
--language-lcomma-separated ISO 639-1Language filter. Example: en,fr
--max-results-nintegerMaximum number of results to return.
--countryISO 3166-1 alpha-2Geo-localize results. Example: US
--afterMM/DD/YYYYOnly return results published after this date.
--beforeMM/DD/YYYYOnly return results published before this date.
--json-jJSON stringAll parameters as JSON. CLI flags override JSON values.

Examples

# Basic query
perplexity-cli search "Python 3.13 new features"

# Academic mode, filter by recency
perplexity-cli search "climate change mitigation" --mode academic --recency year

# Financial filings
perplexity-cli search "Apple Q3 2025 earnings" --mode sec

# Domain filter + result cap
perplexity-cli search "async rust" --domains "doc.rust-lang.org,blog.rust-lang.org" --max-results 5

# Date range
perplexity-cli search "AI regulation" --after "01/01/2025" --before "04/01/2025"

# Human-readable output (global flag first!)
perplexity-cli --text search "best Python ORMs"

# JSON flag (good for multi-field queries from agents)
perplexity-cli search --json '{"query": "AI governance", "search_mode": "academic", "max_results": 10}'

# Stdin pipe (great for agents building queries programmatically)
echo '{"query": "Rust vs Go performance", "search_domain_filter": ["benchmarksgame.alioth.debian.org"]}' \
  | perplexity-cli search

# Extract just URLs
perplexity-cli search "Python packaging tools" | jq '.results[].url'

ask — AI Answer (non-streaming)

Sends a question to Perplexity's Chat Completions API. Waits for the full response, then outputs JSON with the answer, citations, and token usage.

Use chat when you want tokens to stream progressively.

Syntax

perplexity-cli [GLOBAL] ask [QUESTION] [OPTIONS]
perplexity-cli [GLOBAL] ask --json 'JSON_STRING'
echo 'JSON_STRING' | perplexity-cli [GLOBAL] ask

Arguments

ArgRequiredDescription
QUESTIONNo*The question to ask. *Optional when using --json or stdin.

Options

FlagShortTypeDefaultDescription
--model-mstringsonarModel to use. See models/SKILL.md.
--system-sstringSystem prompt. Sets persona/tone/constraints.
--modeweb|academic|secSearch mode for grounding sources.
--recency-rhour|day|week|month|yearFilter grounding sources by recency.
--domains-dcomma-separatedRestrict grounding to these domains.
--temperature-t0.02.0Response randomness. 0.00.3 = focused. 0.7+ = creative.
--max-tokensintegerCap on response length in tokens.
--reasoningminimal|low|medium|highReasoning effort. Higher = better for complex questions but slower.
--relatedflagoffInclude related follow-up questions in output.
--imagesflagoffInclude image URLs in output when available.
--json-jJSON stringAll parameters as JSON. CLI flags override JSON values.

Examples

# Basic
perplexity-cli ask "What is quantum computing?"

# With model upgrade
perplexity-cli ask "Analyze the CAP theorem tradeoffs" --model sonar-pro

# Max reasoning for a hard question
perplexity-cli ask "Compare Tokio vs async-std for production Rust" \
  --model sonar-reasoning --reasoning high

# Recent sources only
perplexity-cli --text ask "What changed in Python 3.13?" --recency month

# System prompt to control output format
perplexity-cli ask "Top 5 Python ORMs" \
  --system "Respond as a JSON array with keys: name, stars, best_for"

# Restrict grounding to trusted domains
perplexity-cli ask "Rust lifetimes explained" \
  --domains "doc.rust-lang.org,blog.rust-lang.org"

# Get related questions for follow-up
perplexity-cli ask "How does TLS work?" --related | jq '{answer: .content, follow_ups: .related_questions}'

# Full JSON input (agent-preferred for complex structured requests)
perplexity-cli ask --json '{
  "question": "What are the security implications of JWT?",
  "model": "sonar-pro",
  "search_recency_filter": "year",
  "reasoning_effort": "high",
  "system_prompt": "Be precise. Cite CVEs where relevant."
}'

# Extract plain answer text
perplexity-cli ask "What is TLS?" | jq -r '.content'

# Get citations as newline-separated list
perplexity-cli ask "Rust ownership rules" | jq -r '.citations[]'

chat — Streaming AI Answer

Like ask but streams tokens as they arrive.

Streaming behaviour by output format:

  • --text mode: tokens stream to stdout in real time. Citations printed to stderr after completion.
  • JSON mode (default): tokens stream to stderr as progress. Final complete JSON goes to stdout.

This means in agent/script usage, you can ignore stderr and capture clean JSON from stdout.

Syntax

perplexity-cli [GLOBAL] chat [QUESTION] [OPTIONS]

Options

Same as ask minus --related and --images, plus:

FlagDescription
--no-streamDisable streaming; behave exactly like ask.

Examples

# Interactive streaming (human-readable, watch it type)
perplexity-cli --text chat "Explain the Rust borrow checker"

# Streaming with better model
perplexity-cli --text chat "Walk me through async Rust" --model sonar-pro

# Agent use: discard streaming progress, capture final JSON
perplexity-cli chat "Explain TLS handshake" 2>/dev/null | jq -r '.content'

# Same as ask (useful to switch without changing the command name)
perplexity-cli chat "What is WebAssembly?" --no-stream

# Pipe final structured output through jq
perplexity-cli chat "Latest Kubernetes release notes" --recency month \
  2>/dev/null | jq '{answer: .content, sources: .citations}'

Global Flags Reference

These always go before the subcommand:

FlagTypeDescription
--textflagPlain text output instead of JSON
--prettyflagIndented JSON output
--api-keystringPerplexity API key (overrides PERPLEXITY_API_KEY env var)
# Correct placement — all before the subcommand
perplexity-cli --text ask "question"
perplexity-cli --pretty search "query"
perplexity-cli --api-key pplx-xxx --text ask "question"

Backend / Auth

Best practice: configure once in ~/.config/perplexity-cli/perplexity-cli.json (perplexity_api_key, openrouter_api_key, plus default model/output/search params), then run bare commands. See root SKILL.md.

Each setting resolves with precedence CLI flag > env var > config file > built-in default:

SourceKeys it provides
--api-key flagPerplexity key only (highest priority)
PERPLEXITY_API_KEY envPrimary backend (native Perplexity API)
OPENROUTER_API_KEY envFallback backend (routes to perplexity/sonar* on OpenRouter)
config fileperplexity_api_key / openrouter_api_key (lowest priority)

Both keys present (any source) → Perplexity primary, OpenRouter fallback on 401/402/403/408/429/5xx + network errors. Only OpenRouter → OpenRouter standalone. Neither → exit 2.

Repository
slurpyb/perplexity-cli
Last updated
First committed

Is this your skill?

If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.