Skip to main content
Glama
MCP Perplexity Pro

MCP Perplexity Pro

by cfdude

MCP Perplexity Pro

An MCP server for the Perplexity API, written in Python (FastMCP, SQLAlchemy, SQLite). It serves MCP over stdio or Streamable HTTP and keeps its own data in a local SQLite database.

Status: 2.0.0

Version 2.0.0 replaces the TypeScript 1.x server. The reason is that Perplexity retired the Sonar endpoints the 1.x server called: both POST /chat/completions and GET /async/chat/completions now return 403 chat_completions_not_available ("Sonar is now the Agent API"), so 1.x could not answer a single query. There was no working behavior to port, so the TypeScript code is deleted (git history keeps it) and the server was rebuilt in Python on the Agent API (POST /v1/agent).

Eleven tools exist today:

Tool

What it does

Spends money

perplexity_ask

One web-grounded question, answered synchronously with its sources. The routing mode picks the model (default perplexity/sonar); or a depth (fast, low, medium), a tier or a model

yes

perplexity_chat

A multi-turn conversation kept in the local database: send, list, read, delete

send only

perplexity_research

Starts a deep research run in the background and returns a job id at once. Depth medium (default), high or xhigh

yes, when a call observes the run finish

perplexity_jobs

Manages research runs: list, status, result, cancel

no new spend; it records the finished run's

perplexity_search

Ranked web search results as data (title, url, snippet, dates), with no model answer. Type fast (default, $0.001 per request) or web ($0.005 per request)

yes

perplexity_decide

Typed questions about a text, answered with calibrated probabilities: a yes probability, the most probable option, or a position on an ordered rubric. One request holds up to 32 questions. About $0.02 per million input tokens ($0.01 for the flash model), output free

yes

perplexity_embed

Indexes saved chats, completed research reports or texts you pass as vectors in the local database, and searches them by meaning: index, search, status, delete. index sends the text to Perplexity. $0.004 (pplx-embed-v1-0.6b) or $0.03 (pplx-embed-v1-4b) per million tokens

index and search

perplexity_models

Lists the models your key can use, with live prices and accepted effort levels from the model matrix, plus the documented Agent API presets

no

perplexity_projects

Lists projects, or deletes one and its stored records (spend history is kept)

no

perplexity_usage

Reports what recorded upstream calls cost, grouped by tool, API, model, project or day. Read-only

no

perplexity_help

The server's own help: an index that picks the right tool, one tool's page, or a topic. Free, no API call

no

The four Agent tools, perplexity_search, perplexity_decide and perplexity_embed record their usage. Every costed upstream call stores one usage event (perplexity_usage reports them), and a background research run is recorded once, by the first perplexity_jobs call that sees it finish.

These tools can spend money, and there is no cost ceiling. A nameless ask or chat uses the routing default, perplexity/sonar, which cost more than the fast depth in the one pair measured (see "Choosing how models are picked"); research defaults to medium and search to its cheaper type (fast). high and xhigh exist only behind perplexity_research because a single run can cost dollars (see "Cost by depth").

The old tool names (ask_perplexity, chat_perplexity and the rest) are gone and are not coming back under those names. No data is imported from 1.x.

Related MCP server: perplexity-user-mcp

Install and run

Requires Python 3.12 or newer and uv.

git clone <this repository> && cd mcp-perplexity-pro
uv sync
export PERPLEXITY_API_KEY=<your-perplexity-api-key>

From PyPI (2.0.0 and later), with nothing cloned:

export PERPLEXITY_API_KEY=<your-perplexity-api-key>

# run the MCP server (stdio is the default transport)
uvx mcp-perplexity-pro

# run the command line
uvx --from mcp-perplexity-pro perplexity-pro ask "What is new in Python?"

# or install both commands once
uv tool install mcp-perplexity-pro        # then: mcp-perplexity-pro, perplexity-pro
pipx install mcp-perplexity-pro

How a release is made: docs/releasing.md.

Start commands from a checkout:

# stdio (the default transport): the MCP client launches this process
uv run mcp-perplexity-pro --transport stdio

# Streamable HTTP on http://127.0.0.1:8102/mcp (health: http://127.0.0.1:8102/health)
uv run mcp-perplexity-pro --transport http

# without a checkout-managed environment
uvx --from . mcp-perplexity-pro --transport http

# check the install
uv run mcp-perplexity-pro --version
uv run mcp-perplexity-pro --help

# the command line front end (see "Command line")
uv run perplexity-pro --help

In stdio mode stdout carries only MCP messages; every log line goes to stderr. A missing or invalid setting prints a message naming the variable and exits with status 1 before anything is created on disk or any port is opened.

Run under pm2

The supervised setup is one pm2 app that runs the HTTP transport on port 8102. Copy the example configuration, set your key in the copy, and start it. The copy is gitignored so the key never enters the repository:

cp ecosystem.example.cjs ecosystem.config.cjs   # then replace REPLACE_ME with your key
pm2 start ecosystem.config.cjs
curl -s http://127.0.0.1:8102/health            # {"status":"ok","version":"2.0.0"}

kill_timeout is 15000 ms because on SIGTERM or SIGINT the server finishes in-flight calls for up to 10 seconds, closes its HTTP client and database connections, and exits 0; pm2 must wait longer than that before it sends SIGKILL. pm2 restart mcp-perplexity-pro brings the server back on the same port.

Command line

The same tools are a command line, perplexity-pro, for a person or a script that would rather not run an MCP client. mcp-perplexity-pro is unchanged (it is still what pm2 and every MCP client configuration start); perplexity-pro serve runs the same server.

uv run perplexity-pro ask "What is new in Python?" --depth fast
uv run perplexity-pro search "rust borrow checker" "zig comptime" --domains=-reddit.com
uv run perplexity-pro chat send --title notes --message "Remember: teal."
uv run perplexity-pro ask "What is this?" --model openai/gpt-6-luna --attachments shot.png
uv run perplexity-pro models --json | jq '.routing'
uv run perplexity-pro usage --group-by tool
uv run perplexity-pro help            # the index; `help ask`, `help costs`, `help topic projects`
uv run perplexity-pro serve --transport http

Every command calls the registered tool in-process, so routing, validation, project rules, usage recording and error categories are exactly the MCP tool's, and a costed command records one usage event in the same database. The subcommands (ask, chat, research, jobs, search, decide, embed, models, projects, usage, help, serve) and their flags are generated from the tool schemas, so a new tool parameter appears as a flag without an edit.

Rule

Form

Positionals

a required action, then a required query (ask "q", chat send, jobs status); everything else is a --flag with dashes (--max-results 3)

Booleans

--search and --no-search; unset means the tool's default

Lists

repeat the flag: --domains python.org --domains docs.python.org; a search takes several queries as positionals

Objects and arrays

JSON: --json-schema '{...}', --json-schema @schema.json or --json-schema - (standard input, once); an untyped value such as decide's --state is JSON when it is an object or array and text otherwise

Anything else

--args-json '{"query": "q", "depth": "low"}' (JSON, @file or -), merged first; flags win; a JSON null means not given

Attachments

--attachments VALUE, repeated, on ask and chat only (see "Attachments"); a relative path is made absolute against the command's working directory and ~/ is expanded before the tool sees it, a https:// URL or data: value is left as written, and a <media type>:: prefix is kept with the path after it made absolute

A value that starts with a dash

--domains=-reddit.com, and -- before a query that starts with one

Output is the tool's readable text on standard output, or the structured result with --json. Exit status: 0 on success, 1 for a tool error (standard error shows [category] message, ending with Run perplexity-pro help <command> for its arguments and examples.) or a setup failure (missing key, invalid setting), 2 for a usage error (a wrong type, an unknown or abbreviated flag, a value outside a schema enum, a missing required value) refused before anything is set up or sent, 130 for Ctrl-C. A described value the schema does not list as an enum (a depth, a tier) reaches the tool, which refuses it as a tool error. Logs are warnings and errors only unless PERPLEXITY_LOG_LEVEL is set, and stay on standard error. --help, <command> --help, help and --version need no key, no network and no data directory, and survive an invalid environment (the routing line then shows the defaults, with one warning). help projects is the tool page, help topic projects the topic. Live record: openspec/changes/archive/2026-10-13-py-cli/acceptance/ (two billed asks, $0.00723, reconciled to the nano-USD).

Settings

All settings are environment variables with the prefix PERPLEXITY_. They are validated at startup; an invalid value aborts startup with a message naming the variable and the offending value. No .env file is read.

Variable

Default

Meaning

PERPLEXITY_API_KEY

none, required

The Perplexity API key. Never logged, returned or stored on disk

PERPLEXITY_HOST

127.0.0.1

HTTP bind host. A non-loopback value logs a startup warning (see Security)

PERPLEXITY_PORT

8102

HTTP port, 1 to 65535

PERPLEXITY_BASE_URL

https://api.perplexity.ai

Perplexity API base URL (http or https)

PERPLEXITY_DATA_DIR

~/.perplexity-pro/

Where the SQLite database, migration lock and backups live

PERPLEXITY_LOG_LEVEL

INFO

DEBUG, INFO, WARNING, ERROR or CRITICAL (case-insensitive)

PERPLEXITY_CONNECT_TIMEOUT

10

Seconds to establish a connection to the API

PERPLEXITY_READ_TIMEOUT

60

Seconds to wait for the API's response

PERPLEXITY_AGENT_READ_TIMEOUT

120

Seconds to wait for a synchronous Agent run (perplexity_ask, perplexity_chat send). A background submit and every other request use PERPLEXITY_READ_TIMEOUT. Must be greater than 0

PERPLEXITY_MAX_ATTEMPTS

3

Attempts per API request (HTTP 429 is retried honoring Retry-After; GET requests are also retried on 5xx, timeouts and connection failures; a create POST is retried only after a connect failure)

PERPLEXITY_MAX_RETRY_WAIT

30

Longest wait in seconds between attempts; a Retry-After longer than this is not waited out

PERPLEXITY_CATALOG_TTL

3600

Seconds the model list is cached

PERPLEXITY_CATALOG_MAX_STALE

86400

Oldest cached model list, in seconds, that may be returned when the live request fails

PERPLEXITY_DB_BUSY_TIMEOUT

5

Seconds a write waits for the database lock before failing with storage_busy

PERPLEXITY_ROUTING

standard

standard, custom or dynamic, case-insensitive. See "Choosing how models are picked"

PERPLEXITY_MODEL

perplexity/sonar

standard mode: the model a call that names nothing uses; dynamic mode: the standard tier's model

PERPLEXITY_CLASSIFIER

rules

dynamic mode only: rules (fixed offline rules) or decisions (the Decisions API picks the tier, the rules back it up). Ignored with a warning in other modes

PERPLEXITY_MATRIX_REFRESH

86400

Seconds between refreshes of the model matrix (see "Model matrix"); 0 refreshes only at start, otherwise 300 to 604800

PERPLEXITY_MATRIX_PROBE

new

new probes models whose efforts or input kinds neither the matrix file nor the packaged baseline knows, and asks a refused input kind again once its answer is 24 hours old (at most 10 models and about $0.25 of reported cost per refresh, effort and input probes together; one document probe of the dearest model cost up to $0.0207 in the 2026-10-30 sweep); off never probes, case-insensitive. With off the local attachment gate still reads a refusal older than 24 hours as unknown, so a stale refusal does not block a model for ever

PERPLEXITY_ATTACH_ROOTS

none

Colon-separated absolute directories. When set, a local file may be attached only from inside one of them, checked on the opened file's real path; a path outside them, whether or not it exists, gets one uniform refusal that names no path. Over HTTP local paths are refused unless this is set (stdio allows any readable path). A built-in deny list applies whatever it says: ~/.ssh, ~/.aws, ~/.gnupg, ~/.config, ~/.claude, ~/.kube, ~/.docker, the data directory, and the base names ecosystem*.cjs, .env, .env.*, .envrc, *.env, *.env.*, .netrc, .npmrc and .pypirc. See "Attachments"

PERPLEXITY_TIER_LIGHT, PERPLEXITY_TIER_STANDARD, PERPLEXITY_TIER_COMPLEX

none

custom mode: the three tier models, all required there. dynamic mode: optional, each replaces that tier's default

Variables starting with FASTMCP_ belong to FastMCP and are not used for this server's own settings.

Choosing how models are picked

perplexity_ask and perplexity_chat (send) need a model. The routing mode says which one runs when a call names nothing; it is a default, never a restriction. A call can always name its own model (used exactly as given, in every mode, even if it is not in the catalog), a depth (a Perplexity preset) or, in custom and dynamic mode, a tier. Name only one of the three per call; two of them fail with an invalid_request that says so. perplexity_research is not affected: its depths are presets with their own runtime.

There are three modes, set with PERPLEXITY_ROUTING:

Mode

What it does

Set up

standard (default)

Every call that names nothing uses one model, perplexity/sonar unless you change it. A base Sonar model line is the default because the line always exists, while a preset's model behind fast moves (it was openai/gpt-6-luna on 2026-10-06)

Nothing. To use another model: PERPLEXITY_MODEL=anthropic/claude-sonnet-5-5

custom

Three tiers you choose: light (light or agent-execution work), standard (everyday work, what a call with no selector uses) and complex (work that needs deeper reasoning). The agent picks one with tier

PERPLEXITY_ROUTING=custom plus all three PERPLEXITY_TIER_LIGHT, PERPLEXITY_TIER_STANDARD and PERPLEXITY_TIER_COMPLEX, each a model id. A missing tier stops startup and names it

dynamic

The server picks a tier from the prompt when a call names nothing, with fixed offline rules by default (no extra request, no cost; PERPLEXITY_CLASSIFIER=decisions asks the Decisions API instead, see "The Decisions classifier"): light runs the fast preset, standard runs perplexity/sonar (or PERPLEXITY_MODEL), complex runs the medium preset. Never high or xhigh

PERPLEXITY_ROUTING=dynamic. Nothing else is required; PERPLEXITY_TIER_LIGHT, PERPLEXITY_TIER_STANDARD and PERPLEXITY_TIER_COMPLEX replace a tier's default with a model id

Example custom setup (in the pm2 env block or the shell):

PERPLEXITY_ROUTING=custom
PERPLEXITY_TIER_LIGHT=openai/gpt-6-luna
PERPLEXITY_TIER_STANDARD=perplexity/sonar
PERPLEXITY_TIER_COMPLEX=anthropic/claude-sonnet-5-5

A model id is 1 to 200 characters from letters, digits and . _ : / @ + -. A variable the active mode does not use (a tier in standard mode, PERPLEXITY_MODEL in custom mode) is ignored with one startup warning. To go back, unset the variables: the defaults are standard and perplexity/sonar. auto is not a model: the API refuses it, so "auto" has to be something this server implements, which is what dynamic is for.

Dynamic mode

