In this article
Route responses by the interface contract: Search returns candidate records, while Agent output contains typed execution and answer items.
A shared HTTP client can call both Perplexity Search and Agent APIs, but a shared prose parser is the wrong abstraction. The interfaces return different artifacts. Identify the response contract before normalizing it for storage or presentation.
Parse Search as records
The Search overview describes a results list with title, url, snippet, date, and last_updated, plus request metadata. Keep source records distinct. An empty snippet is permitted, and nullable dates must remain unknown rather than being replaced with the request time. A result card can exist without usable answer evidence.
Parse Agent as typed output
The Agent quickstart describes output_text as an SDK convenience and output as the underlying collection. Message items contain output-text content; other item types can describe tool work. Do not stringify that entire collection and treat the resulting JSON as the assistant’s answer.
Keep normalization explicit
Define an internal source record separately from an answer record. Search records can feed the application’s own model. Agent output may already include generated text and associated evidence. A consumer requiring sources should not silently receive only aggregated prose, and a consumer expecting an answer should not mistake a search snippet for a completed synthesis.
Preserve the transport distinction
The compatibility guide concerns the Agent interface, not a promise that standalone Search uses the same response shape. Store the interface identity with request diagnostics. This makes an incorrectly selected parser distinguishable from an empty result or an unsupported model request.
Verify useful fixtures
Include Search with empty text, Agent with several output item types, and an answer whose source metadata must survive rendering. The article on provider response normalization explains field-level adaptation. The guide to content-part contracts shows why nested types need deliberate handling. A good abstraction unifies what consumers need while preserving the differences that determine whether evidence and answers are actually present.
Earn rental income from GPUs
Have idle GPUs or looking to fund AI infrastructure? Retrivium finds a rental platform, sets up the server and helps you assess income and costs with a pilot.