Skip to main content
The pplx CLI returns structured JSON from the Perplexity Search API, making it useful for shell pipelines, interactive terminal work, and coding agents that need current web results or query-relevant page snippets.

Install

Open the agent in your project and send it this:
Without an agent, run the installer yourself:

Authenticate

Every command needs a Perplexity API key. Choose one authentication method:

Search the web

-n defaults to 10. Run pplx search web --help for the full flag list and a summary of the input and output shapes.

Filter results

These flags scope a search. They are the Search API filters, so their behavior and limits are identical — see domain filter and date and time filters for the details.
--recency-filter cannot be combined with --published-after-date or --published-before-date. That request fails with BAD_REQUEST.

Ask the same question several ways

Extra positional queries are rephrasings of one question, not separate searches. The CLI still returns a single ranked result set, but wording the question more than one way surfaces pages that only match the phrasing you did not think of first:

Save full results

Save the complete result while keeping stdout small:
The full response is written under out/web/, and stdout includes its path in saved_to. --stdout-preview only truncates stdout when you also set --output-dir or PPLX_OUTPUT_DIR. Cut strings end in ...<truncated> and the response gains a top-level "truncated": true.

Search errors

A search either succeeds or fails outright: on failure nothing reaches stdout and the JSON error object goes to stderr. The search-specific code is BAD_REQUEST, which the service returns when the filters contradict each other, as with --recency-filter alongside a publication-date bound. Everything else you can hit here is a common error.

Generate query-relevant snippets

Extract the passages of a page that are relevant to a query, instead of retrieving the whole page:
text keeps only the query-relevant passages of the page; elided regions in between are marked with the character.
content snippets requires CLI v0.2.3 or later. On an older binary, run pplx update first.
pplx content fetch is deprecated and will stop working; use content snippets.

Cover several pages in one call

Extra positional URLs are additional pages, not rephrasings: unlike pplx search web, where extra positional arguments reword one question, each URL here is snipped independently against the same query. One call takes up to 50 URLs:

Budget the tokens

Two flags cap how much text comes back. Budgets are approximate: a snippet can run a few tokens over its cap, as the tokens_count values above show.

Snippet errors

pplx content snippets reports failure per URL, not per command. A page that cannot be snipped does not fail the run: the command still exits 0, and that URL’s result carries an error message with no text.
Check every result for error before trusting its text, because a successful invocation does not mean every page produced a snippet.

Keep large responses out of stdout

Snippets across many URLs still add up. --output-dir writes the full response under <dir>/snippets/, and --stdout-preview truncates the long strings on stdout:
Stdout carries the saved path in saved_to plus "truncated": true, so the terminal stays readable while the complete text sits on disk.

Handle errors

These are the failures common to every pplx command. A failed command writes one JSON error object to stderr:
Branch on error.code.
Run pplx <command> --help before assuming that a flag exists; CLI output is already JSON, so no --json flag is needed.

Next steps

See the perplexity-cli repository for release notes, manual installation, and uninstall instructions.