A call that names no depth, tier or model is classified from its text and routed to a tier. The rules, in the order the result lists them, are: complex when the text uses words from two different analysis groups (compare, evaluate, trade-offs, pros and cons, step by step, root cause, architecture, in depth, analyze, critique, derive, prove, design, implications), is 1200 characters or longer, or holds three or more questions or numbered items; light when it is at most 120 characters, holds at most one question and opens like a lookup (what is or are, who is or was, when is or did, where is, how many, how much, define, latest, current, price of); standard otherwise. The result's routing says what happened: tier, selected_by classifier, classifier rules (or decisions, see below) and a short reason that names signals, a tier, a probability or a failure category, never your words.

  • Any explicit depth, tier or model skips the rules and is used as given. tier is valid in custom and dynamic mode.

  • A chat follow-up never runs below the tier its chat last used (and in 2025? after a complex turn stays complex); the reason says held at complex.

  • With search false no preset can run, so the standard tier's model answers (reason search off); naming a preset tier together with search false is refused.

  • Cost and time: a complex call runs medium, $0.016 to $0.025 as a research run in the figures below and $0.0376 in the one live dynamic run (openspec/changes/routing-rules-v1/acceptance/), which also took 108 seconds against the 120 second limit for a synchronous run (PERPLEXITY_AGENT_READ_TIMEOUT), so read dynamic mode as a quality policy. No savings figure is claimed: the rules are a first version (a 44-prompt labeled set pins them) and measuring them is later work.

  • To go back, unset PERPLEXITY_ROUTING.

The Decisions classifier

