Perplexity has unveiled a new search architecture called 'Search as Code' that lets AI models write their own search pipelines as Python code instead of relying on fixed APIs. The company says this approach delivers more accurate results while using fewer tokens.
Current AI agents face a bottleneck when tackling complex research tasks. The model writes a query, a search API returns a list of results, the model reads them, then writes the next query. This loop repeats many times. Perplexity argues that today's search engines were designed for humans who want a list of blue links, not for AI agents that need to run hundreds of searches in a few minutes. The agent can only adjust the search term; everything else is a black box.
How Search as Code works
Search as Code changes that dynamic. Instead of calling an API, the model writes a custom Python script that runs in a secure sandbox and pulls from Perplexity's search backend. Basic operations like retrieving, filtering, deduplicating, and reranking are packaged as simple SDK functions.
The architecture has three layers. At the top sits the model, which understands the task and decides on a search strategy. In the middle is the sandbox where the code executes. At the bottom is the 'Agentic Search SDK,' which breaks Perplexity's search engine into individual, mix-and-match functions.
Standard search APIs remain available for simple queries. But for difficult research, the model can go deeper. It can fire off parallel queries, filter out noise programmatically, and pull only relevant hits into its context window.
Perplexity says this is where the real gain happens. Standard search pipelines fill an agent's context window with irrelevant data because the filtering logic is fixed. When the agent writes its own filters, the context stays lean, and the model maintains its bearings across long research sessions.
Real-world test on software vulnerabilities
To demonstrate the approach, Perplexity tested it on a messy cybersecurity task. An agent had to track down 200 critical software vulnerabilities (CVEs) published between 2023 and 2025. For each one, it needed to find the official vendor advisory, the affected software, and the exact version that patched the bug. News articles or blog posts weren't counted.
With Search as Code, the model wrote a three-stage script. It ran parallel searches tailored to how specific vendors like Mozilla or Google format their security bulletins. Then it scanned its own findings, spotted gaps, and ran targeted follow-up queries. Finally, it used a schema to verify that the CVE, product, and fix version all matched.
Stay updated
Get the day's AI and automation news in your inbox. No spam, unsubscribe anytime.
The result: the agent completed the task while using 85 percent fewer tokens than Perplexity's standard pipeline. Competing systems got less than a quarter of the data right.
Benchmark results and rollout
In Perplexity's own benchmarks, Search as Code beat rivals such as OpenAI's Responses API and Anthropic's Managed Agents on four out of five categories. The largest gap was on 'WANDR,' Perplexity's own benchmark for broad research tasks, which the company plans to release soon. On HLE, the system was virtually tied with OpenAI. Perplexity's self-reported results show a clear improvement over its own older architecture.
Search as Code is rolling out now in Perplexity Computer and the Agent API.
Code as the operational layer for AI
Perplexity frames Search as Code as part of a larger trend. Traditional software uses deterministic instructions. Frontier models add reasoning in token space. The most capable systems combine both: models for strategy, deterministic runtimes for batching and filtering, and search infrastructure as an I/O layer.
This upgrade could address a significant issue with current AI search. A recent study found that popular search agents often cheat on benchmarks like BrowseComp by pulling answers from training data instead of scanning the live web. When tested on a new benchmark with fresh facts, every system's score dropped by 25 to 40 points. All those systems used standard search tools.
A separate survey paper suggests that writing code is becoming the default way agents interact with the world. It describes code as a new operational layer for agents and argues that infrastructure for tools, sandboxes, and verification is the real bottleneck for autonomous systems.
Related on Neura Market
- AI Models Directory, Browse and compare AI models from top providers.
- Automation Marketplace, Find tools and services that automate search and data workflows.
- Search Tools Platform, Explore AI-powered search solutions for enterprise and research.

