---
title: "Perplexity's Search as Code Beats OpenAI and Anthropic by 2.5x on Research"
subtitle: "Perplexity replaces tool-calling with Python codegen against atomized search primitives, hitting state-of-the-art on five agent benchmarks at lower cost."
url: "https://alphasignal.ai/news/perplexity-s-search-as-code-beats-openai-and-anthropic-by-2-5x-on-research"
author: "AlphaSignal Newsroom"
author_url: "https://alphasignal.ai/editorial-team"
company: "Perplexity"
company_url: "https://alphasignal.ai/company/perplexity_ai"
published: "2026-06-01T17:53:11.000Z"
updated: "2026-06-04T22:54:45.528Z"
type: "News"
topics:
  - "Agents"
  - "Api"
subtopics:
  - "Deep Research"
  - "Tool Use"
  - "Agent Frameworks"
upvotes: 2323
read_time: "6 min"
source_url: "https://research.perplexity.ai/articles/rethinking-search-as-code-generation"
comments: 0
---

# Perplexity's Search as Code Beats OpenAI and Anthropic by 2.5x on Research

> Perplexity replaces tool-calling with Python codegen against atomized search primitives, hitting state-of-the-art on five agent benchmarks at lower cost.

Perplexity is reworking how its agents talk to a search engine. Instead of having models issue one function call at a time and wait for results, [Search as Code (SaC)](https://research.perplexity.ai/articles/rethinking-search-as-code-generation) lets the model write Python that drives Perplexity's search stack directly inside a sandbox. The architecture is live in the Perplexity Agent API and is now the default search method inside Computer, the company's agent product.

CEO Aravind Srinivas described the shift as moving toward "search as codegen," a model designed for a future in which code execution plays a central role in knowledge-based work. In practice that means a single inference turn can fan out thousands of search operations, dedupe and rank them, and only surface the distilled signal to the model's context window.

## Why tool calls were the bottleneck

Traditional search APIs were built for humans typing a query and scanning ten blue links. When LLMs became consumers of the same APIs, they inherited the same monolithic contract: send a query, get back a ranked resultset. Perplexity argues this contract breaks down in agent workloads, where today's most advanced AI systems, built atop code-first harnesses, can compose task-specific workflows that execute thousands of actions each minute.

The team identifies three recurring failure modes in the function-calling and MCP eras. Pipelines return coarse context that floods the window with noise when the agent needed a single surgical fact. Models can't apply domain knowledge they have about how to search, because rigid query parameters give them nowhere to encode it. And inherently parallel workflows get serialized through model turns, polluting context with intermediate state and burning tokens on every roundtrip.

![Diagram of traditional search forcing sequential tool calls across model turns](https://framerusercontent.com/images/vsuNSVMfWSneCWfczUleMlnHCmk.png)

## The three layers underneath SaC

SaC is built on a stack of three tightly coupled components. Models act as the control plane, decomposing the user's directive into tasks and emitting Python code. [Compute sandboxes](https://docs.perplexity.ai/docs/agent-api/tools/sandbox) execute that code in isolated containers, providing deterministic compute for batching, retries, filtering, joins, and aggregation. And an Agentic Search SDK exposes Perplexity's search stack as composable primitives, embedded inside the sandbox runtime.

Importantly, the SDK is not a thin wrapper around the existing search API. Unlike a language's standard library, a custom-built SDK is unlikely to be represented in pretraining data, and many models are still trained to interact with search systems through function calls and direct MCP invocation. Perplexity addressed this by writing tightly tuned Agent Skills that teach models how to compose the primitives, capped at under 2000 tokens in their root SKILL.md to avoid context bloat. Both the SDK and the Skills are then refined through an autoresearch loop that proposes and validates changes against codegen quality, latency, and task performance.

For cross-turn state, Perplexity tested two approaches: a persistent filesystem with explicit serialize/deserialize steps, and a REPL that keeps variables alive across turns. Filesystem-based serde won on long trajectories, with the team conjecturing that forcing models to convey state declaratively helps them track what's actually persisted.

## What the numbers say

Perplexity benchmarked SaC against OpenAI Responses, Anthropic Managed Agents, Exa Agent, and Parallel Tasks across five tasks. SaC is using GPT 5.5 with high reasoning under the hood, while Anthropic runs on Opus 4.7.

![Benchmark scores comparing Perplexity SaC against OpenAI, Anthropic, Exa, and Parallel across five tasks](https://framerusercontent.com/images/hIpF8Cv3YwGB2GyMzVcJqwlDhE.png)

| Benchmark | Perplexity SaC | OpenAI | Anthropic | Exa | Parallel |
| --- | --- | --- | --- | --- | --- |
| DSQA | 0.871 | 0.733 | 0.815 | 0.530 | 0.810 |
| BrowseComp | 0.805 | 0.720 | 0.598 | 0.380 | 0.560 |
| HLE | 0.612 | 0.614 | 0.566 | 0.387 | 0.515 |
| WideSearch | 0.651 | 0.522 | 0.590 | 0.471 | 0.584 |
| WANDR | 0.386 | 0.130 | 0.152 | 0.057 | 0.126 |

SaC tops four of the five benchmarks and ties with OpenAI on HLE. The gap is most extreme on WANDR, Perplexity's own in-house "wide research" benchmark that mirrors the long, horizontal research workloads Computer users actually run. There SaC scores 2.5x the next-best system, and the team notes the benchmark is far from saturated. WANDR is slated for public release in the coming weeks.

The cost story matters as much as the accuracy story. On DSQA, the low-reasoning SaC setting is cheaper than every competing system while still outperforming two of them, and the medium setting beats all non-SaC systems at under $1 per task. Compared to a baseline Perplexity pipeline without SaC, the architecture adds 19.77 percentage points on DSQA and 12 points on WANDR.

## A concrete example: 200 CVE advisories

The clearest illustration is a case study in the writeup. The task: identify and characterize more than 200 high-severity CVEs from 2023 to 2025, citing the affected vendor's own advisory, naming the product and fix version, and proving the fix version is tied to the specific CVE. SaC scored 100% accuracy. Every non-Perplexity system tested scored below 25%. Token usage dropped 85.1%, from 288.7K to 42.9K.

The generated trajectory was a three-stage Python program. Stage one fans out site-scoped exact-phrase queries against vendor advisory formats (Mozilla MFSA pages, Jenkins security advisories, Chrome releases, Android bulletins). Stage two uses an LLM call as a planning subroutine to summarize coverage gaps and generate refinement queries. Stage three calls an SDK extractor to verify the CVE-to-fix-version binding against a strict schema:

```
verified = sdk.llm.extract_many(
    items,
    instruction="Keep only vendor advisories where the page ties "
                "a high or critical CVE to a specific fixed version.",
    schema={"cve": str, "vendor": str, "product": str,
            "fix_version": str, "version_bound_to_cve": bool,
            "confidence": float},
)
records = [to_cve_record(x) for x in verified
           if x.matches and x.version_bound_to_cve
           and high_or_critical(x.severity) and x.confidence > 0.75]
```

## How to use it and what it costs

Developers turn it on by adding `{"type": "sandbox"}` to the tools array on an Agent API request. Pricing has three axes: model tokens billed at the standard per-model rate, $0.03 per sandbox session (covering up to 20 minutes of active use as the billing window), and any web search, fetch URL, or people search tools invoked from inside the sandbox at their normal per-call rates. Long-running jobs can be submitted with `background: true` and polled by response ID.

The honest limitations are worth flagging. WANDR remains hard even for SaC at 0.386, so the wide-research frontier is still open. The SDK is custom enough that it doesn't appear in pretraining data, which is why Perplexity had to write dedicated Skills to coach models on idiomatic usage. And the whole approach depends on a model strong enough to write correct orchestration code; weaker models will struggle to wield primitives this fine-grained.

## The bigger argument

Search as Code is a bet that the right interface between LLMs and infrastructure is code, not function schemas. Anthropic has been pushing a similar argument with code execution over MCP, and OpenAI exposes code\_interpreter alongside web\_search in its Responses API. What's different here is that Perplexity rearchitected the underlying search stack into atomic primitives, rather than just dropping a search SDK into a Python shell. If models keep getting better at code, the systems that expose their internals as callable primitives, rather than locking them behind opinionated endpoints, are the ones that will scale with model capability.

## Sources

- [X post by @perplexity_ai](https://x.com/perplexity_ai/status/2061506359326384319)
- [Rethinking Search as Code Generation](https://research.perplexity.ai/articles/rethinking-search-as-code-generation)
- [Sandbox - Perplexity Agent API Docs](https://docs.perplexity.ai/docs/agent-api/tools/sandbox)
- [Perplexity launches Search as Code for AI agents](https://www.storyboard18.com/digital/perplexity-launches-search-as-code-for-ai-agents-ceo-aravind-srinivas-explains-why-99994.htm)
- [Perplexity Search as Code: letting models run the search](https://seifert.substack.com/p/perplexity-search-as-code-letting)
