Perplexity Ships Search as Code: Models Write Their Own Search Pipelines, 85% Fewer Tokens
Perplexity shipped Search as Code (SaC) on June 7, a developer API that replaces the standard search tool-call pattern with something structurally different: the model writes a Python script, the script runs in a sandbox, and the results come back already filtered, deduplicated, and ranked.
The architecture inverts the usual flow. Instead of a model issuing search("query") and getting back a ranked list of pages to handle, SaC exposes low-level primitives — retrieve, filter, deduplicate, rerank — as simple SDK functions the model can compose arbitrarily. The model orchestrates the search. The model decides when to fan out across multiple queries, how to merge results, and what to drop before it ever hits the context window.
Perplexity’s published demo tasked an agent with profiling a specific company’s recent financing activity — the kind of multi-source, multi-step research task where standard pipelines pollute context with irrelevant pages. SaC completed it while using 85% fewer tokens than the standard architecture. Competing systems retrieved less than a quarter of the relevant data.
Benchmark Positioning
Perplexity released a five-benchmark comparison against OpenAI’s Responses API and Anthropic’s Managed Agents:
- SaC leads on 4 of 5 categories
- The fifth (HLE, a general reasoning benchmark) is effectively tied with OpenAI
- The largest gap is on WANDR, Perplexity’s own benchmark for broad professional research tasks — which the company plans to release publicly
The self-reported benchmarks deserve the standard caveat: Perplexity designed the evaluation, Perplexity ran it, and WANDR is not yet independently replicable. The comparison against its own older architecture is the more credible signal. Improvements there are consistent across all five benchmarks.
What Changed at the Architecture Level
Traditional search tool-calling sends a query, receives pages, dumps them into context, and hopes the model figures out what to use. At scale, this is expensive: relevant signal gets buried in noise, and the model pays for every token whether it helps or not.
SaC moves the bookkeeping out of the context window and into the sandbox. By the time results reach the model, they have already been filtered, joined, and ranked by code the model wrote for this specific task. Context receives signal, not raw retrieval output.
The pattern mirrors what Perplexity Computer already does internally. SaC makes it available to external developers via the Agent API.
Separately: An Open Tokenizer
Perplexity also open-sourced a rebuilt Unigram tokenizer optimized for XLM-RoBERTa’s 250K-token vocabulary this week. Benchmarks show 5-6x lower CPU usage and roughly 5x lower p50 latency compared to the equivalent HuggingFace tokenizer. The release targets developers running high-volume reranking and embedding workloads where tokenization latency is a real cost line.
Deployment
Search as Code is live now in Perplexity Computer and available via the Agent API. No pricing details were disclosed beyond the existing Agent API rate structure.
The architecture bet is legible: if search is a commodity and model intelligence is a commodity, the differentiation lives in the plumbing between them. Perplexity is betting that letting models write their own plumbing produces better outcomes than any fixed API design can.