Perplexity has released Search as Code, a new architecture that fundamentally changes how AI agents interact with search. Rather than making sequential API calls one at a time, the system generates Python code that orchestrates multiple search operations simultaneously.
The approach is now available in the Perplexity Agent API and has become the default in Computer, Perplexity's browser-integrated research tool.
Traditional Tool Calling Hits a Wall
Most AI agents today use function calling: they request a search, wait for results, analyze them, then decide whether to search again. Each step adds latency. Perplexity argues this creates three problems: high round-trip delays, rigid control flow dictated by the model rather than optimized execution, and context pollution as intermediate results clog the model's working memory.
Search as Code solves this by treating search like a programming problem. The model writes Python that calls Perplexity's search stack directly, composing primitives like fan-out queries, deduplication, filtering, and ranking. Results are processed before they reach the model's context window, keeping it clean and focused.
The company tested the architecture across five research benchmarks. On DSQA, a deep research dataset, Search as Code scored 0.871 compared to Anthropic's 0.815, while costing nearly half as much per task. On WideSearch, it led on accuracy while maintaining lower costs. BrowseComp and HLE showed similar gains.
WANDR, Perplexity's internal benchmark designed to mirror real professional research workflows, showed the starkest difference. Search as Code scored 0.386 against the next-best system's 0.152. The benchmark will be released publicly in the coming weeks.
What This Means for Developers
Developers using the Perplexity Agent API can now build agents that handle multi-step research without manually orchestrating each query. The architecture handles concurrency, result merging, and filtering automatically.
This matters for workflows where speed and cost both constrain what's possible: competitive intelligence, due diligence, academic literature reviews, or any task requiring dozens of related queries that need to be synthesized.
Perplexity has been steadily expanding Computer's capabilities over recent months, integrating Deep Research with the same architecture and adding models like Claude Fable 5 as orchestrator options.
The shift from tool calling to generated code mirrors what other AI platforms are exploring. Replit, Cursor, and Windsurf all generate code to accomplish tasks rather than relying purely on API orchestration. Search as Code extends that pattern to information retrieval.
Cost-Performance Trade-Offs
Perplexity's benchmarks emphasize cost alongside accuracy, a priority for businesses evaluating agentic search. Cutting per-task costs in half while improving scores changes the economics of automating research.
The architecture is documented in the Perplexity Agent API documentation, with examples showing how to construct multi-step queries, handle parallelism, and filter results programmatically.
Sources
1 checkedHow we cover tool news: Create With's tool desk drafts these reports with AI from the sources listed above and checks them against those sources before publishing.





