packages/provider-perplexity sends tracked queries to the Agent API (POST https://api.perplexity.ai/v1/agent). Canonry measures mentions from answer text and cited domains from the source URLs that the adapter extracts.
Perplexity retired Sonar Chat Completions on 2026-09-27 (migration guide). Rows written before the switch are Sonar responses; the adapter still parses them (see Stored history).
The configured model is either an Agent API preset or a vendor/model slug:
| Configured | Request field | Notes |
|---|---|---|
fast (default) |
preset: "fast" |
Perplexity’s suggested replacement for sonar |
low, medium, high, xhigh |
preset |
Heavier, costlier search tiers |
perplexity/sonar, openai/gpt-5.1, … |
model |
One model plus Canonry’s web_search tool |
Retired names still validate and resolve through PROVIDER_MODEL_ALIASES in packages/contracts/src/models.ts: sonar → fast, sonar-pro / sonar-reasoning / sonar-reasoning-pro → low, sonar-deep-research → medium. The long preset names (fast-search, pro-search, deep-research, advanced-deep-research) fold into the short ones.
{
"preset": "fast",
"input": "best crm for startups",
"tools": [{ "type": "web_search", "user_location": { "city": "New York", "region": "New York", "country": "US" } }],
"tool_choice": { "type": "web_search" }
}
web_search tool as user_location (treatment request-param), not in the text as it did with Sonar.tool_choice forces the search, so the retrieval contract is search-required-v1, the same as Claude. Canonry sends no instructions; a preset’s built-in prompt is part of the engine being measured.user_location carries only city, region, and country (no type or timezone, unlike OpenAI’s).anthropic/* slugs also send max_output_tokens: 4096, which the API requires for them, on every request path (sweep, key check, text generation). Presets and other slugs stay uncapped.input: 'Say "ok"' and no forced search.| Field | Source |
|---|---|
answerText |
output_text parts of every message item, joined |
groundingSources |
URLs in search_results.results, fetch_url_results.contents, and message annotations, deduplicated in output order |
citedDomains |
Unique hosts of groundingSources |
searchQueries |
search_results item queries[] |
retrievalStatus |
used with a search_results or fetch_url_results item; not-used with a message and neither; unknown otherwise |
servedModel |
Top-level model (the model a preset resolved to) |
model |
The resolved preset or slug that was requested |
usage |
usage: input_tokens minus the cache reads and writes input_tokens_details breaks out of it = input tokens; cache_read_input_tokens = cached; cache_creation_input_tokens = cache writes; output_tokens = output. Searches are tool_calls_details.web_search.invocation (the billed count) when reported, else one per search_results item. No usage object → none recorded |
stopReason |
incomplete_details.reason when set, else status |
The adapter reads sources from the output array and checks the response status even on HTTP 200. It accepts completed or an absent status. It accepts incomplete only with nonempty answer text. Other statuses fail the query. The shared retry policy covers rate limits, 5xx responses, and network errors.
Switching the engine behind perplexity is treated as a model change:
normalizeExecutionIdentity (contracts) resolves retired ids, so a plan run whose config still says sonar gets an execution identity naming fast and starts a new series.packages/config, project overrides (on write, and on read in the job runner, run queue, query tracking, and research) resolve the same way, so the frozen slot, snapshot model, and identity agree.sonar keeps that id in its slots and snapshots (the revision is immutable); its identity still resolves to fast, and servedModel shows the Agent model. The job runner sends and prices such a slot as fast on both the sync and the batch path. A revision that froze different retired ids on different nodes (sonar and sonar-pro) records every model that now answers (fast + low); before the switch such a mixed-model engine was left out of the identity, so without this its checksum would not move. Mixed-model engines with no retired id are still left out.model_retired): its missing slots would run the replacement engine under the old run’s identity. The run’s stored identity decides, since runs queued since the switch never record a retired id; for a mixed-model engine an earlier identity omitted, the frozen slots decide.reparseStoredResult dispatches on shape. A response with an output array is Agent; anything else is Sonar Chat Completions and keeps its parser: choices[0].message.content, sources from search_results (preferred, keeps titles) or citations, no search queries, and retrievalStatus: unknown. Both work direct or wrapped under apiResponse, so canonry backfill and reparse read old sweeps as before.
query_snapshots.raw_response:
{
"model": "fast",
"groundingSources": [{ "uri": "https://example.com/page", "title": "Page Title" }],
"searchQueries": ["best crm for startups"],
"apiResponse": {
"object": "response",
"status": "completed",
"model": "perplexity/sonar",
"output": [
{ "type": "search_results", "queries": ["..."], "results": [{ "id": 1, "url": "...", "title": "..." }] },
{ "type": "message", "role": "assistant", "content": [{ "type": "output_text", "text": "...", "annotations": [] }] }
]
}
}
The fixtures in packages/provider-perplexity/test/fixtures/ follow the Agent API schema in Perplexity’s official SDK but are not live captures (see that folder’s README). To replace them, run each request shape with a key and save the body:
curl -sS https://api.perplexity.ai/v1/agent \
-H "Authorization: Bearer $PERPLEXITY_API_KEY" -H 'content-type: application/json' \
-d '{"preset":"fast","input":"best crm for startups","tools":[{"type":"web_search"}],"tool_choice":{"type":"web_search"}}' \
> packages/provider-perplexity/test/fixtures/agent-fast-cited.json
curl -sS https://api.perplexity.ai/v1/agent \
-H "Authorization: Bearer $PERPLEXITY_API_KEY" -H 'content-type: application/json' \
-d '{"preset":"fast","input":"Say \"ok\""}' \
> packages/provider-perplexity/test/fixtures/agent-no-search.json
Then update the exact values test/agent-api.test.ts asserts.
@perplexity-ai/perplexity_ai src/generated/api.ts (ResponsesResponseOutput)