Perplexity has introduced Search as Code (SaC), a new architecture that replaces static search API calls with AI-generated Python search workflows. Rather than querying a fixed endpoint and accepting whatever format comes back, an agent writes its own retrieval pipeline — deciding how to search, filter, deduplicate, and rerank for the specific task at hand. The system is live now in Perplexity Computer and the Agent API.

Why Fixed Search APIs Hit a Wall

Most AI search integrations today follow a simple pattern: the agent calls an endpoint, gets a ranked list of results, and works with whatever comes back. For straightforward questions, this works well enough. For complex research tasks, it breaks down quickly.

Consider collecting vulnerability data across 200 CVEs. Mozilla formats its security advisories one way. Google formats them another. Debian uses a third structure entirely. A single API call returns a mixed, inconsistent response that the agent then has to parse, reconcile, and fill in manually — burning tokens and losing accuracy in the process.

Perplexity's answer: let the model write the search code itself.

The Three-Layer Architecture

Search as Code is built on three components:

  1. The model — understands the task and decides on a search strategy
  2. A restricted sandbox — isolated execution environment where the generated Python code runs safely
  3. The Agentic Search SDK — exposes Perplexity's search infrastructure as composable functions: retrieve, filter, deduplicate, rerank

The model doesn't call a monolithic search function. It authors a pipeline from these building blocks, specific to the task. It can run parallel searches, inspect the results, identify gaps, issue follow-up queries, and verify its output against a schema — all in a single coherent workflow it constructed itself.

85% Token reduction vs. baseline (internal benchmark)
100% Accuracy on 200-CVE detection task (internal)
4/5 Benchmark categories claimed over competitors

The CVE Test Case

Perplexity's flagship demonstration involves collecting vendor security advisories for 200 software vulnerabilities (CVEs) published between 2023 and 2025. Here's what the two approaches looked like:

Standard pipeline: single search → mixed vendor formats → less than 25% of data correctly retrieved

Search as Code approach:

  1. Model writes a three-stage Python script
  2. Stage 1: Parallel searches tailored to how Mozilla, Google, Debian, and other vendors each format their advisories
  3. Stage 2: Scan results, identify gaps, issue targeted follow-up queries
  4. Stage 3: Apply a schema to verify CVE number, affected product, and patch version all align

Result (per Perplexity): 100% accuracy, 85.1% fewer tokens than the baseline pipeline.

These are compelling numbers. They are also self-reported, from a company benchmarking its own product against its own previous architecture. Independent validation is still needed before treating them as definitive.

For developers: SaC's biggest advantage is likely in structured multi-source aggregation — vulnerability collection, compliance monitoring, competitive intelligence, and literature review are all tasks where fixed API responses struggle. The code-as-pipeline model also gives you something valuable that standard search doesn't: the retrieval logic is explicit, debuggable, and version-controllable.
Benchmark caveat: All performance figures come from Perplexity's internal evaluations. The WANDR benchmark — Perplexity's planned test for broad research tasks — has not yet been released publicly. Compare against real workloads before committing.

Competitive Landscape

Solution Approach Key Characteristic
Perplexity SaC Code-generated pipelines Modular, sandboxed execution
OpenAI Responses API Fixed endpoint Stable, limited flexibility
Exa Semantic search High-quality results, less pipeline control
Tavily Agent-oriented API Developer-friendly, limited customization
Google AI Search Native integration Freshness advantage, closed ecosystem

Key Takeaways

  • Search as Code replaces fixed API calls with AI-generated Python retrieval pipelines built from composable SDK functions.
  • The three-layer architecture — model, sandbox, Agentic Search SDK — lets agents construct task-specific search workflows on demand.
  • Perplexity claims 85% token savings and 100% CVE detection accuracy, but these are internal benchmarks pending independent validation.
  • Available now in Perplexity Computer and the Agent API; the WANDR benchmark is forthcoming.
  • The approach introduces meta-tooling to search: agents don't just use tools, they author them.

What This Changes

Search as Code represents a subtle but significant shift in how we think about AI retrieval. The conventional model says: here is a search tool, use it. The SaC model says: here are search primitives, compose them into the tool you need.

If the token and accuracy claims hold up under independent testing, this approach has real implications for how AI agents handle research tasks. The bottleneck in many agentic workflows isn't reasoning — it's getting reliable information from the web efficiently. A 10x improvement in retrieval quality and cost, if repeatable, would compound significantly across multi-step tasks.

The deeper question is whether this pattern extends beyond Perplexity's own infrastructure. An open version of the Agentic Search SDK concept — where agents can write retrieval logic against any search backend — would be a meaningful primitive for the broader agentic ecosystem. For now, Perplexity holds the stack. Watching how competitors — Exa, Tavily, Google — respond will tell us whether code-first search becomes the new standard or remains a proprietary advantage.