Editorial illustration for Perplexity's Search as Code lets AI build pipelines, improving performance
Perplexity's Search as Code lets AI build pipelines,...
Perplexity's Search as Code lets AI build pipelines, improving performance
Perplexity is betting on a different way for AI agents to fetch information. Rather than sending a query to a static search API and parsing a list of links, its new “Search as Code” (SaC) architecture lets the model generate a Python script that runs the search itself. The company says this shift can tighten result relevance and cut token consumption.
In practice, the model first decides on a strategy, then writes code that calls Perplexity’s backend through a set of simple SDK functions—retrieving, filtering, deduplicating and reranking results. That code executes inside a secure sandbox, giving the agent full control over the workflow instead of a black‑box API call. The three‑layer stack—model, sandbox, SDK—aims to replace the repetitive loop many agents fall into: query, read, re‑query, repeat, often dozens of times.
By handing the model the ability to script its own search pipeline, Perplexity hopes to move beyond the “neat list of blue links” that traditional engines were built for, offering a more flexible, agent‑centric approach.
Of course, take self-reported benchmarks with a grain of salt, but the comparison against Perplexity's own older architecture shows a clear, massive leap in performance. Code as the operational layer for AI Perplexity frames SaC as part of a bigger trend. The most capable systems combine both: models for strategy, deterministic runtimes for batching and filtering, and search infrastructure as an I/O layer.
Search as Code is rolling out now in Perplexity Computer and the Agent API. This upgrade could solve a glaring issue with current AI search. A recent study found that popular search agents often cheat on benchmarks like BrowseComp.
Why this matters
Perplexity’s “Search as Code” shifts the search step from a static API call to a dynamically generated Python workflow, letting models assemble their own pipelines. In theory this should tighten relevance and cut token consumption, a claim that aligns with the company’s self‑reported benchmarks showing a “massive leap” over its previous architecture. Yet we must treat those numbers with caution; the quote itself warns that such benchmarks deserve a grain of salt.
For developers, the ability to script search logic could reduce the need to stitch together third‑party services, but it also introduces new responsibilities around code safety and maintenance. Founders may see a path to differentiate products through tighter integration of model and execution layer, though it remains unclear whether the promised token savings translate into measurable cost benefits at scale. Researchers gain a concrete example of code becoming the operational interface for AI, echoing a broader move toward hybrid model‑code systems.
Whether this approach will become a staple or a niche experiment is still an open question.
Further Reading
- Rethinking Search as Code Generation - Perplexity Research
- Evaluating Deep Research Performance in the Wild with the DRACO Benchmark - Perplexity Research
- Best Practices - Perplexity API
- How Perplexity AI Answers Work: Retrieval, Ranking, and Citation ... - ZipTie
- What is Perplexity AI? How to use it + how it works - Zapier