Search as Code: Perplexity rewrites AI search
- From fixed API to programmer agent: a paradigm shift
- Inside the architecture: how the Python sandbox works
- Real-world use cases for Italian SMEs
- Comparing OpenAI and Anthropic: where the difference lies
- Trade-offs and risks to consider
- Work still in progress: what's missing for enterprise adoption
- Our recommendation: how to find your bearings today
Perplexity has unveiled an architecture called Search as Code. In essence, AI agents no longer call fixed APIs to find information. Instead, they write their own search routines in Python, inside a controlled sandbox environment. The result is striking: token costs drop by up to 85% compared with comparable solutions from OpenAI and Anthropic.
So this isn't news only for researchers or engineering teams. It matters to any SME considering AI agents in its processes. Lower token costs mean cheaper, more scalable and more customizable pipelines. The system also beats the leading industry benchmarks, which points to a concrete, measurable competitive edge.
At SHM Studio, we follow these developments closely to assess what they mean in practice for Italian B2B and retail companies. In this article, we look at the architecture of Search as Code, the most relevant use cases for SMEs and the trade-offs to weigh before bringing this technology into your digital workflows.
From fixed API to programmer agent: a paradigm shift
For years, AI-based search systems followed a rigid pattern. A language model received a query, called a predefined search API and returned the results. The process was linear, but also limited. Fixed APIs can't adapt dynamically to the complexity of a request. As a result, the model had to work with standardized outputs, often redundant or off-target.
Perplexity has flipped this logic with Search as Code. In this new paradigm, the AI agent doesn't call an external API. Instead, it writes the Python code needed to build its own search pipeline. The model decides on its own how to filter data, remove duplicates and aggregate sources. It all happens inside an isolated, controlled sandbox environment.
This approach is close to the logic of tool-use agents, but it goes further. Rather than using predefined tools, the agent becomes the author of its own tools. In short, it's a qualitative leap in the reasoning ability and autonomy of language models applied to search.
Inside the architecture: how the Python sandbox works
At the heart of Search as Code is a secure execution environment. The AI agent generates Python code that runs in a sandbox with controlled access to external resources. This lets the system query diverse sources, apply custom filtering logic and deduplicate results before passing them back to the main model.
According to The Decoder, the system cuts token consumption by up to 85% compared with equivalent OpenAI and Anthropic architectures. That's a significant figure. Token costs are one of the biggest expenses for anyone running AI pipelines at scale.
The system also outperforms the sector's reference benchmarks. This suggests that the flexibility of a dynamically generated pipeline delivers better-quality results than static approaches. In particular, built-in deduplication reduces informational noise and improves the accuracy of the final answers.
To dig deeper into the architectural implications of autonomous AI agents, see Gartner's analysis of how AI agents are evolving and the research by MIT Technology Review on emerging architectures.
Real-World Use Cases for Italian SMEs
The most relevant question for an Italian SME isn't technical. It's operational: does this technology change anything in my processes today? The answer depends on the industry and on the company's digital maturity.
In B2B retail, for example, a Search as Code agent could build fully automated pipelines to monitor supplier prices and availability. Instead of relying on rigid scrapers or costly commercial APIs, the agent writes its own data-collection code. The system then adapts dynamically to changes in sources, with no manual intervention.
In digital marketing, the applications are just as interesting. An agent could build research pipelines for competitive analysis, aggregating data from different sources with custom filtering logic. At SHM Studio, we see this approach as a natural evolution of artificial intelligence applied to marketing tools.
In professional services, custom search pipelines can also support due diligence, regulatory monitoring and market analysis. The value isn't just in cost savings, but in the quality and relevance of the information collected.
For companies weighing how to integrate these capabilities, the starting point is often a review of their digital marketing strategy and existing information flows.
Comparing OpenAI and Anthropic: where the difference lies
OpenAI and Anthropic offer agentic search solutions through tools like function calling and tool use. However, these approaches remain tied to predefined patterns. The model chooses which tool to use, but can't change how it works internally.
Perplexity's Search as Code brings a higher level of flexibility. The agent doesn't pick from existing tools. It builds the tool best suited to the specific need. From an engineering standpoint, that difference is substantial.
On costs, the advantage is already quantified: up to an 85% reduction in token consumption. For a company handling large volumes of AI queries, that means real operating savings. Likewise, less informational noise improves output quality and lowers the cost of manually checking results.
Still, it's important not to overstate the comparison. OpenAI and Anthropic have more mature ecosystems, with established enterprise integrations. So the choice between platforms depends on each organization's specific context. For an in-depth look at competitive dynamics in AI, see Harvard Business Review's analysis of enterprise AI.
Trade-offs and risks to consider
Every innovative architecture comes with trade-offs, and Search as Code is no exception. The first critical issue is sandbox security. Letting an AI agent write and run Python code introduces security risks that need careful management. Perplexity says it has implemented robust controls, but the attack surface remains larger than with fixed APIs.
The second trade-off is reproducibility. A dynamically generated pipeline can produce different results on every run. That can be an advantage for adaptability, but it becomes a problem where outputs must be deterministic and auditable.
Operational complexity also grows. Running a system where code is generated and executed on the fly takes specific technical skills. For SMEs without a structured IT team, this can be a barrier to adoption. So it's essential to assess your own technological maturity before moving ahead with integration.
Finally, relying on a single vendor remains a strategic risk. Depending on Perplexity for a critical part of your information pipeline exposes your company to changes in pricing, policy or service availability. A balanced AI strategy always includes a contingency plan.
Work still in progress: what's missing for enterprise adoption
Search as Code is a promising technology, but it isn't yet mature enough for widespread enterprise adoption. Several aspects are still undefined. First, agent governance: who is responsible for AI-generated code? How do you manage the audit trail in regulated environments?
Second, there are no interoperability standards. Today, a pipeline built with Perplexity's Search as Code can't easily be ported to other systems. So companies that adopt this technology implicitly accept a degree of lock-in.
Even so, the direction is clear. The AI industry is moving toward increasingly autonomous agents that can build their own tools instead of using predefined ones. This shift will have far-reaching implications for automated advertising campaigns, for SEO and for content production.
Our recommendation: how to find your bearings today
For an Italian SME looking to evaluate Search as Code, we recommend a gradual approach. First, map your information flows and identify where rigid search pipelines create bottlenecks. Then, consider a pilot project built around a specific, low-risk use case.
In particular, companies that already use AI agents in their processes are best placed to experiment with this technology. If you're still in the early stages, it's wiser to shore up the fundamentals first: a solid web presence, a structured SEO strategy and optimized LinkedIn and Google Ads campaigns.
At SHM Studio, we follow the evolution of these technologies with an analytical eye. Our approach never changes: assess the real impact before recommending adoption. To explore how these innovations can fit into your company's digital strategy, our team is available through the contact page. You can also follow the key developments in AI and digital marketing on our blog.
Related articles
Discover more articles exploring similar topics, selected to offer you a more complete and stimulating perspective. Each piece of content is carefully chosen to enrich your experience.