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.The Decoder(the-decoder.com)
Jul 16, 2026
The Modern Job Search Has Changed. Here's What It Takes to Compete.
Jul 14, 2026
Why Your AI Translation Still Doesn't Sound Right?
Jul 6, 2026
Best Ways to create videos at Scale with Pollo AI Apps
Most content teams don't have a creativity problem. They have a production problem. The ideas are there. The briefs are written. The strategy is clear. What's missing is a reliable way to turn one good idea into enough video output to fill a content calendar — without burning out a designer or blowing through an editing budget. The answer isn't working harder. It's working with a system.
Related News
Jun 18, 2026
Elastic Agent Memory Demo Shows Why Long Context Is Not Enough
Elastic published an open-source agent memory demo that turns long-running AI context into a search and retrieval architecture problem.
Jun 17, 2026
SpaceX Acquires Cursor for $60 Billion in First Post-IPO Power Move
SpaceX is buying AI coding startup Cursor for $60 billion in an all-stock deal, its first major acquisition since going public. The deal gives Elon Musk's company access to Cursor's 1 million-plus developers and a foothold in the fast-growing AI coding tools market.
Jun 15, 2026
OpenAI Acquires Ona to Add Persistent Cloud Execution to Codex
OpenAI has agreed to acquire Ona, bringing persistent cloud execution environments to Codex so developers can run AI agents that continue working for hours or days without being tied to a single machine.