PERPLEXITY_CLASSIFIER=decisions replaces the rules with one request to Perplexity's Decisions API per nameless call: the first 4000 characters of your prompt go to /v1/decisions as the state of a single choice question (light, standard or complex), and the answer picks the tier. The same provider receives the same text next as the ask itself.

  • Bounded and never fatal. One attempt, at most 3 seconds. A timeout, a rate limit, any error or an answer it cannot read falls back to the rules and the reason says why (for example decisions failed (rate_limited), rules: short lookup). A weak answer (the chosen option under 50% probability) is raised to the rules' tier when that is higher.

  • Recorded. Each request is its own usage event (API decisions, the calling tool's name, your project), billed on input tokens at 20 nano-USD each; the four requests of the acceptance run cost 12,660 nano-USD in total (openspec/changes/routing-decisions-classifier/acceptance/).

  • When it runs. Only for a call that names no depth, tier or model, whose search is not false, after the call validated; never for a chat follow-up already at complex. An invalid call makes no request. The result's classifier says decisions or rules (when the rules supplied the tier).

  • What it did in testing, as observations. The median classification took 0.26 s (0.68 s slowest of 44). The decider leans toward complex on ordinary questions: it sent 4 of the 18 prompts we labeled standard there and, on one real ordinary question, ran medium for $0.018 and 55.7 s where the rules route it to standard ($0.005, about 10 s). The labels were written to pin the rules, so agreement with them is not a measure of quality. That is why rules is the default; tuning the decider's criteria and threshold is later work (routing-eval-tuning).

What the default costs. perplexity/sonar with web search cost $0.00336 for one question, $0.00371 for a json_schema question (acceptance, openspec/changes/archive/2026-10-13-routing-modes-config/acceptance/) and $0.00379 in the first probe (design.md, 2026-10-13); the fast preset cost $0.00124 for the same question as the first acceptance call (the acceptance files keep results, not query text). That is one question each (about 2.7 times fast in that pair), so read it as a rough guide: the web search tool's pages count as input tokens, which is where most of a Sonar call's cost sits. To keep the old cheap default, pass depth: "fast" on a call or set PERPLEXITY_MODEL to another id. perplexity_usage shows what you really spent.

How the calling agent learns the setup. An agent sees only tools, so the server tells it four ways and any one is enough: the MCP instructions text (some clients show it, some drop it), one sentence in the perplexity_ask and perplexity_chat descriptions, the routing object in every ask and chat result (mode, tier, model and selected_by: default, tier, depth or model, which also shows when an agent overrode the default), and the routing section of perplexity_models, which marks each configured id known when the live list has it. A model the list does not have is still sent as configured, because the list can lag a new model and the API reports a typo on the first call.

Model matrix

The server keeps a small file, model_matrix.json, in the data directory: for every model in Perplexity's live list its provider, prices, whether it is still listed (available or removed) and its efforts, which reasoning.effort levels (minimal, low, medium, high, xhigh, max) the Agent API accepts for it, and its inputs, which attachment kinds (image, document) it accepts, refuses or has not been asked about. Nothing in it is typed by hand and nothing routes by it yet (the attachment gate reads the inputs; see "Attachments"); it is the fact base for model routing.

  • Never empty. A baseline of 55 models (the 54 of 2026-10-17 plus openai/gpt-6.1-terra, which has both kinds unknown) ships inside the package, so the matrix is the baseline on a first start, after a deleted file, and after a corrupt one (a file that is not a matrix is renamed model_matrix.json.corrupt-<time> and never deleted; a file written by a newer version is left alone).

  • Refreshed by the server. A serving process (mcp-perplexity-pro, perplexity-pro serve) starts a background task that fetches the live list at start and then every PERPLEXITY_MATRIX_REFRESH seconds, adds new models, updates prices and marks vanished models removed. It never delays startup and never fails it: a failure logs one warning and the matrix stays as it was. One-shot perplexity-pro commands do not refresh and never write the file. The file is written atomically under model_matrix.lock, so the pm2 server and a stdio server sharing the data directory do not lose each other's rows.

  • Probed, not guessed. Perplexity's list has only ids and prices, and its docs have no per-model capability table (they list 40 of the 54 models and are wrong about at least one: they say Kimi K3 accepts xhigh and max, the API refuses both). A model that neither the file nor the baseline knows is probed once: a control request with no effort and one request per level, each a trivial prompt with no tools, a 400 counting as a refusal only when the control completed. A refresh starts no new model's probe after 10 models or $0.25 of reported cost (checked before each model, so it can overshoot by one model's cost), and a probe makes one attempt per request, and every request is recorded as a usage event with tool model_matrix and no project (perplexity_usage shows it under (none)). On 2026-10-17 probing all 54 models at six levels cost $0.197 in total ($0.0036 on average, at most $0.036 for one model). A fresh install of a release probes nothing, because the baseline already knows every model it was built with.

  • Input kinds are probed too. The baseline records the sweep of 2026-10-30 (one image and one document request to each of the 54 models). A model with a kind still unknown is asked once per kind after a control request of the same round, and the answer is decided by HTTP status: a 200 that completed is accepted, only a 400 that names the modality refusal (the route does not support this document type or source) is a refusal, and a generic invalid request, a 429, a 5xx, a timeout or a failed run leaves the kind unknown. A refusal is asked again once it is 24 hours old, and the local gate treats a refusal that old as unknown. These requests count toward the same 10 models and $0.25 per refresh as the effort probe and are usage events with tool model_matrix. Measured per request over the 54 sweep requests of 2026-10-30 (openspec/changes/media-inputs/acceptance/sweep.json): an image request averaged $0.0005 and a document request $0.0021 (both include requests that reported no cost; priced requests only: $0.00056 and $0.0026), at worst $0.0037 (image, google/gemini-3.1-pro-preview) and $0.0207 (document, anthropic/claude-fable-5-1), and the ten dearest models with both kinds cost $0.10. An older server sharing the data directory ignores inputs and drops it from model_matrix.json on its next write; the newer server then probes again, at most about $0.02 per model. The file's version stays 1 and no guard exists for this, so run one server version per data directory when that matters.

  • Accepted is not effective. The probe learns which levels the API takes, not whether a level changes the answer: on a trivial prompt only 3 of 9 models tried showed reasoning tokens or cost moving with effort. In the 2026-10-17 probe 45 of 54 models accepted every level; gpt-5, gpt-5-mini, gpt-5-nano, gpt-5.1 and Kimi K3 refused xhigh and max, gemini-3.1-pro-preview refused minimal, and deepseek-v4-pro, grok-4.20-multi-agent and grok-4.20-reasoning refused every level.

  • See it. perplexity_models shows each model's efforts, its inputs and the matrix's origin (file or baseline), when it was fetched and how many models are still unprobed. To start over, delete model_matrix.json; to stop automatic work, set PERPLEXITY_MATRIX_REFRESH=0 and PERPLEXITY_MATRIX_PROBE=off.

Getting help

perplexity_help is the first thing a calling agent should read, and it costs nothing (no API call, no usage event, no project). It has three actions:

Action

Name

Returns

index (default)

none

A page of about 900 bytes: a list that maps a need to a tool, one line per tool saying whether it is free, billed or asynchronous, the topic names and the active routing mode

tool

a tool name

What the tool is for, whether a call is billed, asynchronous or can delete data, its cost, one example call, its arguments (read from the tool's own schema, so they cannot drift), the result keys per action and the errors with their fixes

topic

routing, costs, citations, errors, projects or attachments

One short topic page, at most 3000 bytes

{"name": "perplexity_help", "arguments": {"action": "tool", "name": "perplexity_search"}}

An unknown name fails with invalid_request listing the valid names. Every invalid_request from a tool ends with the call that shows that tool's arguments, for example ... Call perplexity_help with action "tool" and name "perplexity_ask" for its arguments and examples., and the server's MCP instructions name the help tool. The text comes from one module (help_text.py) that perplexity-pro help reuses for --help. The help costs figures are the ones in this README (a test checks that each $N.NN figure in help appears here). Live record: openspec/changes/archive/2026-10-13-agent-help/acceptance/.

Client configuration

Claude Code over HTTP (.mcp.json)

Start the server first (pm2 or uv run mcp-perplexity-pro --transport http), then:

{
  "mcpServers": {
    "perplexity": {
      "type": "http",
      "url": "http://localhost:8102/mcp"
    }
  }
}

The URL is the same as in 1.x. The equivalent command is claude mcp add --transport http perplexity http://localhost:8102/mcp.

Over stdio

The client launches the server, so the key goes in the client's env block. From PyPI:

{
  "mcpServers": {
    "perplexity": {
      "command": "uvx",
      "args": ["mcp-perplexity-pro"],
      "env": { "PERPLEXITY_API_KEY": "<your-perplexity-api-key>" }
    }
  }
}

From a checkout:

{
  "mcpServers": {
    "perplexity": {
      "command": "uv",
      "args": [
        "run", "--directory", "/absolute/path/to/mcp-perplexity-pro",
        "mcp-perplexity-pro", "--transport", "stdio"
      ],
      "env": { "PERPLEXITY_API_KEY": "<your-perplexity-api-key>" }
    }
  }
}

Tools

Four tools (perplexity_ask, perplexity_chat, perplexity_research, perplexity_jobs) call the Perplexity Agent API (POST /v1/agent) and spend money. The first three sections below are what applies to all four; each tool follows. perplexity_search calls the Search API (POST /search) and has its own cost table in its section, and so do perplexity_decide (the Decisions API, POST /v1/decisions) and perplexity_embed (the Embeddings API, POST /v1/embeddings).

Cost by depth

A depth is an Agent API preset: a bundle of model, search tools and step budget. You or the calling agent choose it (a call that names no depth, tier or model uses the routing mode's default model, see "Choosing how models are picked", which costs differently from the table) and there is no spending cap. Costs are the exact figures the API reported in its responses (usage.cost_usd, cost_source: "reported"), not estimates, except where the table says "not measured".

Agent requests send the depth as the effort field of the request body (Perplexity deprecated preset); the depth names and the depth argument are unchanged. A response returns a versioned value such as fast@2026-10-16.0 in its effort and preset fields; it is read, stored and shown as before, and the recorded preset is the name the request asked for (checked live 2026-10-29, openspec/changes/api-drift-2026-10/acceptance/README.md).

Depth

Where it is available

Observed cost per call

Evidence

Observed time

fast

perplexity_ask, perplexity_chat

$0.00118 to $0.00180

Live acceptance run, 2026-10-09: $0.00143, $0.00118, $0.00158. Probe fixtures, 2026-10-09 (the eight synchronous fast captures in tests/fixtures/; a ninth, the background poll agent_background_poll.json, cost $0.00105): $0.00119 to $0.00180

1.7 to 2.6 s (acceptance)

low

perplexity_ask, perplexity_chat

$0.00045 to $0.00386

Acceptance, 2026-10-09: $0.00156 (one call, 3.2 s). Probe fixtures, 2026-10-09: $0.00045 (agent_chat_depth_switch.json, a chained chat turn) and $0.00386 (agent_low_fetch_url.json, a call that fetched a page). Up to about $0.02 is the probe report's range; it is not backed by a saved capture

3.2 s (acceptance)

medium

perplexity_research (background); perplexity_ask and perplexity_chat accept it too

$0.01599 to $0.02524 as a research run (three of ours and one reported)

Acceptance, 2026-10-09: $0.01722 (job 1, 39 s between our submit and the call that saw it finish). Probe fixture agent_background_completed.json, 2026-10-09: $0.01599. Acceptance, 2026-10-13 (openspec/changes/py-agent-citation-fixes/acceptance/): $0.02524 and 71 s on a five-vendor pricing question. Reported by another project the same day: about $0.023 and about 90 s (not saved here). Cost follows how many fetches and searches the run makes (the fixture's tool cost was $0.01352, $0.01052 of it from three fetch_url calls), so it depends on the question. About $0.05 as an upper figure is the probe report's range; not backed by a saved capture. One synchronous medium call (a dynamic-mode complex ask, openspec/changes/routing-rules-v1/acceptance/, 2026-10-15) cost $0.0376 and took 108.1 s

39 to about 90 s as a research run (39 s and 71 s measured by us); 108.1 s for the one synchronous call, against the 120 s synchronous limit

high

perplexity_research only

not measured

Never run. "Up to about $0.4 to $0.9, and minutes" is the probe report's and the provider's own positioning: an estimate

minutes (estimate)

xhigh

perplexity_research only

not measured

Never run; more than high

minutes (estimate)

Two things the table cannot show. A cancelled run reports no usage, so its cost is unknown (the probe's cancelled run had already run six searches); the usage report counts it as an error with an unknown cost. And a run's cost grows with what it searches and fetches, so the same depth costs different amounts for different questions. Check perplexity_usage after trying a new kind of question.

Why high and xhigh exist only behind perplexity_research. They can cost dollars and last minutes, and the API sits behind Cloudflare, whose default read timeout (100 s) was not verified for this API, so a long synchronous request may be cut. A synchronous call that is cut may still be billed. perplexity_ask and perplexity_chat therefore refuse both depths with invalid_request and point to perplexity_research, where the run is background, observed later, and can be cancelled.

What store: false does and does not do

perplexity_ask and perplexity_chat send store: false. That is not a retention control. The provider's documentation says it "only hides a response from retrieval" and does not disable persistence, so the provider may still keep the query and answer. Do not rely on it to keep text away from Perplexity. The chat tool uses it because a store: false response can still be continued from (measured on 2026-10-09 for three chained turns), not for privacy.

Research runs are stored by the provider. perplexity_research sends store: true, because a background run that is not stored cannot be retrieved. The query and result stay retrievable at the provider. This server also keeps the query and the result in its own local database (perplexity.db, mode 0600), as it does chat text.

Sources are not citations

sources lists the pages the run found or fetched, de-duplicated by URL, in order of first use, each with url, title, date (when the page has one), ids (every result id the API gave that URL: one page can come back under several ids in a long run) and id (the first of them). It is not a list of what the answer cited. The API's annotations field was empty in every captured response, so the server cannot say which claim rests on which source. The inline markers in the answer are returned unchanged. In the captured responses a marker [N] or [web:N] names the search result whose id is N (checked on three markers in one research fixture, the bare [1] and [3] of the fast fixtures and all 8 markers of a live medium run, acceptance/markers.txt of openspec/changes/py-agent-citation-fixes/), so look N up in each source's ids; the readable result shows them as (ids 10, 71). A fetched page has no id, so a marker cannot be matched to one (a fetch-only run cited [web:0]; what that numbers is unverified). A source may be unused by the answer, and an answer may rest on a page that is not listed.

The fast preset answers with more confidence than its evidence can carry (one report: it stated an acquisition as fact where the deeper research found the disclosures did not show it). Use medium or perplexity_research for anything that goes into a deep analysis.

A source keeps at most 64 ids (a warning says how many were dropped). Sources saved before this change show no ids in the readable text, only id.

With json_schema, citation markers that end a string value are removed from answer_json, and one warning gives the count; the answer text keeps them. A marker is [N] (1 to 999, no leading zero) or [web:N] (0 to 999), in ASCII digits, with any ASCII whitespace before it; a marker inside a value, [0], [1000], [2024] and other bracket forms ([1,2], [^1]) are left alone. A parsed value nested deeper than 100 levels is returned as answer_json: null with a warning (read the answer text), because the structured result cannot be serialised beyond about 300 levels.

Attachments

perplexity_ask and perplexity_chat send take an optional attachments: a list of at most 10 strings, each an image or a document. perplexity_research and every other tool do not take attachments, and the command line has --attachments on ask and chat only. A call with no attachments, or an empty list, is built exactly as before. The query stays required: an attachment never replaces it.

The three forms. Each string is one of:

Form

Example

What happens

A local path

/Users/me/shot.png, ~/report.pdf

Absolute or starting with ~/ (a relative path is refused; perplexity-pro makes it absolute first). The server reads the file and sends it as base64

An HTTPS URL

https://example.com/report.pdf

Sent to the API as it is. This server never fetches it, resolves its host or checks it is reachable: the provider retrieves it. Port 443 or none, at most 2048 characters, no credentials, fragment, backslash or control character, and a plain ASCII host (an internationalized host must be written in punycode; an IPv6 literal is refused). http:// is refused because the API needs HTTPS

A data: URI

data:image/png;base64,iVBORw0KGgo=

Decoded strictly, at most 1 MiB decoded (larger input belongs in a path or a URL). Parameters before ;base64, such as ;charset=utf-8, are accepted and dropped

Any item may start with a media type and :: (application/pdf::https://example.com/download?id=7), which says what a URL with no recognizable extension is. On a path or a data: URI the prefix must equal the type the server derives, or the call is refused. The scheme is read case-insensitively.

Types. The kind is derived from the media type and never asked for. Images: PNG, JPEG, WEBP and GIF. Documents: PDF, DOC, DOCX, UTF-8 TXT and RTF. A path's type comes from its extension (.png, .jpg, .jpeg, .webp, .gif, .pdf, .doc, .docx, .txt, .rtf), a data: URI's from the URI, a URL's from the prefix or else the extension of its path. The first bytes of a file or a decoded data: item must match the type (the image signatures, %PDF-, the OLE signature for DOC, the ZIP signature for DOCX, {\rtf, and valid UTF-8 with no NUL byte for TXT), or the call is refused and nothing is sent. Audio and video are refused locally (.mp3, .wav, .mp4, .mov and the like, or an audio/ or video/ type): the API accepts neither.

Limits, all checked before any request, with the API's own limits as the backstop:

Limit

Value

Attachments per call

10

One file

20 MiB decoded

One call, all files and data: items

32 MiB decoded

One data: item

1 MiB decoded

Path string / URL

4096 / 2048 characters

Decoded bytes in flight in the whole process

64 MiB; a call that cannot get its share within 30 seconds fails rate_limited (a local wait: no Retry-After applies)

Request body

64 MiB, computed before any base64 is built (the caps above keep it under about 44 MiB)

Documents in one chat

30 documents and 50 MiB of document bytes, counting what a chained follow-up inherits; URL documents count toward the 30 and add no bytes

Reading a local path is guarded. The file is opened without following a final symbolic link and without blocking, must be a regular file (a directory, FIFO, socket, device or link is invalid_request, a missing file not_found), and is read no further than one byte past the size the open file reported (a file that grew fails); the 20 MiB limit is checked separately. The roots and the deny list are applied to the opened file's real path, never to the string you wrote, so a symlinked parent cannot escape and /Users/me/work-secrets is not inside /Users/me/work. Over stdio, with PERPLEXITY_ATTACH_ROOTS unset, any readable path is allowed. Over HTTP, local paths are refused unless PERPLEXITY_ATTACH_ROOTS is set (the server logs one line at start saying so); URLs and data: items are unaffected. With roots set, a path that is denied or outside them gets one uniform invalid_request ("the path is not readable or not allowed"), whether or not the file exists, so a restricted server does not reveal which paths exist; inside the roots, a missing file is not_found and an unreadable one invalid_request, naming the path as written (cut to 200 characters). The deny list (~/.ssh, ~/.aws, ~/.gnupg, ~/.config, ~/.claude, ~/.kube, ~/.docker, the data directory, and the base names ecosystem*.cjs, .env, .env.*, .envrc, *.env, *.env.*, .netrc, .npmrc and .pypirc) applies in every transport and under any roots. The roots and the deny directories are resolved with realpath first, and compared ignoring case only on a case-insensitive volume. This is protection against a confused or hostile caller, not a sandbox: with stdio and no roots, whoever can call the tool can attach any file the server's user can read and the deny list does not name. Set PERPLEXITY_ATTACH_ROOTS whenever the caller is not fully trusted.

Which model reads it. The gate checks the final route (an explicit model, a tier's model, the default model) against the model matrix, with the kinds the call carries. A model the matrix records as refusing a kind is refused locally with invalid_request, naming the model and the kind and listing up to five accepting models, and no request is made. A model the matrix does not know, or whose kind is unknown (or whose only refusal is older than 24 hours), is sent the attachment and the API answers: the matrix lags the API, and a wrong local refusal is worse than one 400. A depth carries media only where it was verified (images at fast, low and medium; documents at fast and medium); any other depth and kind is refused locally, naming an explicit model as the way out. perplexity_models shows each model's inputs. An upstream 400 on a call that carried new attachments stays invalid_request with a hint: a model that cannot read images answers the generic invalid request, and the hint then says the model may not accept that kind and points to perplexity_models; a descriptive body is kept and the hint names the kinds sent. If the 400 says the model itself is not served, the text says model <id> is not served by the API instead, and the matrix is not told the kind was refused. A run that comes back failed with a refusal error for a document is unexpected_response with a hint that another model may read it (it is still recorded: it was billed).

Cost. Attachments add input tokens, so a call can cost more than the figures in "Cost by depth", and there is no spending cap. The result's usage reports the tokens and the reported cost, and the call is recorded as one usage event like any other. In the live acceptance of 2026-11-19 (five attachments, a PNG, a PDF, a text file and an image and a PDF by URL, each on openai/gpt-6-luna and on depth fast; openspec/changes/media-inputs/acceptance/live-5-1.md) a call on the model cost $0.00001 to $0.00009 and a call on fast $0.00103 to $0.00162. A large PDF can be many thousands of tokens, so check usage after the first call. Attachments combine with search and the search filters. A call that fails local validation stores nothing, spends nothing and creates no project.

What is stored. File bytes, base64 and data: URIs are never written to the database, a result, an error message or a usage event, and the request body is never logged. A log record about an attachment holds at most its position, kind, media type, decoded size and the first 12 hex characters of its SHA-256. Error text, usage rows and logs are scrubbed of data: URI bodies and of base64 runs of 200+ characters that look like encoded bytes (upper case, lower case, a digit, and at most one / per 16 characters) ([media removed]), and a URL quoted in any of them loses its credentials, query and fragment, because a signed URL's secret lives there. Text that is stored or logged (a usage row, a log record) shows a quoted URL as scheme and host only (/… when a path was cut); the error returned to the caller keeps the URL's path, without credentials, query and fragment. A data: item is shown only as its position and media type.

In a chat. send takes attachments on any turn, with the same rules. The stored user message is the text, a newline and one trailer line, for example [attachments: shot.png (image/png, 2048 bytes, sha256 3f2a9c4b1d0e)]: a file or data: item shows its name (at most 60 characters, with ;, brackets, parentheses and control characters replaced by _), type, size and a 12-character digest; a URL shows only its host, type and a digest of its host and path. A trailer over 1500 characters ends with +N more: <d> documents, <i> images, <b> bytes, which still counts toward the per-chat limits. A line of your own that begins [attachments: is stored with a leading backslash, so a stored trailer is always genuine. read shows the trailer as part of the message. A chained follow-up sends only the new message and previous_response_id: the provider keeps the earlier files across turns and even a change of model (verified 2026-10-30), so a question about an earlier PDF needs no re-attach, and the model gate uses the new attachments' kinds plus the kinds named in the chat's stored notes. replay cannot resend files (the server never kept them): it sends the stored history, whose earlier turns carry only their trailers as text, starts a new provider chain, marks that turn [attachments: restart; ...] (just [attachments: restart] when it adds none), and its result carries a warning that N earlier attachments were not resent and can be attached again on that turn. Files and the document count restart from that turn, and the per-chat document limits do not apply to a replay's earlier attachments. A chained send that the API refuses with a 400 for a new attachment gets the attachment hint, not the advice to send again with replay; a 400 on a follow-up that carries only inherited kinds still gets that advice.

Examples (a stdio server reading the paths; the model is one the acceptance run used):

{"name": "perplexity_ask", "arguments": {"query": "What colour is this?", "model": "openai/gpt-6-luna", "attachments": ["/Users/me/shot.png"]}}
{"name": "perplexity_chat", "arguments": {"action": "send", "title": "Q3 report", "message": "Summarize this", "attachments": ["/Users/me/report.pdf"]}}

A refusal before any request (the live acceptance's c_audio step, run through the command; the path is shortened):

$ perplexity-pro ask "Transcribe" --model openai/gpt-6-luna --attachments audio.wav
[invalid_request] attachments[0]: audio is not supported (the API accepts neither audio nor video) Run perplexity-pro help ask for its arguments and examples.

perplexity_ask

One web-grounded question, answered synchronously and statelessly. It never waits for a background run. A completed or incomplete run returns a result; any other status is an unexpected_response error (the call is still recorded, because it was billed).

Argument

Type

Default

Meaning

query

string

required

The question, not blank, at most 20000 characters

project

string

default

The project the call is recorded under; created if absent

depth

fast, low or medium

none

The preset. high and xhigh are refused (see "Cost by depth"). Cannot be combined with tier or model

tier

light, standard or complex

none

custom routing mode only (refused in standard mode, naming the mode). Cannot be combined with depth or model

model

string

none

An explicit model id (for example openai/gpt-6-luna), used exactly as given in every mode. A call that names no depth, tier or model uses the routing mode's default model. It searches with the web search tool and a 3-step budget unless search is false. An Anthropic id gets max_output_tokens 4096 unless you set one

search

boolean

none

false answers from the model alone and is refused with depth (a depth always searches). true is accepted and changes nothing

domains

list of strings

none

At most 20 domains to search: all allowed (python.org) or all denied with a - prefix (-reddit.com). Mixing the two is refused

recency

hour, day, week, month or year

none

Only recent results

after, before

string YYYY-MM-DD

none

Only results published after or before this date. A malformed date is refused locally

country

string

none

Two-letter country code to localize the search (US)

max_results

integer 1 to 50

none

Search results to retrieve

instructions

string

none

System-style instructions, at most 10000 characters

max_output_tokens

integer 1 to 64000

none

Cap on answer tokens. A run that hits it is incomplete

json_schema

object

none

A JSON Schema whose root type is object, at most 20000 characters serialized, for a structured answer. The parsed answer is answer_json

attachments

list of strings

none

At most 10 images or documents: absolute or ~/ paths, HTTPS URLs or data: URIs, each with an optional <media type>:: prefix. They add input tokens. See "Attachments"

A search filter (domains, recency, after, before, country, max_results) replaces the preset's own tools with the web search tool alone, so a filtered medium run loses the preset's page fetching. The filters are validated here because the API accepts some invalid input silently (a mixed allow and deny list, a date in the wrong format) and would run, and bill, a call that ignored it.

Output (structuredContent, with the answer, a numbered source list and one usage line as text):

Key

Meaning

answer

The answer text; inline markers are unchanged

answer_json

The parsed answer when json_schema was given and the text parsed, else null

sources

Pages the run found or fetched (see "Sources are not citations")

status

completed or incomplete

incomplete_reason

Why an incomplete run stopped, for example max_output_tokens; otherwise null

warnings

Things worth knowing about this result

model

The model that answered

depth

The preset used; null when a model ran (the default route, a tier or model)

routing

How the model was picked: mode, tier (or null), model (the id requested, null for a preset) and selected_by (default, tier, depth or model)

response_id

The API's response id

usage

input_tokens, output_tokens, total_tokens, cost_usd (an exact decimal string, null when unknown) and cost_source (reported, computed or none)

latency_ms

Measured wall time of the upstream call

project

The project the call was recorded under

An incomplete answer is a result with a warning, not an error: the run happened and was billed. An invalid json_schema makes the API answer with the same generic 400 invalid request it gives for other mistakes, so the error message names the schema only as the likely cause.

Example, fast with a domain filter. The result is from the live acceptance run on 2026-10-09 (it predates the routing field; a current result also carries "routing": {"mode": "standard", "tier": null, "model": null, "selected_by": "depth"}) (openspec/changes/archive/2026-10-09-py-agent-api/acceptance/a1.json), shortened to 3 of its 10 sources; nothing else is edited. The acceptance files hold results, not requests, so every example call in this README is written to match its result (depth, project and the fields the result shows); where a result does not repeat the query, the query text is illustrative:

{"name": "perplexity_ask", "arguments": {"query": "What is the latest stable Python release?", "depth": "fast", "domains": ["python.org"], "project": "acceptance"}}
{
  "answer": "The latest stable Python release is **Python 3.15.0**, released October 9, 2026.[1]",
  "answer_json": null,
  "sources": [
    {"url": "https://www.python.org/downloads/release/python-3150/", "title": "Python Release Python 3.14.8 | Python.org", "date": null, "id": 1, "ids": [1]},
    {"url": "https://www.python.org/doc/versions/", "title": "Python documentation by version", "date": "2016-03-13", "id": 2, "ids": [2]},
    {"url": "https://devguide.python.org/versions/", "title": "Status of Python versions", "date": "2026-05-27", "id": 3, "ids": [3]}
  ],
  "status": "completed",
  "incomplete_reason": null,
  "warnings": [],
  "model": "openai/gpt-6-luna",
  "depth": "fast",
  "response_id": "resp_902df360-29f3-4568-b1f6-b78f6cdb7797",
  "usage": {"input_tokens": 3298, "output_tokens": 30, "total_tokens": 3328, "cost_usd": "0.00143", "cost_source": "reported"},
  "latency_ms": 2011,
  "project": "acceptance"
}

The same file's low run (a2.json), keys shortened to the ones that differ (it returned 15 sources and cost more than fast):

{"name": "perplexity_ask", "arguments": {"query": "What is FastMCP?", "depth": "low", "project": "acceptance"}}
{
  "answer": "FastMCP is a Python framework for building Model Context Protocol (MCP) servers, clients, and interactive applications that connect AI models to tools and data. [web:1]",
  "status": "completed",
  "model": "openai/gpt-6-luna",
  "depth": "low",
  "usage": {"input_tokens": 5464, "output_tokens": 95, "total_tokens": 5559, "cost_usd": "0.00156", "cost_source": "reported"},
  "latency_ms": 3156,
  "project": "acceptance"
}

A call that names nothing, from the live acceptance of the routing change (2026-10-13, standard mode; the request line is reconstructed from the answer, since the acceptance files hold results; keys shortened to the ones that differ, the answer cut to its first sentence; raw output in openspec/changes/archive/2026-10-13-routing-modes-config/acceptance/billed-calls.json):

{"name": "perplexity_ask", "arguments": {"query": "What is the latest stable Python 3 release? One sentence with a source.", "project": "acceptance-routing"}}
{
  "answer": "The latest stable release is **Python 3.15.0** ([Python.org](https://www.python.org/downloads/source/)). ...",
  "status": "completed",
  "model": "perplexity/sonar",
  "depth": null,
  "routing": {"mode": "standard", "tier": null, "model": "perplexity/sonar", "selected_by": "default"},
  "usage": {"input_tokens": 2571, "output_tokens": 88, "total_tokens": 2659, "cost_usd": "0.00336", "cost_source": "reported"}
}

A conflicting call (here a custom server) fails without sending anything:

[invalid_request] tier and model: `tier` and `model` cannot be combined: each one selects the model on its own. Pass one of them, or neither to use this server's default (the standard tier (perplexity/sonar)).

perplexity_chat

A multi-turn conversation kept in the local database, with four actions. The messages are stored in this server's perplexity.db, project-scoped. Only send calls the API and spends money; list, read and delete touch only the local database, and none of them ever creates a project (a by-id action in an absent project is not_found; list in one is empty).

Argument

Type

Default

Meaning

action

send, list, read or delete

required

What to do

message

string

none

send: the message, not blank, at most 20000 characters

title

string

none

send starting a chat: its title, 1 to 120 characters, required. Not allowed with chat_id

chat_id

integer

none

send: continue this chat; omit it to start a new one. read and delete: the chat

project

string

default

The project the chat belongs to

replay

boolean

false

send with chat_id: resend the stored history instead of continuing from the previous response (see below)

attachments

list of strings

none

send only: as in perplexity_ask (see "Attachments" for what a chat stores, a chained follow-up and replay)

depth, tier, model, search, domains, recency, after, before, country, max_results, instructions, max_output_tokens

as in perplexity_ask

as there

send only. depth and tier may change on every turn (a chained send may switch model: probed 2026-10-13); high and xhigh are refused. There is no json_schema

limit

integer

20 (list), 50 (read)

list: chats to return, 1 to 100, newest first. read: the last N messages, 1 to 200

confirm

boolean

false

delete needs true; removing a chat cannot be undone

A send continues from the last stored response with previous_response_id, sending only the new message, so the cost of a turn does not grow with the history. replay is the fallback: it resends the whole stored history (and, with it, every stored character as input on every turn). The provider rejects an unknown, malformed, unfinished or cancelled previous_response_id with one generic 400 invalid request (that an id can also expire is possible but was not measured); when that happens on a chained send, the error says the provider could not continue and to send again with replay: true. The server does not retry by itself, because a hidden second call would double the bill. A replay of more than 100000 stored characters adds a warning that every send costs more. Only completed turns are stored; an incomplete answer is returned with a warning (it was billed) and is not saved, and an incomplete first send creates no chat (chat_id is null).

Output of send has every perplexity_ask key except answer_json (always null here) plus:

Key

Meaning

action, project

The action and the project

chat_id, chat

The chat the call concerns (the new one for a first send) and its record: id, title, message_count, created_at, updated_at

continuation

new, chained (from the last response id) or replay

list returns chats (newest first), chats_total and truncated. read returns chat, messages (each with id, role, content, created_at and, for the assistant, response_id, model, preset and sources), messages_total and truncated. delete returns messages_removed. Keys an action does not use are null. A chat whose answer could not be stored after a billed call still returns the answer, with a not_saved warning; the usage event is kept.

Example, two turns in a new chat. The results are from the live acceptance run on 2026-10-09 (c1.json and c2.json), shortened to the keys shown and, for the first, 2 of its 10 sources. Turn 2 answers from turn 1 through the stored response id ("continuation": "chained"):

{"name": "perplexity_chat", "arguments": {"action": "send", "title": "acceptance chat", "message": "Remember this codeword for later: HERON-7. Just reply OK.", "project": "acceptance"}}
{
  "action": "send",
  "project": "acceptance",
  "chat_id": 1,
  "chat": {"id": 1, "title": "acceptance chat", "message_count": 2, "created_at": "2026-10-09T21:51:07.605016Z", "updated_at": "2026-10-09T21:51:07.605016Z"},
  "continuation": "new",
  "answer": "OK",
  "sources": [
    {"url": "https://sharpe.co.za/tools/code-word-generator/", "title": "Code Word Generator: a private phrase your family can say ...", "date": null, "id": 1, "ids": [1]},
    {"url": "https://militaryalphabet.net/", "title": "Military Alphabet - NATO Phonetic Alphabet - Communication", "date": "2025-05-05", "id": 2, "ids": [2]}
  ],
  "status": "completed",
  "model": "openai/gpt-6-luna",
  "depth": "fast",
  "usage": {"input_tokens": 3073, "output_tokens": 5, "total_tokens": 3078, "cost_usd": "0.00118", "cost_source": "reported"},
  "latency_ms": 1689
}
{"name": "perplexity_chat", "arguments": {"action": "send", "chat_id": 1, "message": "What was the codeword?", "project": "acceptance"}}
{
  "chat_id": 1,
  "chat": {"id": 1, "title": "acceptance chat", "message_count": 4, "created_at": "2026-10-09T21:51:07.605016Z", "updated_at": "2026-10-09T21:51:10.265646Z"},
  "continuation": "chained",
  "answer": "Your codeword is HERON-7.",
  "model": "openai/gpt-6-luna",
  "depth": "fast",
  "usage": {"input_tokens": 7583, "output_tokens": 55, "total_tokens": 7638, "cost_usd": "0.00158", "cost_source": "reported"},
  "latency_ms": 2613
}

perplexity_research

Starts a deep research run in the background and returns at once with a job id. Nothing ever waits for a run to finish: read progress and the answer with perplexity_jobs.

Argument

Type

Default

Meaning

query

string

required

The research question, not blank, at most 20000 characters

depth

medium, high or xhigh

medium

Deeper runs take longer and cost more (see "Cost by depth"). fast and low belong to perplexity_ask

instructions

string

none

System-style instructions, at most 10000 characters

project

string

default

The project the job belongs to; created if absent

Output: job_id (the local id, for perplexity_jobs), response_id, status (what the provider reported, usually queued or in_progress), depth, project, started_at (UTC, this server's clock) and message. A run that had already finished when it was submitted is stored finished and recorded at once.

A run is recorded as spend only when a perplexity_jobs call sees it finished. The submit is not recorded while it is still running (the cost is unknown until the run ends); a failed or already-finished submit is recorded at once. See "The unobserved-run gap" below.

Example, from the live acceptance run on 2026-10-09 (r1.json, unedited). The query's first 120 characters are the job's query_excerpt in j2.json; the rest is illustrative:

{"name": "perplexity_research", "arguments": {"query": "Compare the pricing models of Pinecone, Weaviate Cloud and Qdrant Cloud using current official pricing pages. Short table.", "depth": "medium", "project": "acceptance"}}
{
  "job_id": 1,
  "response_id": "resp_f607dfc5-a69a-44cd-9e45-43cb0587af76",
  "status": "queued",
  "depth": "medium",
  "project": "acceptance",
  "started_at": "2026-10-09T21:51:17.475891Z",
  "message": "The run is going in the background. Check it with perplexity_jobs status, or list with refresh true; it is recorded as spend when a call sees it finished."
}

perplexity_jobs

Manages the runs started by perplexity_research. No action waits for a run to progress: call again later. An action never creates a project (list in an absent project is empty; the others are not_found), and a job id from another project is not_found.

Argument

Type

Default

Meaning

action

list, status, result or cancel

required

What to do

job_id

integer

none

status, result, cancel: the job from perplexity_research

project

string

default

The project the job belongs to

refresh

boolean

false

list: first observe the project's running jobs, up to 10, least recently checked first

limit

integer

20

list: jobs to return, 1 to 100, newest first

  • status fetches a running job once, stores what it shows and reports progress (progress.searches, progress.fetches). A job that is already finished is served from the local database with no request.

  • result does the same, and returns the stored answer, sources and usage of a finished job. For a run that ended without an answer (cancelled, failed, incomplete, lost) the message says why. A run that is not finished returns no answer and a message to try again.

  • cancel fetches first, then cancels a running job at most once (a second call while the cancel is pending sends no second request). The result's status is cancelling; the run turns cancelled after a few more polls, so call status afterwards. Cancelling stops the run for good.

  • list returns jobs (each with job_id, response_id, depth, status, query_excerpt, model, started_at, finished_at, cancel_requested_at, usage_recorded), jobs_total and truncated. With refresh, not_refreshed counts running jobs that were not refreshed (beyond 10, or whose fetch failed; a failed one is also a warning naming the job).

A job's status is queued, in_progress, completed, failed, incomplete, cancelled, lost or an unknown provider status verbatim. lost means the provider no longer knows the run: it needs a second not-found answer at least 10 minutes after submit, and its spend cannot be recorded. cancelling is only ever reported by cancel, never stored. usage_recorded says a usage event was attempted for the run (best effort: perplexity_usage shows what was stored), and is always false for a lost job.

The unobserved-run gap. The first perplexity_jobs call that sees a run finished records its cost, once (overlapping calls record one event). Nothing watches in the background, so a run that nobody observes is never recorded: the provider ran and billed it, and perplexity_usage knows nothing. perplexity_jobs list with refresh: true settles up to 10 running jobs in one call and is the way to close the gap; use it after starting runs you do not plan to read. Once a job is observed finished, its result is served from the local database and stays readable; a run nobody observes can still be fetched while the provider keeps it, and becomes lost if the provider forgets it. The times a job carries (started_at, finished_at) are this server's clock, not the API's: the API rewrites its own timestamps on every fetch. finished_at is when a call saw the run finish, so it is an upper bound on when it did.

Deleting a project that still has running research jobs (perplexity_projects delete) discards their local rows, so the spend of those runs is never recorded while the provider keeps running and billing them; the delete result reports how many as running_jobs, and the confirmation message names them. Cancel them first.

Example, from the live acceptance run on 2026-10-09: the result of job 1 (j2.json, answer shortened to 160 characters and sources to 2 of 30), the cancel of job 2 and the status call after it (k1.json, k2.json, shortened to the keys shown), and the list (jl.json). Job 2's query was "Summarize the history of the Python programming language in five bullet points with sources." A cancelled run reports no usage; it was recorded with an unknown cost.

{"name": "perplexity_jobs", "arguments": {"action": "result", "job_id": 1, "project": "acceptance"}}
{
  "action": "result",
  "project": "acceptance",
  "job_id": 1,
  "status": "completed",
  "job": {"job_id": 1, "response_id": "resp_f607dfc5-a69a-44cd-9e45-43cb0587af76", "depth": "medium", "status": "completed", "query_excerpt": "Compare the pricing models of Pinecone, Weaviate Cloud and Qdrant Cloud using current official pricing pages. Short tabl", "model": "openai/gpt-6-luna", "started_at": "2026-10-09T21:51:17.475891Z", "finished_at": "2026-10-09T21:51:56.461160Z", "cancel_requested_at": null, "usage_recorded": true},
  "answer": "| Provider | Pricing model |\n|---|---|\n| **Pinecone** | **Starter:** free with usage limits. **Builder:** $20/month flat, with included usage limits. **Standard...",
  "sources": [
    {"url": "https://www.pinecone.io/pricing/", "title": "Pricing - Pinecone", "date": null, "id": 21, "ids": [21]},
    {"url": "https://www.pinecone.io/pricing/estimate/", "title": "Pricing", "date": null, "id": 22, "ids": [22]}
  ],
  "usage": {"input_tokens": 25474, "output_tokens": 974, "total_tokens": 26448, "cost_usd": "0.01722", "cost_source": "reported"}
}
{"name": "perplexity_jobs", "arguments": {"action": "cancel", "job_id": 2, "project": "acceptance"}}
{
  "action": "cancel",
  "job_id": 2,
  "status": "cancelling",
  "job": {"job_id": 2, "response_id": "resp_76ef65be-0662-4ad7-8c3c-dfd4bac61317", "depth": "medium", "status": "in_progress", "query_excerpt": "Summarize the history of the Python programming language in five bullet points with sources.", "model": null, "started_at": "2026-10-09T21:52:04.115117Z", "finished_at": null, "cancel_requested_at": "2026-10-09T21:52:07.375264Z", "usage_recorded": false},
  "progress": {"searches": 1, "fetches": 0},
  "message": "The cancel was accepted. The run turns cancelled after a few more polls: call status to see it and to record its spend."
}
{"name": "perplexity_jobs", "arguments": {"action": "status", "job_id": 2, "project": "acceptance"}}
{
  "action": "status",
  "job_id": 2,
  "status": "cancelled",
  "job": {"job_id": 2, "response_id": "resp_76ef65be-0662-4ad7-8c3c-dfd4bac61317", "depth": "medium", "status": "cancelled", "query_excerpt": "Summarize the history of the Python programming language in five bullet points with sources.", "model": null, "started_at": "2026-10-09T21:52:04.115117Z", "finished_at": "2026-10-09T21:52:11.813305Z", "cancel_requested_at": "2026-10-09T21:52:07.375264Z", "usage_recorded": true},
  "progress": {"searches": 2, "fetches": 0}
}
{"name": "perplexity_jobs", "arguments": {"action": "list", "project": "acceptance"}}
{
  "action": "list",
  "project": "acceptance",
  "jobs": [
    {"job_id": 2, "response_id": "resp_76ef65be-0662-4ad7-8c3c-dfd4bac61317", "depth": "medium", "status": "cancelled", "query_excerpt": "Summarize the history of the Python programming language in five bullet points with sources.", "model": null, "started_at": "2026-10-09T21:52:04.115117Z", "finished_at": "2026-10-09T21:52:11.813305Z", "cancel_requested_at": "2026-10-09T21:52:07.375264Z", "usage_recorded": true},
    {"job_id": 1, "response_id": "resp_f607dfc5-a69a-44cd-9e45-43cb0587af76", "depth": "medium", "status": "completed", "query_excerpt": "Compare the pricing models of Pinecone, Weaviate Cloud and Qdrant Cloud using current official pricing pages. Short tabl", "model": "openai/gpt-6-luna", "started_at": "2026-10-09T21:51:17.475891Z", "finished_at": "2026-10-09T21:51:56.461160Z", "cancel_requested_at": null, "usage_recorded": true}
  ],
  "jobs_total": 2,
  "truncated": false
}

Ranked web search results as data: a title, url, snippet and dates per result, and no model answer. It calls the Search API (POST /search), one request per call, and spends money.

Argument

Type

Default

Meaning

query

string or list of strings

required

One query, or a list of 1 to 5; each not blank, at most 8192 characters

project

string

default

The project the call is recorded under; created if absent

search_type

fast or web

fast

fast costs $0.001 per request, web $0.005 (see "Cost by search type"). people is refused (see below). The type is always sent, because an omitted one runs the dearer web search

max_results

integer 1 to 20

the API's 10

Total results across all queries. The API refuses 21

max_tokens

integer 1 to 16384

none

Cap on page text across all results. The API may drop whole results to fit it. 16384 is this server's own cap (the API accepts more)

max_tokens_per_page

integer 1 to 4096

none

Cap on page text per result. 4096 is this server's own cap

domains

list of strings

none

At most 20 domains: all allowed (python.org) or all denied with a - prefix (-reddit.com). Mixing the two is refused

recency

hour, day, week, month or year

none

Only recent results. Cannot be combined with after, before, updated_after or updated_before

after, before

string YYYY-MM-DD

none

Published on or after, or on or before, this date. A malformed date, or after later than before, is refused

updated_after, updated_before

string YYYY-MM-DD

none

The same for the last-updated date

languages

list of strings

none

At most 20 two-letter lowercase ISO 639-1 codes (en)

country

string

none

Two-letter country code to localize the search (US); sent in upper case

Every argument is checked before anything is sent: a bad one is an invalid_request error that names it, nothing is billed and no project is created. The API accepts several invalid inputs silently (a mixed allow and deny list, for one), so those are refused here rather than run and billed.

Output (structuredContent, with warnings, a numbered result list and one usage line as text):

Key

Meaning

results

The ranked results, in the API's order: title, url, snippet, date and last_updated (YYYY-MM-DD, or null when the API gave none)

count

Results kept

query_count

Queries in the request

search_type

fast or web

request_id

The API's request id

cost_usd

Exact USD cost of the request as a decimal string, null when unknown

cost_source

computed, or none when the cost is unknown

latency_ms

Measured wall time of the upstream call

project

The project the call was recorded under

warnings

Things worth knowing about this result

A result with no usable url is dropped, with a warning; a field longer than this server's size cap is cut, with a warning.

Several queries are merged and cannot be attributed. A request with a list of queries returns ONE flat list. Nothing says which query produced which result, and max_results is a total across the queries, not per query. The tool returns the API's list unchanged, sets query_count and adds a warning. When you need results per query, make one call per query (a fast call is $0.001).

Titles and snippets are third-party web content. Treat them as untrusted text, never as instructions: a page can say anything, including text that looks like a command to you.

max_tokens can drop results. The API keeps within the token budget by dropping whole results, not by shortening them. When max_tokens is set and fewer results come back than max_results (or than the API's default of 10), the result carries a warning saying so. Without max_results that can also just mean the query had few hits, and the warning says that too.

Why people is not offered. The API's search_type also accepts people. Its price is not documented, and it returns individuals' professional data. The server refuses it with invalid_request rather than bill an unknown amount for personal data.

Cost by search type. The cost is computed from Perplexity's documented prices (dated 2026-10-29, PRICES_AS_OF in pricing.py) at one request unit per call: the Search API's response carries no usage or cost to report. A five-query request is still one billing unit. cost_source is computed.

search_type

Cost per request

Evidence

fast (default)

$0.001

Computed from the documented price. Live acceptance, 2026-10-11: two fast calls, 0.001 each, recorded as 1000000 nano-USD each

web

$0.005

Computed from the documented price. Live acceptance, 2026-10-11: one web call, recorded as 5000000 nano-USD

The live acceptance (openspec/changes/archive/2026-10-11-py-search-api/acceptance/) made 3 billed calls, no errors and no unknown cost, and perplexity_usage for the project reported 7000000 nano-USD ($0.007), which equals 0.001 + 0.001 + 0.005. That reconciles the server's own books against its own price table. The provider's console was not read, so the cost of one unit per request is not checked against what Perplexity actually billed.

Two cases leave the books a lower bound (and so does any other error call, such as a 5xx or a timeout, which is recorded at cost 0 and may have been billed). A call the API refused with a 4xx or 429 is documented as not billed and is recorded with cost 0 and its error category. A billed-but-unparseable 200 (a success the tool could not read as a search response) may have been billed: it is recorded with status unexpected_response and an unknown cost, and perplexity_usage counts it in calls_cost_unknown, so its totals are a lower bound.

Rate limit. The provider's limit seen in the probe is 50 request units per one-second window (x-ratelimit-limit 50). A multi-query request probably counts one unit per query (three queries read 3), so a five-query request can trip it on its own only in a burst. A refused request does not count (120 parallel invalid requests drew no 429). A 429 is retried honoring Retry-After, then reported as rate_limited. No 429 from the Search API was observed.

Example, fast with a domain filter. The result is from the live acceptance run on 2026-10-11 (openspec/changes/archive/2026-10-11-py-search-api/acceptance/a1.json). The snippets are cut here to their first line followed by ... (the real ones are 1840, 4233 and 1466 characters); nothing else is edited:

{"name": "perplexity_search", "arguments": {"query": "python packaging guide", "search_type": "fast", "max_results": 3, "domains": ["python.org"], "project": "acceptance-search"}}
{
  "results": [
    {"title": "Python Packaging User Guide", "url": "https://packaging.python.org/en/latest/", "snippet": "Python Packaging User Guide\n...", "date": "2026-10-02", "last_updated": "2026-10-03"},
    {"title": "Packaging Python Projects", "url": "https://packaging.python.org/en/latest/tutorials/packaging-projects/", "snippet": "Packaging Python Projects - Python Packaging User Guide\n...", "date": "2026-10-02", "last_updated": "2026-10-03"},
    {"title": "Guides - Python Packaging User Guide", "url": "https://packaging.python.org/en/latest/guides/", "snippet": "Guides - Python Packaging User Guide\n...", "date": "2026-10-02", "last_updated": "2026-10-03"}
  ],
  "count": 3,
  "query_count": 1,
  "search_type": "fast",
  "request_id": "ce88a4f7-0961-4210-8c8c-f6babe6c83f2",
  "cost_usd": "0.001",
  "cost_source": "computed",
  "latency_ms": 316,
  "project": "acceptance-search",
  "warnings": []
}

The calls here are the requests that produced the saved results (a1, a2, a3); the long snippets are cut for reading.

A multi-query call with recency (a2.json): three queries, six results in one list, the merge warning, and the same $0.001. Three of the six results are shown, snippets cut:

{"name": "perplexity_search", "arguments": {"query": ["rust borrow checker", "golang generics", "zig comptime"], "search_type": "fast", "max_results": 6, "recency": "week", "project": "acceptance-search"}}
{
  "results": [
    {"title": "The next-gen borrow checker, a drop-in replacement for Rust ...", "url": "https://gist.github.com/FlameyosSnowy/a49a35ba006238be55d8c3e410c31061", "snippet": "The next-gen borrow checker, a drop-in replacement for Rust borrow checking.\n...", "date": "2026-10-09", "last_updated": "2026-10-11"},
    {"title": "Linguaggio Rust: cos’è, come funziona e a cosa serve ...", "url": "https://www.creativemotions.it/linguaggio-rust/", "snippet": "# Linguaggio Rust: cos’è, come funziona, a cosa serve e quando sceglierlo\n...", "date": "2026-10-06", "last_updated": "2026-10-11"},
    {"title": "rust.wyattau.com · 02-ownership-borrowing · ownershipOwnership and Borrowing | Rust", "url": "https://rust.wyattau.com/02-ownership-borrowing/ownership/", "snippet": "# Ownership and Borrowing\n...", "date": "2026-10-08", "last_updated": "2026-10-09"}
  ],
  "count": 6,
  "query_count": 3,
  "search_type": "fast",
  "request_id": "3db7385a-25f7-41ce-97be-4e0045c8e667",
  "cost_usd": "0.001",
  "cost_source": "computed",
  "latency_ms": 252,
  "project": "acceptance-search",
  "warnings": ["The API merges the queries into one list and does not say which query produced which result; make one call per query when you need that."]
}

A web search (a3.json) with a denied domain and a language filter. A null date is a page the API gave no publication date for. Two of the three results are shown, snippets cut:

{"name": "perplexity_search", "arguments": {"query": "python asyncio taskgroup", "search_type": "web", "max_results": 3, "domains": ["-reddit.com"], "languages": ["en"], "project": "acceptance-search"}}
{
  "results": [
    {"title": "Coroutines and tasks — Python 3.15.0 documentation", "url": "https://docs.python.org/3/library/asyncio-task.html", "snippet": "- The `asyncio.create_task()` function to run coroutines concurrently as asyncio `Tasks`.\n...", "date": null, "last_updated": "2026-10-10"},
    {"title": "Coroutines and Tasks", "url": "https://docs.python.org/3.12//library/asyncio-task.html", "snippet": "- The `asyncio.create_task()` function to run coroutines concurrently as asyncio `Tasks`.\n...", "date": "2013-12-03", "last_updated": "2026-10-11"}
  ],
  "count": 3,
  "query_count": 1,
  "search_type": "web",
  "request_id": "c3eacf73-044a-4f6f-afc6-80dc3f478347",
  "cost_usd": "0.005",
  "cost_source": "computed",
  "latency_ms": 308,
  "project": "acceptance-search",
  "warnings": []
}

Refusals return before any request (x1.json, x2.json), as [invalid_request] ... with structuredContent {"category": "invalid_request", "message": ...}:

[invalid_request] domains: an allowlist and a denylist (entries starting with '-') cannot be mixed; the API accepts a mixed list but its documentation calls it invalid.
[invalid_request] recency: cannot be combined with a date filter.

perplexity_decide

Typed questions about a text, answered with calibrated probabilities. It calls the Decisions API (POST /v1/decisions), one request per call however many questions it holds, and spends money. The answers are model probabilities, not facts: the tool returns a number or a distribution and you choose the threshold. A noul of 0.93 means the model puts 93% on yes, not that the answer is yes.

Argument

Type

Default

Meaning

state

string, object or list

required

What to judge: non-blank text, or a non-empty JSON object or list, at most 200000 characters serialized (our cap; the API's limit is 262144 tokens). Images are not supported in v1 and are refused (an image_url key or a data:image/ string anywhere in it). NaN, Infinity and nesting too deep to serialize are refused

questions

object

required

1 to 32 questions (our cap; the API allows 128), by a name you choose: each name non-blank text of at most 128 characters; the whole object at most 200000 characters serialized. Each question is {type, criteria, instructions}; see "Question shapes"

model

one of pplx-decider-v1.1-27b, pplx-decider-v1-27b, pplx-decider-v1.2, pplx-decider-flash-v1.2, pplx-decider-latest, pplx-decider-flash-latest, perplexity/pplx-decider-latest, perplexity/pplx-decider-flash-latest

pplx-decider-v1.1-27b

The Decisions model (eight accepted names). The default stays pplx-decider-v1.1-27b. The flash models cost half the others per input token (see Cost). Always sent

project

string

default

The project the call is recorded under; created if absent

Question shapes. instructions is optional on every type: non-blank text, or a non-empty object or list. Any other key in a question is refused.

type

criteria

Answer

noul (yes or no)

An object with the keys true and/or false, each saying what that answer means; or leave it out and give instructions. One of the two is required

noul: the probability the answer is yes, 0 to 1

choice

An object of 1 to 255 options: option name to a description (a value may be null; values are not validated beyond being JSON)

choice: the most probable option, confidence, and probabilities for every option

score

A list of 1 to 10 levels, in order (the index is the level number)

score: the probability-weighted level index, confidence, probabilities by level index, and legend (level index to the level's text)

Every argument is checked before anything is sent: a bad one is an invalid_request error that names it, nothing is billed and no project is created.

Output (structuredContent, with warnings, one line per question and one usage line as text):

Key

Meaning

answers

One answer per question, by your names. Each has type and the keys of its shape (noul, choice, confidence, probabilities, score, legend); keys that do not apply to the type are null

model

The model that answered

input_tokens, output_tokens

Token counts from the response; null when unreadable

cost_usd

Exact USD cost of the request as a decimal string, null when unknown

cost_source

computed, or none when the cost is unknown

latency_ms

Measured wall time of the upstream call

project

The project the call was recorded under

warnings

Things worth knowing about this result. A question the API returned no readable answer for is left out of answers with a warning

Cost. The API reports no cost, so it is computed from Perplexity's documented price (dated 2026-10-29, PRICES_AS_OF in pricing.py): $0.02 per million input tokens (20 nano-USD per input token) for pplx-decider-v1.2 and every name that selects it (pplx-decider-v1.1-27b, pplx-decider-v1-27b, pplx-decider-latest, perplexity/pplx-decider-latest), and $0.01 per million (10 nano-USD) for pplx-decider-flash-v1.2 and the flash latest names. The price follows the name the request used, not the model the response reports. Output tokens are free and there is no per-request fee. On one identical input (2026-10-29) the v1.2 call counted 136 input tokens and the flash call 201, so a flash call is cheaper per token, not necessarily half the total. cost_source is computed. A call whose input_tokens cannot be read has an unknown cost (cost_usd null, cost_source none), not a cost of zero, and perplexity_usage counts it in calls_cost_unknown.

The live acceptance (openspec/changes/archive/2026-10-11-py-decisions-tool/acceptance/, 2026-10-11) made 2 billed calls, no errors and no unknown cost, from 346 and 107 input tokens, and perplexity_usage for the project reported 9060 nano-USD ($0.00000906), which equals 346 x 20 + 107 x 20 (6920 + 2140). That reconciles the server's own books against its own price table. The provider's console was not read, so the computed cost is not checked against what Perplexity actually billed.

No request id. The response body carries no id, so the usage event's request id is empty and two identical calls each record an event, which is right because each was billed. An event carries no id (the response does have an x-request-id header, which the client logs but does not store).

A call the API refused with a 4xx is recorded with cost 0 and its error category, and any other error call (a 5xx, a timeout) is recorded the same way and may have been billed, so the usage totals stay a lower bound.

Rate limit. The provider's limit seen in the probe is 10 (x-ratelimit-limit 10; the one-second window is assumed, as for Search). It counts requests, not questions: one request holding 32 questions is one unit. A 429 is retried honoring Retry-After, then reported as rate_limited. No 429 from the Decisions API was observed in the acceptance run.

Example, a support ticket as an object state, default model, three questions of the three shapes. The result is from the live acceptance run on 2026-10-11 (d1.json): the values are as returned and only the line layout is compacted. The request below is the one that produced it (up to the wording of the criteria texts):

{"name": "perplexity_decide", "arguments": {
  "state": {"ticket": "App crashes when exporting a PDF with more than 200 pages", "customer_tier": "enterprise"},
  "questions": {
    "urgent": {"type": "noul", "criteria": {"true": "blocks the customer's work", "false": "does not block"}},
    "area": {"type": "choice", "criteria": {"export": "file export", "auth": "login", "billing": null}},
    "severity": {"type": "score", "criteria": ["minor", "moderate", "major", "critical"]}
  },
  "project": "acceptance-decide"}}
{
  "answers": {
    "urgent": {"type": "noul", "noul": 0.9272088398171816, "choice": null, "confidence": null, "probabilities": null, "score": null, "legend": null},
    "area": {
      "type": "choice", "noul": null, "choice": "export", "confidence": 0.9999303770930034,
      "probabilities": {"export": 0.999953584728669, "auth": 0.000012104419072042511, "billing": 0.000034310852258853485},
      "score": null, "legend": null
    },
    "severity": {
      "type": "score", "noul": null, "choice": null, "confidence": 0.572264292842776,
      "probabilities": {"0": 0.0014426776781794849, "1": 0.01213513817010492, "2": 0.5737069705209555, "3": 0.4127152136307601},
      "score": 2.397694720104296,
      "legend": {"0": "minor", "1": "moderate", "2": "major", "3": "critical"}
    }
  },
  "model": "pplx-decider-v1.1-27b",
  "input_tokens": 346,
  "output_tokens": 3,
  "cost_usd": "0.00000692",
  "cost_source": "computed",
  "latency_ms": 601,
  "project": "acceptance-decide",
  "warnings": []
}

Read the score as a position on the rubric: 2.40 sits between major (2) and critical (3), with 57% on major and 41% on critical. The confidence of a score or choice is a separate number from the answer.

The older model on a text state (d2.json), one score question. The values are as returned, with the layout compacted:

{"name": "perplexity_decide", "arguments": {
  "state": "The package arrived two weeks late and the box was crushed, but support refunded me quickly.",
  "questions": {"satisfaction": {"type": "score", "criteria": ["furious", "unhappy", "okay", "delighted"]}},
  "model": "pplx-decider-v1-27b",
  "project": "acceptance-decide"}}
{
  "answers": {
    "satisfaction": {
      "type": "score", "noul": null, "choice": null, "confidence": 0.6495288146561603,
      "probabilities": {"0": 0.012135763754312684, "1": 0.299771970111492, "2": 0.661664578410473, "3": 0.026427687723722365},
      "score": 1.7023841901036052,
      "legend": {"0": "furious", "1": "unhappy", "2": "okay", "3": "delighted"}
    }
  },
  "model": "pplx-decider-v1-27b",
  "input_tokens": 107,
  "output_tokens": 1,
  "cost_usd": "0.00000214",
  "cost_source": "computed",
  "latency_ms": 245,
  "project": "acceptance-decide",
  "warnings": []
}

Refusals return before any request (x1.json, x2.json), as [invalid_request] ... with structuredContent {"category": "invalid_request", "message": ...}. The first is a blank state, the second a state holding an image_url part:

[invalid_request] state: must not be blank.
[invalid_request] state: images are not supported in this version.

perplexity_embed

Indexes text as vectors in the local database and searches it by meaning. It calls the Embeddings API (POST /v1/embeddings) and spends money, but very little: see "Cost". One tool, four actions:

action

What it does

Calls the API

index

Embeds the project's saved chat messages (source chat), its completed research reports (job) or texts you pass (text, with items), and stores the vectors. Only items with no stored vector for the chosen model, size and encoding (or whose text changed) are embedded; an unchanged item spends nothing

yes, one request per batch

search

Embeds the query in one request and returns the stored chunks nearest to it, best first

yes, one request

status

Shows how many chunks are stored per source, model, size and encoding, and how many chat messages and completed jobs have no vector yet for the chosen combination

no

delete

Removes stored vectors, optionally filtered; needs confirm true

no

Privacy. index sends the text of every chunk it embeds to Perplexity, so index only what you are willing to send there. search sends only the query. The configured API key is replaced by [redacted] in any text before it is chunked, sent or stored (and in a hit's text on the way out); a pplx- shaped example in a text is kept. Nothing is sent by status or delete, and nothing is sent for a call that is refused locally.

Argument

Type

Default

Meaning

action

string

required

index, search, status or delete; anything else is invalid_request

source

chat, job or text

none

Required for index; filters search and delete. chat: every message with non-blank text of the project's chats, both roles. job: the project's research jobs with status completed and a non-blank result (an incomplete run has no answer). text: the items you pass

items

list of objects

none

index of text only (refused with another source): 1 to 100 objects {"key", "text"}. A key is non-blank text of at most 128 characters, unique within the call; a text is non-blank, valid UTF-8 and at most 100000 characters. A key indexed again with new text replaces that key's chunks

query

string

none

search: non-blank text of at most 4000 characters

top_k

integer

5

search: how many hits, 1 to 20

min_score

number

none

search: only hits scoring at or above this, -1 to 1 (a negative value is meaningful for int8 only; binary scores run 0 to 1)

limit

integer

256

index: stop after the whole item that makes the count of new chunks reach this, 1 to 2048. At least one whole item is always taken, so a call may embed up to 49 chunks more than limit

model

pplx-embed-v1-0.6b or pplx-embed-v1-4b

pplx-embed-v1-0.6b

The embedding model. On delete, omitted means every model. Always sent on a request

dimensions

integer

the model's full size

Vector size, a multiple of 8: 128 to 1024 for the 0.6b model, 128 to 2560 for the 4b model. Sent only when given, so the full size (1024 or 2560) applies when omitted. On delete, omitted means every size

encoding

int8 or binary

int8

int8 keeps one signed byte per dimension; binary keeps one bit per dimension, 8 times smaller than int8 of the same size. On delete, omitted means both

project

string

default

The project the vectors belong to; an index or search that makes a request creates it if absent

confirm

boolean

false

delete only: must be true; otherwise confirmation_required and nothing is removed

model, dimensions and encoding together are the combination (model, size, encoding). Vectors of different combinations are not comparable, so a search compares only chunks stored under its own combination, and the same text indexed under two combinations is two separate sets of rows. status lists every stored combination.

Every argument is checked before anything is sent: a bad one is an invalid_request error that names it, nothing is billed and no project is created. The refusals are an unknown action, source, model or encoding; a dimensions that is out of range for the model (for delete: outside 128 to 2560) or not a multiple of 8; items with the wrong shape, count, length, a repeated or blank key or a lone surrogate, or items given with a source other than text; a limit outside 1 to 2048; a blank or over-long query; a top_k outside 1 to 20; a min_score outside -1 to 1; and an index that would take a project past 20000 chunks for one combination. delete without confirm true is confirmation_required.

The store. Vectors live in one table, embedding_chunks (migration 0005; the upgrade first writes backup-0004.db, see "Data and backups"), in the same SQLite file as everything else. A chunk holds its text, its vector (the provider's bytes unchanged: int8, or packed bits for binary), its combination and a hash of its text. Every chunk belongs to a project, and a chunk of source chat or job also belongs to its chat message or research job, so:

  • deleting a chat removes the vectors of its messages, deleting a research job removes its vectors, and deleting a project removes all of the project's vectors (perplexity_projects delete counts the job and text chunks in rows_removed; the chat chunks go by the cascade of the chat delete and are not counted). Nothing asks first: status shows what is stored.

  • a project holds at most 20000 chunks per combination (our cap, which bounds the memory a search needs). An index that would pass it is refused before anything is sent, and says to delete something.

  • delete filters by source, model, dimensions and encoding only. There is no delete by key: to drop one text key, delete the text chunks and index the others again.

Chunks and batches. A text is split into chunks of at most 4000 characters (at the last blank line, else line break, else space before the limit, else at the limit), and a text yields at most 50 chunks; the rest is ignored and index says so in a warning. Chunks are sent in batches of at most 64 inputs and 100000 characters in all (our caps; the API allows 512 inputs). Each batch is one request, and the items it completes are stored before the next batch is sent, so a failure on batch 3 keeps every item fully embedded in batches 1 and 2 (the error says how many chunks were stored first); an item that straddles a batch boundary is stored only when its last chunk has been embedded, so the items of a failed batch, and an item split across it, stay pending (and are embedded, and billed, again on the next call). Batches run one after the other, never concurrently, and two index calls on one project in one server process wait for each other, so the same pending item is not embedded twice. limit makes index resumable: it stops after about limit new chunks and reports remaining, the pending chunks it left, so call it again until remaining is 0.

Scoring. For int8 the score is the cosine similarity of the query vector and the stored vector read as signed 8-bit integers (a zero vector scores 0). For binary it is 1 - hamming / dimensions, where hamming is the number of differing bits. The scan runs locally with numpy (a new dependency), in blocks, off the event loop, and compares at most 20000 chunks. A search over a combination with nothing stored returns no hits and a warning, makes no request and records no event. Vectors are never returned: no result, error, log record or usage event holds a vector, its base64 text or its bytes. A hit's text is cut to 800 characters (the text rendering shows 200).

Output (structuredContent, with warnings and one usage line as text). Keys that do not apply to the action are null:

Key

Meaning

action, project, warnings, latency_ms

The action, the project used, things worth knowing, and the measured wall time (of the upstream requests for index and search, 0 when none was made; of the local call for status and delete)

embedded_chunks, embedded_items, skipped_items, remaining

index: chunks and items stored; items skipped because they were already current or their source was deleted during the call; pending chunks left because of limit

requests, input_tokens

index, search: upstream requests made and tokens billed

cost_usd, cost_source, calls_cost_unknown

index, search: the exact sum of the recorded costs of this call's requests as a decimal string, where the cost came from (reported, computed, mixed or none), and how many requests had an unknown cost. A call that made no request has null cost_usd and cost_source

candidates, hits

search: stored chunks compared, and the best chunks first, each with score, source, chunk_index, text and its reference: chat_id and message_id, job_id, or key (the others null)

groups, unindexed_chat, unindexed_job

status: chunks per source, model, size and encoding; chat messages and completed jobs with text and no vector for the chosen combination (items whose text changed are not counted)

removed

delete: chunks removed

Cost. Prices are Perplexity's documented figures (dated 2026-10-29, PRICES_AS_OF in pricing.py), per million input tokens, with no per-request fee:

Model

Price

Nano-USD per token

pplx-embed-v1-0.6b

$0.004

4

pplx-embed-v1-4b

$0.03

30

Unlike Search and Decisions, the Embeddings API reports the cost of each response (usage.cost.total_cost, in USD), and the server records that figure (cost_source reported). The documented price is only a fallback: if a response reports no cost, or one in a currency other than USD, the cost is computed from prompt_tokens (computed), and if that is unreadable too it is unknown (none, counted in calls_cost_unknown), never zero. A reported cost is never replaced by a computed one.

The live acceptance (openspec/changes/archive/2026-10-11-py-embeddings/acceptance/, 2026-10-11) made 5 billed requests (2 index, 3 search), no errors and no unknown cost, and every cost was reported. perplexity_usage for the project reported 4086 nano-USD ($0.000004086), which equals 456 + 3420 + 36 + 24 + 150 for the five requests, from 248 tokens in all. The provider's console was not read (the manual read was waived), so the figure is the provider's own number in each response, not checked against what its console shows.

No request id. The response body carries no id, so the usage event's request id is empty and two identical requests each record an event, which is right because each was billed. A request the API refused with a 4xx is recorded with cost 0 and its error category, and any other error request (a 5xx, a timeout) is recorded the same way and may have been billed, so the usage totals stay a lower bound. A billed batch whose chunks then could not be stored is recorded, stays pending, and is billed again when indexed again.

Rate limit. The provider's limit seen in the probe is 50 (x-ratelimit-limit 50; the window is not documented here). A 429 is retried honoring Retry-After, then reported as rate_limited; its body was not captured and no 429 was observed in the acceptance run.

Examples, from the live acceptance run on 2026-10-11 against the project acceptance-embed. The values are as returned; the long text values are written in full where short and the layout is compacted. The five texts were indexed with these keys (i1.json, default model, default size, default encoding):

{"name": "perplexity_embed", "arguments": {"action": "index", "source": "text", "project": "acceptance-embed", "items": [
  {"key": "sourdough", "text": "Sourdough bread needs a live starter, a long slow fermentation and a very hot oven for a crisp crust."},
  {"key": "baking", "text": "To bake a loaf, mix flour, water and salt, let the dough rise overnight, then bake it in a preheated Dutch oven."},
  {"key": "python", "text": "Python asyncio lets a program run many I/O-bound tasks concurrently with async and await instead of threads."},
  {"key": "tasks", "text": "An asyncio TaskGroup starts coroutines together and cancels the rest if one of them raises an exception."},
  {"key": "volcano", "text": "A volcano erupts when magma rises through the crust, releasing ash, gas and lava from a vent."}]}}
{
  "action": "index", "project": "acceptance-embed", "warnings": [], "latency_ms": 207,
  "embedded_chunks": 5, "embedded_items": 5, "skipped_items": 0, "remaining": 0,
  "requests": 1, "input_tokens": 114, "cost_usd": "0.000000456", "cost_source": "reported",
  "calls_cost_unknown": 0, "candidates": null, "hits": null, "groups": null,
  "unindexed_chat": null, "unindexed_job": null, "removed": null
}

The text content of that result:

Indexed 5 chunks of 5 items (0 skipped, 0 chunks remaining) in 1 request(s).
Usage: 114 tokens, cost 0.000000456 USD (reported), project acceptance-embed.

A search (s1.json, top 3; chat_id, message_id and job_id are null on a text hit and are left out here, and the hit texts are the full chunks):

{"name": "perplexity_embed", "arguments": {"action": "search", "query": "how do I make crusty bread at home", "top_k": 3, "project": "acceptance-embed"}}
{
  "action": "search", "project": "acceptance-embed", "warnings": [], "latency_ms": 1197,
  "requests": 1, "input_tokens": 9, "cost_usd": "0.000000036", "cost_source": "reported",
  "calls_cost_unknown": 0, "candidates": 5,
  "hits": [
    {"score": 0.3855651915073395, "source": "text", "chunk_index": 0, "key": "baking",
     "text": "To bake a loaf, mix flour, water and salt, let the dough rise overnight, then bake it in a preheated Dutch oven."},
    {"score": 0.3696805238723755, "source": "text", "chunk_index": 0, "key": "sourdough",
     "text": "Sourdough bread needs a live starter, a long slow fermentation and a very hot oven for a crisp crust."},
    {"score": 0.12555111944675446, "source": "text", "chunk_index": 0, "key": "volcano",
     "text": "A volcano erupts when magma rises through the crust, releasing ash, gas and lava from a vent."}
  ]
}

The second query (s2.json, "running coroutines concurrently in Python", top 3) ranked tasks (0.4619726538658142), python (0.40427613258361816) and sourdough (0.06810659170150757), at 6 tokens and 0.000000024 USD. The bread and asyncio queries each put their two related texts first and the unrelated ones far below, which is the sanity check; the scores are the provider's model quality, not a probability.

The same texts indexed again with the 4b model, 256 dimensions and binary (i2.json) cost 0.00000342 USD for the same 114 tokens, and a search over that combination (s3.json, "what makes a volcano erupt", model pplx-embed-v1-4b, dimensions 256, encoding binary) scored volcano 0.71875 and python 0.59765625 (5 tokens, 0.00000015 USD, 5 candidates; the saved file holds only those two hits and does not record the request's top_k). Indexing the same texts again under the same combination (i3.json) sends nothing:

Indexed 0 chunks of 0 items (5 skipped, 0 chunks remaining) in 0 request(s).

with requests 0, latency_ms 0 and cost_usd and cost_source null. status (st1.json) then lists the two stored combinations:

text: 5 chunks (pplx-embed-v1-0.6b, 1024, int8)
text: 5 chunks (pplx-embed-v1-4b, 256, binary)
Not indexed: 0 chat messages, 0 jobs.

Refusals return before any request (x1.json, x2.json), as [invalid_request] ... with structuredContent {"category": "invalid_request", "message": ...}. The first is dimensions 130 for the 0.6b model, the second a blank text:

[invalid_request] dimensions: must be a whole number from 128 to 1024 for pplx-embed-v1-0.6b, a multiple of 8.
[invalid_request] items: each text is non-blank and at most 100000 characters.

delete with confirm true and no filter (d1.json) returned Removed 10 chunks. (both combinations), and status afterwards listed no groups. After the project itself was deleted, perplexity_usage still reported the five requests' 4086 nano-USD by its name, with 5 events retained.

perplexity_models

Lists the models available to the configured key, from the live GET /v1/models, with prices as the API reports them. The list and the prices are never typed by hand, so they track Perplexity; each model's accepted effort levels and input kinds come from the model matrix (see "Model matrix").

Argument

Type

Default

Meaning

provider

string

all

Only models from this provider, compared case-insensitively (for example anthropic)

refresh

boolean

false

Bypass the cache and fetch the list now

Output (structuredContent, with the same data rendered as text):

Key

Meaning

models

Entries with id, provider (the API's owned_by), pricing: input, output, cache_read, cache_write, unit (a field the API did not supply is null), and efforts from the model matrix: accepted and refused as lists of effort levels and source (probe, baseline or unprobed; an unprobed model lists none). A model the matrix does not hold has no efforts. inputs is one short string of the attachment kinds the matrix records for the model: the accepted kinds, then the refused ones in parentheses (image,document, image (refused document), (refused document)). An empty string means unknown, not unsupported, and a model the matrix does not hold has an empty string. Audio and video are not accepted by the API at all, so they never appear. The text table shows - for empty and says how many models have an unknown kind

providers

Every provider in the live list, ignoring the filter, so a typo in provider shows the real names

stale

true when the live request failed and an older cached list is shown instead

age_seconds

Seconds since the list was fetched live

matrix

The model matrix's origin (file or baseline), fetched_at and unprobed, the number of available matrix models with no complete probe. The tool reads the stored matrix; refresh refreshes only the list above

routing

The active routing mode and the configured model or tiers (name, id, known: whether the live list has the id; an id that is not listed is still used). Configuration, not live data, and present whatever provider says

presets

The Agent API preset names (fast, low, medium, high, xhigh) and the model each maps to, with source: "documentation" and as_of (the recording date). Presets are copied from Perplexity's documentation, not live data, and the model behind a name can change

A failed refresh serves the cached list (stale: true) only for rate_limited, upstream_failure and network_timeout, and only while it is younger than PERPLEXITY_CATALOG_MAX_STALE. An authentication or forbidden failure is always returned as an error, never hidden behind a cache.

Example call and result (values are from the recorded fixture tests/fixtures/models.json, captured 2026-10-09; the real list changes):

{"name": "perplexity_models", "arguments": {"provider": "anthropic"}}
{
  "models": [
    {
      "id": "anthropic/claude-haiku-4-5",
      "provider": "anthropic",
      "pricing": {"input": 1.0, "output": 5.0, "cache_read": 0.1, "cache_write": 1.25,
                  "unit": "usd_per_1m_tokens"}
    }
  ],
  "providers": ["anthropic", "google", "openai", "perplexity", "xai"],
  "stale": false,
  "age_seconds": 0.0,
  "presets": {
    "source": "documentation",
    "as_of": "2026-10-29",
    "presets": [
      {"name": "fast", "model": "openai/gpt-6-luna"},
      {"name": "xhigh", "model": "anthropic/claude-opus-5-5"}
    ],
    "note": "Taken from Perplexity's documentation, not from the live API. ..."
  }
}

The example is shortened: a real result lists every matching model (14 for anthropic in that fixture) and all five presets.

perplexity_usage

Reports what the recorded upstream Perplexity calls cost. It reads the usage events (one row per costed upstream call, stored by the server itself) and never writes. The four Agent tools record their calls (perplexity_ask, perplexity_chat send and perplexity_research, whose background runs are recorded when a perplexity_jobs call sees them finish), and so do perplexity_search, perplexity_decide and perplexity_embed; the totals are zero on a fresh install and until one of them runs.

Argument

Type

Default

Meaning

project

string

all projects

Only calls recorded under this project name. Matched by the name stored with each call, so a deleted project still reports; naming one that never existed returns zeros and creates nothing

since

string

no start

First UTC day to include, written YYYY-MM-DD

until

string

no end

Last UTC day to include, written YYYY-MM-DD; the whole day is included. 9999-12-31 is refused

group_by

tool, api, model, project or day

tool

The one grouping to return

limit

integer

20

Most groups to return, 1 to 200

A bad date, since after until, a limit outside 1 to 200 or an invalid project name is invalid_request.

Output (structuredContent, with a small plain-text table rendering the same data):

Key

Meaning

totals

The measures over every matching call, whatever limit is

groups

At most limit entries, each the same measures plus key. Ordered by cost, highest first (ties by key); day returns the latest limit days in ascending order. A call with no value for the grouping column is grouped under (none)

groups_total

How many groups matched in all

groups_truncated

true when limit cut the list, so groups does not cover everything (totals still does)

group_by, project, since, until, limit

The filters and grouping that were applied

The measures in totals and in each group: calls, errors (calls whose status is not ok), input_tokens, output_tokens, total_tokens, cost_nano_usd, cost_usd, calls_cost_computed and calls_cost_unknown. Money is exact. cost_nano_usd is an integer count of nano-USD (10^-9 USD), summed in the database, and cost_usd is the same amount as an exact decimal string such as "0.00875" (trailing zeros trimmed, "0" for none), never a float.

How each call's cost is known (cost_source, stored per call):

  • reported: the API returned the cost in its response, and the server stores it as given.

  • computed: the response carried no cost, so the server priced the call from Perplexity's documented prices, kept in pricing.py and dated (PRICES_AS_OF). The date is stored with the call, so a later price change does not rewrite old rows. calls_cost_computed counts these.

  • none: the cost is unknown, not free. Such a call adds 0 to the cost, and calls_cost_unknown counts it. An unknown token count likewise adds 0 to the token sums.

The cost is a lower bound. Error calls count cost 0 and may still have been billed, and every unknown-cost call adds 0, so the true spend is at least the reported figure. Read calls_cost_unknown next to cost_usd: any value above 0 means the figure is missing some spend.

Example call and result, from the live acceptance run on 2026-10-09 (u_tool.json, unedited): six real calls in the project acceptance (2 ask, 2 chat, 2 research, one of them the cancelled run). Your totals will differ:

{"name": "perplexity_usage", "arguments": {"project": "acceptance", "group_by": "tool"}}
{
  "totals": {"calls": 6, "errors": 1, "input_tokens": 44892, "output_tokens": 1159, "total_tokens": 46051, "cost_nano_usd": 22970000, "cost_usd": "0.02297", "calls_cost_computed": 0, "calls_cost_unknown": 1},
  "group_by": "tool",
  "groups": [
    {"calls": 2, "errors": 1, "input_tokens": 25474, "output_tokens": 974, "total_tokens": 26448, "cost_nano_usd": 17220000, "cost_usd": "0.01722", "calls_cost_computed": 0, "calls_cost_unknown": 1, "key": "perplexity_research"},
    {"calls": 2, "errors": 0, "input_tokens": 8762, "output_tokens": 125, "total_tokens": 8887, "cost_nano_usd": 2990000, "cost_usd": "0.00299", "calls_cost_computed": 0, "calls_cost_unknown": 0, "key": "perplexity_ask"},
    {"calls": 2, "errors": 0, "input_tokens": 10656, "output_tokens": 60, "total_tokens": 10716, "cost_nano_usd": 2760000, "cost_usd": "0.00276", "calls_cost_computed": 0, "calls_cost_unknown": 0, "key": "perplexity_chat"}
  ],
  "groups_total": 3,
  "groups_truncated": false,
  "project": "acceptance",
  "since": null,
  "until": null,
  "limit": 20
}

The text content of the same result:

Usage for project acceptance: 6 call(s), 1 error(s), 46051 token(s), cost 0.02297 USD (22970000 nano-USD).
The cost is a lower bound: error calls count cost 0 and may have been billed; 1 call(s) have no known cost and 0 cost(s) were computed from documented prices.
By tool: key | calls | errors | tokens | cost USD
perplexity_research | 2 | 1 | 26448 | 0.01722
perplexity_ask | 2 | 0 | 8887 | 0.00299
perplexity_chat | 2 | 0 | 10716 | 0.00276

The one unknown-cost call is the cancelled research run, which reports no usage. The research row holds both research runs: a run is recorded under the tool that started it, whichever perplexity_jobs call observed it. The two research costs add up to $0.01722 because only the completed run had a known cost.

perplexity_projects

Projects group what the server stores. A tool that stores something creates the project it names the first time, and uses the project default when none is given; this tool only looks projects up and never creates one. Project names are case-sensitive, 1 to 64 characters of ASCII letters, digits, -, _ and ., may not begin with ., and may not look like an API key.

Argument

Type

Meaning

action

list or delete

Required. list shows all projects; delete removes one

project

string

Project name (delete only)

confirm

boolean

Must be true for delete; deletion cannot be undone

Output: action; for list, projects (each with name and created_at, UTC); for delete, project, rows_removed, rows_retained and running_jobs. rows_removed counts rows removed from tables that reference the project directly (the project's chats and research jobs, and its text and job embedding chunks; the chat messages and the chat embedding chunks go by cascade and are not counted). running_jobs counts the project's research jobs that had not finished: deleting the project discards their local rows, so the spend of those runs is never recorded while the provider keeps running and billing them. When it is above 0, the result (and the confirmation_required message before it) carries a warning; cancel them first with perplexity_jobs cancel.

Deleting a project keeps its spend history. Usage events are not deleted: each is detached from the project (its project reference is cleared) and kept, together with the project's name as it was written, so perplexity_usage still reports that spend under the deleted name. rows_retained counts the events detached. Everything else stored in the project is removed. The project default may be deleted; it is recreated the first time a tool stores records in it. A fresh install lists no projects: perplexity_ask, perplexity_research and the first send of a new chat create the project they name (or default); every other action only looks a project up.

{"name": "perplexity_projects", "arguments": {"action": "list"}}
{"action": "list", "projects": [{"name": "demo", "created_at": "2026-10-09T19:32:31Z"},
                                {"name": "research", "created_at": "2026-10-09T19:32:31Z"}],

 "project": null, "rows_removed": null, "rows_retained": null, "running_jobs": null}

Example, from the live acceptance run on 2026-10-09 (d1.json and u3.json): deleting the project acceptance, which held 2 research jobs and 1 chat, then reporting its spend by name. The delete result was recorded before running_jobs was added to it, so that key is not in the saved file; the same call now also returns "running_jobs": 0 for this project (both jobs had finished).

{"name": "perplexity_projects", "arguments": {"action": "delete", "project": "acceptance", "confirm": true}}
{"action": "delete", "projects": null, "project": "acceptance", "rows_removed": 3, "rows_retained": 6}

The spend of the deleted project is still there (u3.json, the same totals as before the delete):

{"name": "perplexity_usage", "arguments": {"project": "acceptance", "group_by": "tool"}}

reports totals.calls 6 and totals.cost_usd "0.02297", with the three tools as groups.

Errors

Every tool failure is an MCP tool error (isError: true) in exactly one of eleven categories. A client can read the category three ways:

  • structuredContent.category (with structuredContent.message), for code

  • _meta.category, for code that only looks at metadata

  • the text content, which always starts [category] message, for clients that show only text

{"isError": true,
 "structuredContent": {"category": "confirmation_required",
   "message": "Deleting project 'demo' removes the project and its stored records and cannot be undone; spend history is kept. Call again with confirm=true."},
 "_meta": {"category": "confirmation_required"},
 "content": [{"type": "text", "text": "[confirmation_required] Deleting project 'demo' removes the project ..."}]}

Category

Meaning

invalid_request

A missing or mistyped argument, an invalid project name, an attachment that fails a local check (see "Attachments") or HTTP 400/422 from the API

authentication

The API rejected the key (HTTP 401)

forbidden

The key is not allowed to do this (HTTP 403)

not_found

Unknown tool, a project that does not exist, a local attachment file that does not exist (inside the allowed roots, or with no roots set), or HTTP 404 from the API

rate_limited

HTTP 429 after the allowed attempts, or at once when Retry-After exceeds PERPLEXITY_MAX_RETRY_WAIT. Also a call whose attachments could not get their share of the 64 MiB in-flight budget within 30 seconds: a local wait, with no Retry-After

upstream_failure

HTTP 5xx from the API

network_timeout

The API did not connect or answer within the timeouts

unexpected_response

Any other HTTP status, or a response missing a field the server needs

confirmation_required

A destructive action was called without confirm: true; nothing changed

storage_busy

A database write waited longer than PERPLEXITY_DB_BUSY_TIMEOUT; retry shortly

internal_error

An unexpected failure, or a call made while the server is shutting down. The message is generic and never contains exception text; the detail is logged to stderr with secrets removed

Security

  • Unauthenticated, loopback by default. The HTTP endpoints (/mcp, /health) have no authentication. The default host is 127.0.0.1. If PERPLEXITY_HOST is anything other than 127.0.0.1, ::1 or localhost, startup logs a warning to stderr. Use beyond loopback is unsupported until authentication exists.

  • Host and origin protection. FastMCP's host and origin checks are enabled explicitly. A request with a foreign Host header gets HTTP 421 and one with a foreign Origin gets 403, which blocks DNS-rebinding attacks from a web page against the local server.

  • The key is never emitted. It is held as a secret value and is removed, together with any pplx- shaped token, from logs, error messages, tool results, /health and every file the server writes. It is not stored in the data directory.

  • Owner-only data. The data directory is created with mode 0700 and the database with 0600; a looser existing directory is tightened or startup fails naming it.

  • Attachments. Local files are read only as described in "Attachments": no symbolic link as the final component, the real path checked against PERPLEXITY_ATTACH_ROOTS and a built-in deny list, and local paths refused over HTTP unless roots are set. Attachment bytes are never stored or logged, and text that is stored or logged shows a URL as scheme and host only.

  • The server never writes into the working directory of the project that calls it.

Data and backups

Everything persistent lives in PERPLEXITY_DATA_DIR (default ~/.perplexity-pro/):

File

Purpose

perplexity.db

The SQLite database: projects, usage events, chats and their messages, research jobs with their queries and results, embedding chunks with their vectors (WAL mode, so perplexity.db-wal and perplexity.db-shm appear while it is open)

migrate.lock

Lock file so two processes starting together cannot migrate at once

model_matrix.json

The model matrix (prices, availability, accepted effort levels and input kinds per model), written atomically by the refresh task of a serving process; safe to delete (see "Model matrix")

model_matrix.lock

Lock file for the matrix writes, so two servers sharing the directory do not overwrite each other

backup-<rev>.db

Copy of the database as it was at schema revision <rev>, taken automatically before a migration touches a database that already has a revision (for example backup-0001.db, or backup-0004.db when a revision-0004 database starts on this release)

Migrations run at startup. A failed migration rolls back and the server exits non-zero without listening. A database that is newer than the code is refused with both versions named. The backup exists for a migration that succeeded but turned out wrong. Restoring is manual:

  1. Stop the server (pm2 stop mcp-perplexity-pro, or stop the stdio client).

  2. Delete the write-ahead files so stale pages are not replayed over the restored file: rm -f ~/.perplexity-pro/perplexity.db-wal ~/.perplexity-pro/perplexity.db-shm

  3. Copy the backup over the database: cp ~/.perplexity-pro/backup-<rev>.db ~/.perplexity-pro/perplexity.db

  4. Run the previous version of the server (the one that matches that schema revision) and check GET /health.

Downgrading drops spend history. Revision 0002 creates the usage_events table. A downgrade of 0002 (migration code only; the server never downgrades by itself) drops that table and every usage event in it. A downgrade first writes backup-0002.db (the backup is named for the revision being left), and that file holds the usage_events table and its rows: restoring it with the steps above brings the history back. Another downgrade of the same revision replaces that file, so copy it somewhere safe first. The upgrade backup, backup-0001.db, holds no usage rows, and a fresh install has no backup at all, because only a database that already has a recorded revision is backed up.

Downgrading also drops chats and research jobs. Revision 0003 creates chats and chat_messages, and revision 0004 creates research_jobs. A downgrade of 0004 (migration code only) drops research_jobs with every job row, its stored queries and answers; a downgrade of 0003 drops chats and chat_messages with every stored conversation. Each downgrade first writes the backup named for the revision being left (backup-0004.db or backup-0003.db), and that file holds the table and its rows: restoring it with the steps above brings them back. The upgrade backup of a database that was at 0002 is backup-0002.db, which holds none of these tables. A database that has just been created holds no chats or jobs, and a run that was already started at the provider keeps running whatever happens to its row.

Downgrading also drops embedding vectors. Revision 0005 creates embedding_chunks. A downgrade of 0005 (migration code only) drops the table with every stored chunk and vector, and first writes backup-0005.db, which holds them. Upgrading a database that was at 0004 writes backup-0004.db first (it holds no embedding table). The source chats and research jobs are untouched by a downgrade, and index rebuilds the vectors, at the price of embedding them again.

Use your own PERPLEXITY_DATA_DIR in the paths if you set one. Both server processes (a pm2 HTTP instance and a stdio instance) may share one data directory.

Development

uv sync                              # install runtime and dev dependencies from uv.lock
uv run pytest                        # offline test suite (about 60 s)
uv run ruff check .                  # lint (ruff is the only linter)
uv run ruff format --check .         # formatting (ruff is the only formatter)
uv run pre-commit install            # once per clone: runs ruff and pytest on every commit
uv run pre-commit run --all-files    # run the commit checks by hand

The commit hook runs ruff check --fix, ruff format and uv run --locked pytest. CI (.github/workflows/ci.yml) runs uv sync --locked, ruff check, ruff format --check and pytest on Python 3.12 and 3.14 for every push and pull request. --locked makes the install fail when uv.lock is out of date; --frozen would not.

Tests

  • Tests are offline. A socket guard in tests/conftest.py fails any connection to a non-loopback address; a test that truly needs the network opts out with @pytest.mark.allow_network.

  • Upstream calls are faked by injecting an httpx2.AsyncClient on an httpx2.MockTransport (respx and pytest-httpx do not intercept httpx2).

  • Recorded API responses live in tests/fixtures/, each with a .meta.json sidecar naming the endpoint and capture date. Fixtures come from real calls and are scanned for key-shaped strings.

  • Tests marked live call the real API and are deselected by default (addopts = -m 'not live'). Run them deliberately with a real key:

    PERPLEXITY_API_KEY=<your-perplexity-api-key> uv run pytest -m live
  • The fixtures capture helper is tests/test_live_capture.py (a live test). It re-records the fixtures, scrubs account identifiers, scans every payload for keys before writing anything, and stops without writing if one is found:

    PERPLEXITY_API_KEY=<your-perplexity-api-key> uv run pytest -m live tests/test_live_capture.py

Layout

src/mcp_perplexity_pro/
  __main__.py     entry point: startup order, stdio and HTTP runners, graceful shutdown
  cli.py          argument parsing of the server command (--transport, --version)
  command.py      the perplexity-pro command: subcommands generated from the tool schemas, run in-process
  settings.py     PERPLEXITY_* settings and their validation
  server.py       build_server(): FastMCP wiring, AppContext, /health, error middleware
  client.py       the one Perplexity HTTP client (httpx2): retry, typed errors, redaction; the
                  Agent calls create_run, get_run and cancel_run
  errors.py       PerplexityError and the eleven error categories
  catalog.py      model list cache, stale-on-failure rule, documented presets
  agent.py        Agent API request building and validation, response digestion, run_costed
                  and the research job observation
  costed.py       costed_call: the one costed-call sequence (project, timed call, record),
                  shared by the Agent, Search, Decisions and Embeddings tools and the model matrix
                  probe (which records under no project); cost_fields turns a recorded usage into
                  the result's cost
  matrix.py       the model matrix file: load with the packaged baseline, merge, atomic write under
                  a lock (pure, no network)
  matrix_refresh.py  the refresh task, the effort probe and the input probe of a serving process
  media.py        attachments: the grammar of an item, kinds and types, signatures, URL rules, limits
                  and the request parts (pure)
  media_read.py   the local read of a path: safe open, roots and deny list on the real path, the
                  process-wide byte budget
  media_gate.py   the model gate for a call's kinds and the hints for an upstream refusal
  media_notes.py  the stored attachment note of a chat turn and what a chat counts from it
  call_flow.py    the shared order of an ask or chat send: selectors, attachment parse, resolve, gate
  data/           model_matrix_baseline.json, the matrix every install starts from (packaged)
  routing.py      which model answers an ask or chat: the routing mode, resolve() for the three
                  selectors, the instructions and description text (pure)
  help_text.py    the curated help behind perplexity_help (pure, no FastMCP; `perplexity-pro help` reuses it)
  search.py       Search API request building and validation, response digestion, run_search
  decisions.py    Decisions API request building and validation, response digestion,
                  decisions_usage (cost from input tokens), run_decide
  embeddings.py   Embeddings API request building and validation, chunking, vector decoding,
                  scoring (numpy), the index planner, embeddings_usage (reported cost, computed
                  fallback), run_embed and the index, search, status and delete operations
  models/         tolerant pydantic models for API payloads (agent.py: Agent runs, search.py:
                  Search responses, decisions.py: Decisions responses, embeddings.py: Embeddings
                  responses)
  tools/          one module per tool, each with register(server): ask, chat, research, jobs,
                  search, decide, embed, models, projects, usage, help
  usage.py        usage recorder (record_usage), money helpers, the Agent and Embeddings usage
                  parsers (Search and Decisions have none: their cost is computed)
  pricing.py      documented Perplexity prices in nano-USD, for costs the API does not report
  usage_report.py read-only spend report behind perplexity_usage
  storage/        engine, unit_of_work session, migration runner, project rules, ORM models,
                  chats.py (chat rows and history), jobs.py (research job rows), embeddings.py
                  (embedding chunk rows: insert, hashes, vectors for scoring, delete)
  migrations/     Alembic environment and versions/NNNN_slug.py, 0001 to 0005 (packaged in the
                  wheel)
  log_setup.py, redaction.py   stderr logging with secrets removed
tests/            offline tests, fixtures/, and the live-marked capture helper
openspec/         the spec-driven change records (`openspec/changes/archive/` holds every delivered change)

Contributor and agent guidance is in CLAUDE.md.

Available Tools

11 tools
perplexity_askPerplexity AskA

Ask one web-grounded question and get the answer with its sources. Synchronous and stateless; it never waits for a background run (use perplexity_research for those).

Approximate cost per call by depth (observed ranges; the upper figures are estimates): fast $0.001 to $0.002, low $0.0005 to $0.004 (up to about $0.02 estimated), medium $0.016 to $0.025 as a research run (up to about $0.05 estimated; a synchronous medium call was not measured). high and xhigh can cost dollars and take minutes (unmeasured estimates), so they exist only behind perplexity_research. Giving a search filter (domains, recency, after, before, country, max_results) makes the run use the web search tool alone, so a filtered medium run loses the preset's page fetching.

The request sets store to false, which only hides the response from retrieval; the provider's documentation says it still persists state, so this is not a retention control. Sources are what the run touched, not a citation of each claim. Every call that reaches the API is recorded as spend (see perplexity_usage).

Routing mode: standard. With no depth, tier or model perplexity/sonar answers with web search; tier is for custom mode only. A model is always used as given. The per-depth costs above apply to depth; the default model's cost differs (see perplexity_usage). Details: call perplexity_help.

Inputs: query (required), tier, after, depth, +11 more. Returns: The result of one answered call; ``perplexity_chat`` send extends it (design D1…

perplexity_chatPerplexity ChatA
Destructive

Hold a multi-turn conversation grounded in web search. A send continues the chat from its last stored response; the messages are kept in this server's local database. Actions: send (starts a chat when chat_id is omitted), list, read and delete.

Approximate cost per send by depth (observed ranges; the upper figures are estimates): fast $0.001 to $0.002, low $0.0005 to $0.004 (up to about $0.02 estimated), medium $0.016 to $0.025 as a research run (up to about $0.05 estimated; a synchronous medium send was not measured); high and xhigh are not available here (use perplexity_research). Every send is recorded as spend (see perplexity_usage). list, read and delete make no upstream call and cost nothing; they read or change only the local database and never create a project.

Chat text is stored in the local database. A send sets store to false, which only hides the response from retrieval at the provider; the provider's documentation says it still persists state, so this is not a retention control. If the provider cannot continue from the previous response, send again with replay true to resend the stored history.

Routing mode: standard. With no depth, tier or model perplexity/sonar answers with web search; tier is for custom mode only. A model is always used as given. The per-depth costs above apply to depth; the default model's cost differs (see perplexity_usage). Details: call perplexity_help.

Inputs: action (required), tier, after, depth, +16 more. Returns: The result of every action; the fields an action does not use are null (design…

perplexity_decidePerplexity DecideA

Put typed questions about a text to the Decisions API and get a calibrated answer for each: a yes probability (noul), the most probable option with every option's probability (choice), or a probability-weighted position on an ordered rubric (score). The answers are model probabilities, not facts: you choose the threshold. Costs about $0.02 per million input tokens (output is free), a few thousandths of a cent per call, however many questions one call holds; a refused call costs nothing. Every request that reaches the API is recorded as spend (see perplexity_usage).

Inputs: state (required), questions (required), model, project. Returns: model, answers, project, cost_usd, +5 more

perplexity_embedPerplexity EmbedA
Destructive

Index your saved chats, completed research reports or texts as vectors and search them by meaning. index SENDS the text it indexes to Perplexity (search sends only the query); vectors are stored locally per project and are never returned. Prices per million tokens: $0.004 for pplx-embed-v1-0.6b, $0.03 for pplx-embed-v1-4b (the reported cost is recorded; see perplexity_usage). An unchanged item is never embedded twice; index stops after about limit new chunks and reports remaining, so call it again until 0. status shows what is stored and what is not; delete removes vectors (confirm true). Deleting a chat or a project removes its vectors. Details: call perplexity_help.

Inputs: action (required), items, limit, model, +8 more. Returns: hits, action, groups, project, +15 more

perplexity_helpPerplexity HelpA
Read-only

How to use this server: start with action index (a short page that picks the right tool), then tool with a tool name, or topic (routing, costs, citations, errors, projects). Free; makes no API call.

Inputs: name, action. Returns: name, text, tools, action, +1 more

perplexity_jobsPerplexity JobsA
Destructive

Manage research runs started by perplexity_research. Actions: list (newest first), status (one fetch of a running job, with progress), result (the stored answer, sources and cost of a finished job) and cancel (stops a running job for good). Nothing here waits for a run to progress: call again later.

status, result and cancel fetch a job that is not finished at most once and then store what it shows; a finished job is served from the local database with no request. The first call that sees a run finished attempts to record its cost as spend, once: list with refresh true settles up to 10 running jobs, and a run nobody observes is never recorded. A run the provider no longer knows becomes lost after a second not-found at least 10 minutes after submit, and its spend cannot be recorded. Actions never create a project: list in an absent project is empty, the others fail with not_found. Details: call perplexity_help.

Inputs: action (required), limit, job_id, project, +1 more. Returns: The result of every action; the fields an action does not use are null (design…

perplexity_modelsPerplexity ModelsA
Read-only

List the models available to the configured key with their prices (live data), plus the documented Agent API presets as a separate section.

Inputs: refresh, provider. Returns: stale, models, presets, routing, +2 more

perplexity_projectsPerplexity ProjectsA
Destructive

List the server's projects, or permanently delete one with its stored records.

Spend history (usage events) is not deleted: it is kept, detached from the project, and stays reportable by the project's name. Neither action creates a project.

Inputs: action (required), confirm, project. Returns: action, project, projects, rows_removed, +2 more

perplexity_researchPerplexity ResearchA

Start a deep research run in the background and return at once with a job id. The call never waits for the run: read progress and the result with perplexity_jobs (status, result, list, cancel).

Approximate cost per run by depth: medium $0.016 to $0.025 and 39 to about 90 seconds over four runs (query-dependent; up to about $0.05 estimated); high can cost up to about $0.4 to $0.9 and take minutes, and xhigh more (both unmeasured estimates, from the provider's positioning). There is no spending cap. A run is recorded as spend only once a perplexity_jobs call observes it finished, so call status or list with refresh true; a run nobody checks is never recorded.

Research runs are stored by the provider (store is true, because a background run that is not stored cannot be retrieved), so the query and result stay retrievable there. The query and the result are also kept in this server's local database. Details: call perplexity_help.

Inputs: query (required), depth, project, instructions. Returns: depth, job_id, status, message, +3 more

perplexity_usagePerplexity UsageA
Read-onlyIdempotent

Report what recorded upstream Perplexity calls cost: exact totals over every matching call plus one grouping, filtered by project and UTC date range. Read-only.

The cost is a lower bound: error calls count cost 0 and may have been billed. calls_cost_unknown says how many calls have no known cost. Unknown token counts add 0. Projects are matched by the name recorded with each call, so a deleted project still reports. The Agent tools (ask, chat, research) record their calls; nothing is recorded by a tool that does not make costed calls.

Inputs: limit, since, until, project, +1 more. Returns: limit, since, until, groups, +5 more

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.3/5.0

    Scored across 11 tools

    Disambiguation4/5

    Tools are mostly distinct: ask, chat, research, and search cover different modalities (synchronous one-shot, multi-turn, background deep research, raw results), and jobs/embed/usage are clearly separate. However, the four query-oriented tools share web-grounded querying, so an agent may need to read descriptions carefully to route correctly.

    Naming Consistency5/5

    All 11 tools use the same perplexity_ snake_case prefix, with no casing or style mixing. The suffixes mix verbs and resource nouns, but the pattern is predictable and consistent for this server.

    Tool Count5/5

    11 tools is well within a reasonable range for a Perplexity integration covering ask/chat/research/search/embed/jobs/models/projects/usage/help. Each tool maps to a meaningful capability rather than being redundant.

    Completeness4/5

    Covers core Perplexity workflows, chat/research lifecycle, embedding index/search/delete, usage reporting, model listing, help, and project deletion. Minor gap: projects can be listed and deleted but not created or renamed, which may limit isolated local storage workflows.

    Maintenance

    ActivityMaintained
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers