Perplexity's "Search as Code" lets AI models write their own search pipelines instead of calling fixed APIs

Perplexity AI Lets Models Write Their Own Search Pipelines

Perplexity AI has introduced a new feature called Search as Code. It enables large language models to dynamically generate their own search pipelines instead of calling fixed, pre-defined APIs. This marks a shift from traditional retrieval-augmented generation (RAG) toward more flexible, model-driven information retrieval.

How Search as Code Works

Instead of relying on a static set of API calls, the AI model now writes and executes code to search the web, aggregate results, and return answers. The model can decide the search strategy, the query structure, and how to combine multiple sources. This approach gives the model real-time control over the search process.

The system operates in a sandboxed environment to ensure safety and prevent unintended side effects. Perplexity’s feature essentially treats search as a programmable step within the model’s reasoning loop, not just a separate tool call.

Why It Matters

Traditional RAG systems use fixed API endpoints that limit how models can probe the internet. With Search as Code, the model can adapt its search strategy on the fly. For example, it can break a complex question into multiple searches, then combine results intelligently.

“This approach allows the model to adapt its search strategy on the fly, rather than being limited to a predefined set of API endpoints.”

This flexibility could improve accuracy for nuanced queries that require iterative refinement. It also reduces the engineering overhead of manually crafting search pipelines for every use case.

Potential Use Cases

  • Complex research queries – The model can break down a multi-part question into several focused searches, then synthesize findings.
  • Real-time fact-checking – Instead of a single API call, the model can verify claims by dynamically adjusting its search logic.
  • Domain-specific searches – The model can rewrite queries to match specialized terminology or data sources without human intervention.
  • Iterative exploration – The model can refine its search based on intermediate results, much like a human researcher.

Limitations and Concerns

Search as Code introduces new risks. The model may generate inefficient or even malicious search patterns if not properly constrained. Perplexity has implemented safety measures, but any system that allows AI to write and execute code raises questions about security and resource abuse.

Additionally, the quality of results still depends on the underlying search infrastructure and the model’s ability to write correct code. If the model misinterprets the task, the search pipeline could produce irrelevant or misleading answers.

There is also a cost consideration. Generating and executing code for each query increases compute and API usage, potentially raising operational expenses compared to fixed API calls.

The Bigger Picture

Search as Code reflects a broader trend: giving LLMs more autonomy over the tools they use. Rather than treating search as a black box, this approach lets the model reason about how to best gather information. It could become a template for future AI systems that build their own data pipelines on demand.

Perplexity’s move also pressures other search and AI companies to rethink how they integrate real-time web data with generative models. The debate between fixed RAG systems and dynamic, code-driven search is only beginning.

What are your thoughts on this? I’d love to hear about your own experiences in the comments below.

Gnoppix is the leading open-source AI Linux distribution and service provider. Since implementing AI in 2022, it has offered a fast, powerful, secure, and privacy-respecting open-source OS with both local and remote AI capabilities. The local AI operates offline, ensuring no data ever leaves your computer. Based on Debian Linux, Gnoppix is available with numerous privacy- and anonymity-enabled services free of charge.