← Back

AI writes Python on the fly to search 7x cheaper: Perplexity unleashes Search as Code.

Original version · Jun 4, 1:00

This is actually wild. Instead of just googling things like a basic bot, AI is now writing its own code to search the web, filtering out the garbage before it even reads it. It sounds like sci-fi, but it’s already live, and it’s insanely clever.

The new architecture is called Search as Code, and it is already running in Perplexity's Agent API and its Computer feature. Instead of treating the search engine as a rigid black box that spits out a wall of text, the AI writes a custom Python script to orchestrate the search process step-by-step. It is like hiring a researcher who, instead of googling manually, builds a mini-software tool to scrape, sort, and clean the data before presenting it.

This custom script utilizes the Agentic Search SDK, a toolbox of simple commands that can find documents, sort them by relevance, and fire off dozens of parallel queries in an instant. The entire process runs in a secure, isolated sandbox, allowing the AI to safely execute its own code without accidentally blowing up the servers.

For simple, one-off searches, this whole setup is a massive over-engineering disaster. But for complex research tasks requiring thousands of queries, the code manages the chaos by filtering out the noise and feeding the main AI model a clean, highly condensed summary. In one benchmark test, this approach slashed token consumption from 288.7 thousand to just 42.9 thousand while maintaining perfect accuracy.

To prove this isn't just marketing hype, Perplexity ran tests against OpenAI, Anthropic, Exa, and Parallel. Using a high-reasoning GPT-5.5 under the hood, their system outperformed competitors on four out of five industry benchmarks, showing the biggest leap in complex computer-agent simulation tasks where it beat the closest rival by 2.5 times.

The tech world is looking at a fundamental shift in how software is designed. Instead of humans hardcoding APIs for AI to use, the AI is now generating its own custom-tailored code primitives on the fly to solve problems. It seems the future of programming isn't about writing code for humans to use, but about AI writing code for other AI to consume, leaving human developers to wonder if they should start learning carpentry.

Source: Perplexity Research

Comments

This is where the magic happens: AI reads your discussion and rewrites the article based on the most interesting comments. Each strong comment adds points to the meter below. Once the meter is full, the article updates live — no page reload needed.

0/24
  1. No comments yet.