Models & Research

Perplexity’s “Search as Code” lets AI models write their own search pipelines instead of calling fixed APIs

· June 7, 2026
Perplexity’s “Search as Code” lets AI models write their own search pipelines instead of calling fixed APIs

What changed

Perplexity introduced a new “Search as Code” architecture that replaces fixed search APIs with AI models writing their own search routines in Python. Instead of calling rigid external APIs for queries, the AI agent constructs, filters, and deduplicates search pipelines internally inside a sandboxed environment. This gives the model full control over how it accesses and processes search results.

Why builders should care

This shift allows for custom search workflows that are dynamic rather than limited to predefined API responses. By embedding filtering and deduplication logic in code the model writes, it reduces irrelevant or duplicated tokens, lowering token consumption by up to 85 percent. It also improves key benchmarks compared to OpenAI and Anthropic’s fixed API approaches, suggesting more efficient and precise information retrieval.

The practical takeaway

Developers building AI search or agent workflows can benefit from this move by gaining fine-grained control over querying and post-processing steps. Running search logic in Python within a secure sandbox means better adaptability and cost efficiency. This approach can reduce reliance on costly token-heavy API calls and make search-based agents faster and cheaper to operate.

What to watch next

It will be important to see if other AI service providers adopt similar flexible, code-driven search methods. Watch for how this approach integrates with different AI models and its impact on operational costs in production. Also track security and reliability outcomes from running dynamic agent-generated code versus static API calls in live environments.

AI Quick Briefs Editorial Desk

Stay ahead of AI Get the most important AI news delivered to your inbox — free.