Metadata-Version: 2.4
Name: llm-perplexity-agent
Version: 0.3.0
Summary: Perplexity's Agent API as a model for Simon Willison's llm CLI.
Author-email: Constantin Gonzalez <constantin@glez.de>
License: BSD 3-Clause License
        
        Copyright (c) 2026, Constantin Gonzalez
        
        Redistribution and use in source and binary forms, with or without
        modification, are permitted provided that the following conditions are met:
        
        1. Redistributions of source code must retain the above copyright notice, this
           list of conditions and the following disclaimer.
        
        2. Redistributions in binary form must reproduce the above copyright notice,
           this list of conditions and the following disclaimer in the documentation
           and/or other materials provided with the distribution.
        
        3. Neither the name of the copyright holder nor the names of its
           contributors may be used to endorse or promote products derived from
           this software without specific prior written permission.
        
        THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
        AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
        DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
        FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
        SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
        CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
        OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
        OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
        
Project-URL: Homepage, https://github.com/zalez/perplexity-agent-mcp
Project-URL: Issues, https://github.com/zalez/perplexity-agent-mcp/issues
Project-URL: Changelog, https://github.com/zalez/perplexity-agent-mcp/blob/main/CHANGELOG.md
Keywords: llm,perplexity,research,agent,cli
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: BSD License
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Utilities
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: llm>=0.27
Requires-Dist: perplexity-agent-mcp==0.3.0
Dynamic: license-file

# llm-perplexity-agent

Perplexity's [Agent API](https://docs.perplexity.ai/docs/agent-api/quickstart) — multi-step web research with citations — as a model for Simon Willison's [`llm`](https://llm.datasette.io) CLI.

```bash
llm install llm-perplexity-agent
llm keys set perplexity        # skip if you already set this for llm-perplexity
llm -m perplexity-agent 'What changed in MCP 2026-07-28?'
```

## Why

`llm-perplexity` wraps Perplexity's older Sonar chat models. This wraps the **Agent API** (`POST /v1/agent`) — the multi-step endpoint that runs its own searches, fetches pages, and synthesizes one cited answer. Different product, different endpoint.

## Options

```bash
llm -m perplexity-agent -o preset xhigh -o recency week 'Latest on X'
llm -m perplexity-agent -o domains 'nasa.gov,-reddit.com' 'Artemis status'
llm -m perplexity-agent -o timeout 600 'Something genuinely deep'
```

| Option | Default | Notes |
|---|---|---|
| `preset` | `medium` | `fast`, `low`, `medium`, `high`, `xhigh`, `wide-research`. Passed through unvalidated — Perplexity declares no enum, so a new preset works the day it ships. |
| `recency` | — | `hour`, `day`, `week`, `month`, `year` |
| `domains` | — | Comma-separated; prefix with `-` to exclude. Max 20. |
| `timeout` | `300` | Seconds before giving up. |
| `spotlight` | `false` | Wrap the answer as untrusted web content — see below. |

Poll progress goes to **stderr**, so the answer pipes cleanly.

## A note on prompt injection

Retrieved web content is untrusted, and this tool feeds it to a language model. The companion MCP server always wraps its answers in a delimiter marking them as untrusted data, because there the answer goes straight into a model that is holding tools — injected instructions could cause *actions*.

Here the answer goes to your terminal, and `llm` runs no tool loop by default, so that wrapping is **off** by default. Turn it on when the output is headed somewhere that matters:

```bash
llm -m perplexity-agent -o spotlight true 'Research X' | llm -m gpt-5 'Summarise'
```

It is a mitigation, not a fix. See [SECURITY.md](https://github.com/zalez/perplexity-agent-mcp/blob/main/SECURITY.md).

## Sibling

This is one of two adapters over the same client. The other is [`perplexity-agent-mcp`](https://github.com/zalez/perplexity-agent-mcp), an MCP server for Claude Desktop, Claude Code, VS Code and other MCP clients. Both are released together at the same version from [one repository](https://github.com/zalez/perplexity-agent-mcp).

BSD-3-Clause. Copyright (c) 2026, Constantin Gonzalez.
