AIToday

Perplexity's Search as Code lets AI models write custom search workflows

THE DECODERJun 7, 2026
Perplexity's Search as Code lets AI models write custom search workflows

Key takeaway

Perplexity has launched 'Search as Code,' an architecture that lets AI models write Python scripts to customize their own search workflows rather than rely on fixed APIs. Instead of repeatedly querying a rigid search engine, models can now filter, deduplicate, and rerank results directly. In a test tracking 200 critical software vulnerabilities, the approach used 85 percent fewer tokens while competitors retrieved far less accurate data.

Summaries like this, in your inbox every morning.

Sign up free →

3 Key Points

  • What happened

    Perplexity introduced 'Search as Code,' which lets AI models write Python scripts to run custom search pipelines instead of calling fixed search APIs. The model builds tailored workflows using basic search operations like filtering and reranking, all executed in a secure sandbox. The feature is now rolling out in Perplexity Computer and the Agent API.

  • Why it matters

    Traditional search APIs force AI agents into rigid loops—query, get results, read, repeat—wasting tokens on irrelevant data. By writing code to filter and deduplicate programmatically, models stay focused and use fewer tokens. In a real-world test tracking 200 critical software vulnerabilities, the system used 85 percent fewer tokens than the standard pipeline while competitors retrieved less than a quarter of the correct data.

  • What to watch

    Perplexity claims Search as Code led on four out of five internal benchmarks against OpenAI's Responses API and Anthropic's Managed Agents, with the largest gap on 'WANDR,' Perplexity's own broad research benchmark (to be released soon). The company frames this as part of a trend where frontier AI systems combine reasoning with deterministic code execution for stronger performance.

FAQ

How does Search as Code differ from traditional search APIs?
With traditional APIs, AI agents query, receive a list of results, read them, and write the next query in a rigid loop. Search as Code lets the model write a custom Python script that runs in a secure sandbox, using basic SDK functions to filter, deduplicate, and rerank results programmatically, keeping the context window lean and allowing parallel queries.
What real-world test did Perplexity use to demonstrate the benefit?
Perplexity tested it on tracking 200 critical software vulnerabilities (CVEs) published between 2023 and 2025, requiring the agent to find official vendor advisories, affected software, and patch versions. The model wrote a three-stage script with parallel searches tailored to vendor formats, followed targeted follow-up queries, and verified results against a schema, using 85 percent fewer tokens than the standard pipeline.
When and where is Search as Code available?
Search as Code is rolling out now in Perplexity Computer and the Agent API.

Get the latest AI Business & Industry news every morning

AI-summarized, only the topics you pick — one digest a day via Email, Slack, or Discord.

Free · takes 30 seconds · unsubscribe anytime

Discussion

No comments yet. Be the first to share your thoughts!

Log in to join the discussion

Related Articles

Stay ahead with AI news

Get curated AI news from 200+ sources delivered daily to your inbox. Free to use.

Get Started Free

Free · takes 30 seconds · unsubscribe anytime

1 minute a day. The AI essentials.

200+ sources · Email / LINE / Slack

Get it free →