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)
Jun 7, 2026
Anthropic Warns AI Industry Has No Brake Pedal as Claude Codes 80% of Its Own Codebase
Anthropic co-founder Jack Clark warns the AI industry is accelerating without a brake pedal, as Claude now writes over 80% of the company's code. The safety-focused lab is calling for a coordinated, verifiable pause mechanism before AI systems achieve full recursive self-improvement.
Jun 7, 2026
Trump Administration in Talks for Direct Government Stake in OpenAI
The Trump administration is negotiating a direct government equity stake in OpenAI, with President Trump calling it a potential partnership where the American public shares in AI wealth. Bernie Sanders proposes a competing 50% stock tax on AI giants. Both plans signal a historic shift toward public ownership of AI.
Related News
Jun 8, 2026
GitLab Cuts 14% of Staff in AI Pivot Despite Record 264 Million Revenue
GitLab is cutting 350 jobs and exiting 22 countries in a sweeping AI restructuring, even as the company reports $264 million in quarterly revenue with 23% growth. The move signals that even profitable dev-tool companies are reallocating resources toward AI-native features as agentic workloads reshape the developer landscape.
Jun 8, 2026
OpenAI Declares Chat Is Dead in Biggest ChatGPT Overhaul Ahead of IPO
OpenAI is transforming ChatGPT from a chatbot into a unified superapp that merges Codex, AI agents, and third-party services — the biggest product overhaul since launch. The pivot comes as Anthropic pulls ahead in enterprise revenue and both companies race toward IPOs later this year.
Jun 7, 2026
OpenAI's Lockdown Mode Locks Down ChatGPT Against Prompt Injection Attacks
OpenAI is rolling out Lockdown Mode to all ChatGPT users, an optional security setting that disables live web browsing, deep research, and agent mode to block prompt injection attacks that try to exfiltrate sensitive data. The move signals that connected AI agents are creating attack surfaces that even frontier labs are racing to contain.