Perplexity Code Mode lets an Agent API model write JavaScript programs that call enabled tools, run calls in parallel and return selected output to the model. Coverage reported that Perplexity presented the feature on December 2, 2026. Perplexity’s documentation describes how the programmatic calls work and how developers configure access.
For an agent that needs several tool results, Code Mode lets you coordinate calls in one JavaScript program and return only the output the model needs.
What Code Mode changes in Agent API
Code Mode moves tool orchestration into a JavaScript program written by the model. The program can call enabled tools with await tools.<name>(args), run calls concurrently with Promise.all, use one result to shape another call and filter what it returns. Perplexity runs the program and sends its output back to the model.
That gives developers a way to group tool work and select the results the model receives. The program can return chosen content with text(value). Code Mode does not give the program unrestricted access to outside data: external information must come through tools enabled for the request.
How developers configure tool access
A custom POST /v1/agent request needs a {"type":"programmatic_tool_calling"} object in its tools array. Each tool the program should be able to call must include programmatic in allowed_callers.
The caller setting determines the available route: programmatic allows program calls, direct allows direct calls, and direct together with programmatic permits both. Perplexity’s documentation names xhigh and ultra as effort levels that enable Code Mode. The December 2026 changelog specifies the versions xhigh@2026-12-01.0 and ultra@2026-12-01.0.
What Perplexity reported from WANDR
WANDR is Perplexity’s 500-task benchmark for research agents, described in its benchmark overview. Results attributed to Perplexity covered the first 100 tasks. The reported soft-recall scores and average costs per task were:
| Effort | Model configuration | Code Mode | Soft recall | Average cost per task |
| xhigh | Sol-6.2 | No | 78.7% | $5.57 |
| xhigh | Sol-6.2 | Yes | 80.5% | $3.85 |
| ultra | Opus 5.5 + three Sol-6.2 instances | No | 88.5% | $12.12 |
| ultra | Opus 5.5 + three Sol-6.2 instances | Yes | 89.4% | $10.30 |
The listed xhigh costs work out to a 30.9% decrease, from $5.57 to $3.85 per task; soft recall rose by 1.8 percentage points. That calculation differs from the roughly 15% reduction also described for the xhigh comparison. For ultra, $12.12 to $10.30 is a 15.0% decrease, alongside a 0.9-point increase in soft recall.
The reported “up to 53%” reduction uses a different baseline: $10.30 for the ultra configuration with Code Mode versus $21.71 for the listed November 5 preset, a 52.6% decrease. The WANDR costs are benchmark averages per task, not a subscription price.
Perplexity also reported paired WANDR runs at the same spend with median duration moving from 28.9 to 25.3 minutes, the 95th-percentile duration from 97.3 to 57.5 minutes, and the maximum from 174.2 to 75.6 minutes. These results describe the reported benchmark runs and configurations.
Runtime limits developers should know
Code Mode programs cannot import modules or access process or fetch. Variables do not carry over to the next program, and external data has to come through enabled tools. These boundaries shape what a program can do within a single execution.
For a programmatic-only MCP tool that requires approval, set defer_loading to true; otherwise, the approval request returns HTTP 400, according to Perplexity’s documentation. Published accounts also describe exec returning partial output after 10 seconds while the program continues running in the background.