
Image: Perplexity
Why it mattersA long research task now needs fewer paid round-trips to the model. Teams can cut the bill by letting the model write the plan as code.
A research agent can make dozens of tool calls before it answers. Each call pulls a full page of data back into the model. The model is then paid to read that page again on the next step. Perplexity added Code Mode to its Agent API. The model now writes one short script. The script calls many tools at once. It keeps the raw data out of the model's view. Only the final answer comes back.
Perplexity calls the old shape "standard tool calling". It says the shape "forces a full model round-trip after every search, fetch, or API call". The raw pages come back into the context window each time. Code Mode is the replacement. The model writes JavaScript. The script calls a typed interface for the tools the agent already has.
What the script can call
The typed interface is tools.*. Perplexity lists the tools it covers. web_search, fetch_url, people_search, finance_search, MCP servers, and any sandbox file or shell tools the caller turns on. A script can run many of these at once. It waits for them with exec_wait. The raw results stay out of the model's view.
The runtime is QuickJS compiled to WebAssembly. Perplexity runs the script in the agent loop itself. No Linux container starts. That is the change from an earlier feature called Search as Code.
The numbers Perplexity reports on WANDR
The results are Perplexity's own. They were measured on WANDR, a research benchmark Perplexity uses. Three effort settings:
- High with Code Mode: 47.7 percent, at $0.38 per task. Perplexity says that is 2.9 points above its baseline.
- Xhigh (Sol-6.2 with Code Mode): 80.5 percent, at $3.85 per task. Perplexity says the cost is 47 percent less than its 5 November xhigh setting.
- Ultra (Opus 5.5 plus three Sol-6.2 with Code Mode): 89.4 percent, at $10.30 per task. Perplexity says that is 53 percent less than its 5 November ultra setting.
Latency changed too. Perplexity says exec_wait cut the median task duration from 28.9 minutes to 25.3 minutes. The p95 fell from 97.3 minutes to 57.5 minutes. The longest run fell from 174.2 minutes to 75.6 minutes.
Every figure is Perplexity's own. No outside measurement is yet available. Perplexity does not say how many tasks sit in WANDR, or which model wrote each one.
Where it fits
Code Mode is on by default in the high, xhigh and ultra effort levels of the Agent API. A team already paying for one of those levels gets the lower cost with no code change.
Code Mode is now one of several products called the same thing. Anthropic put a Code Mode in Claude Code last month. It runs tool calls as JavaScript against TypeScript definitions. Earendil wrote one for Pi. Perplexity's runs inside QuickJS on WebAssembly, not inside a container. The three systems answer the same cost problem in the same shape, with different runtimes.
A team building a research agent on Perplexity's Agent API now pays less per answer. A step that would have been three calls to the model is one script. The saving is on Perplexity's own benchmark. Test it on your own tasks before trusting the headline number.
Source
Introducing Code Mode in the Agent API, Perplexity.
This item was written by an AI system from the linked source. Reveneau is responsible for what it publishes.
Get AI News in your inbox
New developer tools, model and agent releases, and how teams are actually using them to release software. Short, and only when there is something worth reading.

