Learning resourcesReviewed · Perplexity

Perplexity Agent API Sandbox guide

Perplexity's Sandbox guide teaches developers to add code execution to AI agents, but container time is billed separately from model and tool use. It explains model-written Python and bash in network-enabled Linux containers, execution records, background requests and generated-file retrieval.

Researched 25 Nov 2026

In short.

Perplexity's Sandbox guide explains code execution for developers building AI agents, but container fees add to model and tool costs. It documents how the model writes and runs Python or bash, inspects output and uses results in its answer. Containers have network access and retain files and installed packages across executions within one response. Returned execution records expose the code, logs and exit status. Container time costs $0.03 per started 20-minute block; full request costs, numerical execution limits and data-retention terms are not established by this page. Nothing was executed, so correctness and performance remain untested.

Researched and written by an AI model and checked by a second AI model. How it works

Coverage is the complete selected documentation page at [https://docs.perplexity.ai/docs/agent-api/tools/sandbox.md], supplied as selected-page.txt. The connector preview notice is included. Linked pages covering models, pricing, rate limits, connectors, other tools and the full API schema are excluded, as is the documentation index. Their contents cannot establish additional prices, limits, compatibility or rights here. No code, API requests or file downloads were executed; documented behavior remains untested.

The overview

Identity

This is Perplexity's Sandbox documentation at [https://docs.perplexity.ai/docs/agent-api/tools/sandbox.md]. It teaches integration of the sandbox tool into Agent API requests, with Python, TypeScript and cURL examples.

The documented feature lets a model execute code in an isolated container during a request and incorporate the results into its answer. Developers enable the tool and provide a task; the model decides when to call it and writes the code.

Assessment

The guide provides a useful starting point for integrating computation into an AI agent. Its strongest practical details are the returned code and execution logs, the separation of message output from sandbox results, and the additional steps required to retrieve generated files.

It supports an initial integration design, but it does not establish production reliability, calculation accuracy or performance. The response examples illustrate the documented interface without independently validating its behavior.

Users

The guide suits developers building research agents, calculation assistants, data-cleaning workflows or systems that produce CSV, JSON and report files. It also addresses workflows that combine retrieved information with computation.

Beginners receive examples in three interfaces, but need to understand authenticated API requests, response objects and asynchronous polling. Developers requiring a particular hand-authored script should consider that this interface delegates code generation and execution decisions to the model.

Capabilities

Documented uses include numerical and statistical calculations, parsing and transforming data, checking code logic, reproducing errors, generating structured artifacts and maintaining intermediate files during multi-step work. Python handles computation and bash supports shell commands.

The container can access the internet and install packages at runtime. Its preinstalled Perplexity SDK can call Web Search, Fetch URL Content and People Search without those tools being separately added to the request.

With both sandbox and the GitHub connector enabled, the model can use git and gh to clone private repositories, edit and commit code, and create or update pull requests. Access is limited by the connected GitHub account's permissions. Connectors are explicitly in preview.

Using it

Requirements

Requests require authenticated Perplexity Agent API access. The cURL examples use a bearer token supplied through PERPLEXITY_API_KEY; the SDK examples use the Perplexity Python or TypeScript client.

The tools array must include an entry whose type is sandbox. For research combining sandbox and web_search with a direct model, the guide says to set max_steps to allow multiple steps; otherwise the default is one step.

The examples name openai/gpt-5.6-sol, but the page supplies no complete model-compatibility list or SDK version requirements. Repository operations additionally require the GitHub connector and a connected account with the necessary permissions.

Mechanism

According to the guide, the model writes code, executes it in an isolated Linux container and reads captured standard output and standard error. Multiple executions within one response share files and installed packages. Persistence across separate responses is not established.

The response output array contains sandbox_results items alongside message items. Each sandbox item identifies the call and container and includes language, executed code, overall status and a results array. Individual results expose stdout, stderr, exit_code, duration_ms and status.

A file written in the container becomes retrievable through the response files endpoints when it is delivered with share_file. Its contents are downloaded separately as raw bytes rather than returned inline in the response.

Setup

Create an authenticated request to [https://api.perplexity.ai/v1/agent], choose a model, supply the task in input and add {"type":"sandbox"} to tools. Instructions can specify how computation and verification should contribute to the answer. The research example also enables web_search and sets max_steps to 10.

For longer requests, set background to true and retrieve the response by its ID while its status is queued or in_progress. The documentation identifies completed, failed, cancelled and incomplete as terminal statuses.

Parse message text and sandbox execution records separately. For generated files, list the response's files and download each required file using both its file ID and the response ID.

Example

The guide's small background example asks the agent to create a CSV containing the first 10 Fibonacci numbers and their squares. It enables sandbox, submits the request with background enabled and polls the response until it leaves queued or in_progress.

To retrieve a generated artifact through the documented file interface, the file must be delivered with share_file. The Python retrieval examples use client.responses.files.list(response_id), followed by client.responses.files.content with the file and response IDs. These examples describe the integration pattern; no result for this task was independently executed or verified.

Assessment & evidence

Limitations

Each execution has a runtime cap, but its numerical duration is unspecified. Background mode is described for long-running requests without establishing that it removes the per-execution cap. Agent API rate limits apply, while tier-specific values are only linked.

Large stdout and stderr streams are truncated at approximately 1 MiB per stream. The guide recommends returning large results as files. CPU, memory, disk allocation, maximum artifact size and cross-response persistence are not specified.

An API response may complete despite a command error, so individual exit codes and stderr require inspection. Timeouts appear as timed_out; quota or limit failures return an error object.

The container is described as isolated and network-enabled, but the page does not detail isolation enforcement, data retention or configurable network restrictions. Connector behavior may change during preview.

Reasoning

Returning the executed code and command outputs gives developers a concrete basis for reviewing how an answer was produced. Shared files within a response also support workflows where later calculations depend on earlier results.

Those records do not establish that the model chose the right data, formula or interpretation. A completed status describes execution outcome, while answer correctness still depends on the generated program and its inputs.

Network access and built-in retrieval tools make combined research and computation plausible, but they also make usage costs depend on the steps the model takes. The container price alone is insufficient for estimating a complete workload.

Alternatives

The page names web_search as a companion tool and describes SDK access to search, URL fetching and people search. These provide information-retrieval capabilities alongside sandbox computation.

It provides no comparison with competing execution services or local code execution. Relative cost, speed, isolation and migration effort are therefore not assessed.

Evidence

The evidence is the complete Perplexity Sandbox page at [https://docs.perplexity.ai/docs/agent-api/tools/sandbox.md], supplied as selected-page.txt. It includes request examples, container behavior, connector support, background polling, error handling, response fields, file retrieval and pricing.

This is vendor documentation with illustrative code and response data. It contains no independent benchmarks or operational measurements. Linked documentation is outside the supplied evidence.

Access & freshness

Costs

The stated container price is $0.03 for each started 20-minute block, measured from container start through its last command. The 20-minute interval is a billing unit, not the execution runtime cap.

Model tokens are billed separately at model-specific rates. SDK web searches use a sandbox SDK search rate; Fetch URL Content and People Search calls use their respective tool rates. Numerical token and tool rates are absent from this page, so total request cost remains unknown.

The response reports sandbox invocation, duration_ms and cost_usd under usage.tool_calls_details.sandbox. SDK tool calls appear under their own usage keys, such as search_web and fetch_url.

Rights

The page supplies no explicit reuse license for its documentation or code examples. Permission to redistribute them cannot be established from this evidence.

Ownership and reuse terms for generated artifacts, applicable service terms and third-party content rights are also unspecified. The ability to download a file or access a repository does not establish those rights.

Freshness

The supplied page was captured on 2026-11-25 at 18:16:16.192 UTC. It gives no publication date, last-update date, SDK version or API release history, so its last substantive revision and compatibility over time are unknown.

The explicit preview notice applies to connectors and warns that supported services and behavior may change. Current prices and service behavior beyond the supplied capture are not established.

Actions

A first evaluation can use the documented small CSV task, inspect the returned code and per-execution status, and verify that any artifact can be listed and downloaded. Multi-step research needs an appropriate max_steps setting; long requests need background polling.

Before budgeting or production use, establish current model and tool rates, numerical execution and account limits, and data-handling terms. For repository work, confirm that the connected GitHub account permits the intended actions and that connector preview behavior suits the application.

Evidence for this report

selected-page.txtselected · checked 2026-11-25