Learning resourcesReviewed · Perplexity

Perplexity Agent API: Background Mode

Perplexity’s Background Mode guide teaches developers to run long AI agent tasks asynchronously, but applications must track each run and handle pauses, failures and connection recovery. It provides Python, TypeScript and cURL examples for submitting requests, retrieving results, resuming streams and cancelling work.

Researched 14 Nov 2026

In short.

Perplexity’s Background Mode guide is a practical reference for developers building long-running AI features, but reliable integration requires managing response IDs, status changes and reconnection limits. The page documents server-side execution that continues after a client disconnects, with examples for polling, streaming recovery and asynchronous cancellation. It also explains token-limit pauses and the one-step default for direct-model requests without an effort level or explicit step limit. No examples were executed; operational reliability, current model availability, costs and SDK compatibility remain unverified.

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

Coverage includes the complete selected page at [https://docs.perplexity.ai/docs/agent-api/background-mode.md]: overview, submission, polling, streaming and reconnection, cancellation, all examples, and the token-limit and reconnect-window notices. The documentation-index pointer and next-step links are present, but the index and all linked pages are outside scope; their contents were not assessed. No code, API behavior, billing or operational recovery was tested.

The overview

identity

This is Perplexity’s documentation for Background Mode in its Agent API, available at [https://docs.perplexity.ai/docs/agent-api/background-mode.md]. It teaches an API integration pattern for tasks such as extended research and sandbox work. The documented submission endpoint is POST [https://api.perplexity.ai/v1/agent].

assessment

The guide is useful when an application needs results from agent tasks that may take several minutes and cannot depend on one uninterrupted client connection. Its strongest practical detail is the handling of outcomes beyond successful completion, including token-limit pauses, incomplete responses and expired stream reconnect windows.

It supplies focused integration examples, but does not establish production reliability, research accuracy or deployment readiness. Authentication setup, pricing and broader service guarantees are not explained here.

users

The primary audience is developers integrating long-running AI research or sandbox tasks into an application. Backend developers can use the response ID to track work independently of the original connection; developers building live progress interfaces can use the streaming and reconnect instructions.

Beginners get examples in three languages or interfaces, but still need to understand authenticated HTTP requests, asynchronous execution, polling and application state.

capabilities

The documented feature can accept a background request, return a response ID immediately and continue execution after a client disconnects. Applications can retrieve status and output, stream events, resume a stream after a recorded event sequence number and request cancellation.

Examples include web_search and sandbox tools. These are task configurations shown alongside background execution; the page does not establish that either tool is required for Background Mode.

Using it

requirements

The HTTP examples require a Perplexity API key and use PERPLEXITY_API_KEY for bearer authentication. Python examples import Perplexity from perplexity, and the Python reconnect example also requires requests. TypeScript examples use @perplexity-ai/perplexity_ai. Shell examples use curl and jq.

Applications need to retain response IDs and, for resumable streams, the latest event sequence number. Required SDK versions, runtime versions, account eligibility and access to the illustrated model and tools are not specified.

mechanism

Set background=true when creating a response, then save its id. Retrieve it through GET [https://api.perplexity.ai/v1/agent/{id}]. queued and in_progress are non-terminal states. completed, failed, cancelled and incomplete are terminal states. A token-limit pause keeps the response in_progress with a paused object; the guide says to continue polling without resubmitting.

For streaming, also set stream=true. Retain sequence_number from streamed events, leaving the cursor unchanged for response.paused and response.resumed notices, which have no sequence number. Reconnect through [https://api.perplexity.ai/v1/agent/{id}?stream=true&starting_after=N]. An expired reconnect window returns 400; retrieve the response snapshot with a plain GET.

Cancellation uses POST [https://api.perplexity.ai/v1/agent/{id}/cancel]. A successful request returns 200 with status cancelling, so poll for terminal cancelled. Cancelling an already-terminal response returns 400; an unknown ID or a response belonging to another account returns 404.

setup

Choose an illustrated SDK or direct HTTP requests, configure authentication and submit the task with background=true. Save the returned ID before beginning status polling. Handle every terminal state explicitly, reading output only after successful completion and inspecting the error object when the request fails.

The multi-step research examples set max_steps=10. The page states that a direct-model request without an effort level otherwise gets one step, which is insufficient for multi-step research. The sample polling interval is two seconds; the page does not establish it as a required or optimal interval.

example

The battery-storage example submits a request for a sourced brief using the model identifier openai/gpt-5.6-sol, web_search and sandbox tools, max_steps=10 and background=true. It then retrieves the same response every two seconds until a terminal state appears.

On completed, the example reads the output text. On failed, it reads the error; cancelled and incomplete receive separate handling. This is an unexecuted documentation example. It establishes neither model availability nor the quality of any resulting brief.

Assessment & evidence

limitations

Stream reconnection is time-limited, but the reconnect window’s duration is unspecified. Response retention, maximum task duration, concurrency limits and numerical token limits are also unspecified. Returning a snapshot after reconnection fails does not by itself establish that the task completed; its status still needs checking.

The cancellation examples omit max_steps despite the page’s warning about the one-step default for direct-model requests without an effort level. They demonstrate cancellation calls, but should not be assumed to configure multi-step research. Performance, output accuracy and recovery behavior were not tested.

reasoning

The documented separation between submission and retrieval supports applications that need work to continue across connection interruptions. Saving the existing response ID is central to that design. The instruction to keep polling during token-limit pauses also avoids submitting another task while the original remains active.

A practical implication is that application state should distinguish successful completion, failure, cancellation and incomplete output. Background execution addresses connection handling; the page supplies no evidence that it improves answer quality or guarantees completion.

alternatives

Within the guide, polling suits applications that need the eventual result, while background streaming suits applications that also need events during execution. Streaming adds sequence-number tracking and reconnect-window handling. Plain retrieval is the documented fallback after that window expires.

The page does not compare other providers, external job queues or synchronous execution on cost, latency or reliability. Their relative suitability is not assessed.

evidence

The evidence is the complete Perplexity Background Mode documentation page at [https://docs.perplexity.ai/docs/agent-api/background-mode.md], including its explanations, notices and Python, TypeScript and cURL examples. The captured source revision is sha256:d48de11d90885bff77ee00e0c4d746e51256aa611a3aa2ec4c485c8cbffad860.

These provider-authored instructions support descriptions of the documented interface. No code or API requests were executed, and no independent measurements or successful execution receipts are available.

Access & freshness

costs

Costs are unknown from this page. It gives no model prices, tool charges, background-mode surcharge, polling charges or billing rules for failed, incomplete or cancelled requests.

The token-limit pause notice describes execution behavior without specifying numerical limits or prices. max_steps controls the agent loop’s step count; the page does not present it as a monetary spending cap. No per-run cost can be calculated from the examples.

rights

The page states no redistribution licence for its documentation or code examples. It also does not establish API contractual terms, output ownership, commercial-use permissions or data-retention conditions. Those rights and conditions remain unknown from this source.

freshness

The page was captured at 2026-11-14T22:18:22.073Z. It supplies no publication date, last-update date, change history or pinned SDK versions. Current endpoint behavior, availability of the illustrated model and changes after capture remain unverified.

actions

Before adoption, confirm account access, the intended model identifier, compatible SDK versions, current pricing, response retention and reconnect-window duration. Begin with submission and retrieval, saving the response ID and handling every terminal state.

For integration validation, exercise token-limit pauses, incomplete responses, asynchronous cancellation and dropped streaming connections. Include the expired-window fallback if using streaming, and choose an explicit step budget for multi-step work. These are proposed validation steps; none were performed.

Evidence for this report

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