Updated 1 hour ago
Perplexity Search as Code Lets AI Models Write Their Own Search Pipelines

Agentic Search API

Perplexity Search as Code Lets AI Models Write Their Own Search Pipelines

Perplexity has launched Search as Code, a new architecture that lets AI models write their own search pipelines in Python instead of calling fixed APIs. The approach cuts token usage by 85% and outperforms OpenAI and Anthropic on research benchmarks.

Why Fixed Search APIs Are Breaking AI Agents

AI agents have a search problem. The standard loop — model writes a query, search API returns results, model reads them, model writes another query — was designed for humans, not for autonomous systems doing hundreds of rapid searches. Context windows get stuffed with junk because the filtering logic is locked inside the search engine. The model can tweak the query but cannot control how results are ranked, deduplicated, or filtered.

Perplexity's answer, announced on June 6, is Search as Code (SaC) — an architecture where AI models write their own search pipelines as Python code and execute them in a sandbox. As 1 put it: "Instead of calling a ready‑made search API, models in Perplexity's new Search as Code architecture write their own search workflows as Python code."

How Search as Code Works

The architecture has three layers, described in detail in Perplexity's research paper:

  • Model (Control Plane) The AI reasons about the task, decomposes it, and generates Python code that assembles a custom search pipeline. It decides strategy — not just which keywords to use, but how to combine retrieval, filtering, and ranking.
  • Compute Sandbox A secure execution environment with a persistent filesystem for cross‑turn state. Chosen over a REPL approach because explicit state handling via serialization improves reliability on long research trajectories.
  • Agentic Search SDK Breaks Perplexity's search backend into atomic primitives — retrieve, fanout, filter, dedupe, rerank, parse_field — that the generated code can freely combine. No retrieval operation is dispatched through function calling; everything is code‑driven.

The Numbers — 85% Fewer Tokens, 4x Competitor Accuracy

In a case study tracking down 200 high‑severity CVEs (2023‑2025) with vendor‑specific advisory formats, Perplexity reported that SaC achieved 100% accuracy while consuming 42,900 tokens — an 85% reduction from the 288,700 tokens used by Perplexity's own standard pipeline. Competing systems scored below 25% on the same task.

Across benchmarks, Perplexity claims SaC outperformed 1 on 4 out of 5 tests. The largest improvement came on the WANDR broad‑research benchmark, where SaC showed a 45% absolute gain over Perplexity's own baseline. On DSQA, the gain was 29%.

Code Is the New Interface Layer

Search as Code reflects a broader shift in how AI agents interact with infrastructure. As Perplexity's research team wrote: "Code is a powerful medium for orchestrating preexisting capabilities — it can also serve as a gap‑filler for capabilities that aren't present in the search stack or SDK."

Rather than the model being limited to the parameters a search API exposes, SaC gives it access to the same primitives a human engineer would use to build a search pipeline — then lets it compose them programmatically. As The Decoder noted, the emerging paradigm combines models for strategy with deterministic runtimes for batching and filtering, with search infrastructure becoming an I/O layer rather than a black box.

What This Means for Builders

Search as Code is rolling out now in Perplexity Computer, the company's agentic AI platform. For developers building AI agents that need to do complex research — gathering data across hundreds of sources, verifying facts, compiling reports — SaC represents a fundamentally different approach from the "one query, one response" model that dominates current search APIs.

The implications are significant. If models can write their own search pipelines, the bottleneck shifts from can the API return the right results to can the model design an effective search strategy That favors frontier models with strong reasoning and code‑generation capabilities — and puts pressure on search API providers to expose their internals as programmable primitives rather than black‑box endpoints. Perplexity's SDK‑based approach may become the template for how search infrastructure is packaged for the agentic era.

Sources

  1. 1.The Decoder(the-decoder.com)

Share this article

PostShare

More on This Story

Related News