Perplexity's new "Search as Code" architecture dumps rigid search APIs and lets AI models write their own search routines in Python. By letting the agent handle its own filtering and deduplication inside a sandbox, the system beats OpenAI and Anthropic on key benchmarks, while cutting token costs by up to 85 percent.