VOOZH about

URL: https://developers.openai.com/api/docs/guides/background

⇱ Background mode | OpenAI API


Search the API docs

Primary navigation

Evaluation

Legacy APIs

Agents like Codex and Deep Research show that reasoning models can take several minutes to solve complex problems. Background mode enables you to execute long-running tasks on models like GPT-5.2 and GPT-5.2 Pro reliably, without having to worry about timeouts or other connectivity issues.

Background mode kicks off these tasks asynchronously, and developers can poll response objects to check status over time. To start response generation in the background, make an API request with background set to true:

Because background mode stores response data for roughly 10 minutes to enable polling, it is not Zero Data Retention (ZDR) compatible. Requests from ZDR projects are still accepted with background=true for legacy reasons, but using it breaks ZDR guarantees. Modified Abuse Monitoring (MAM) projects can safely rely on background mode.

Polling background responses

To check the status of background requests, use the GET endpoint for Responses. Keep polling while the request is in the queued or in_progress state. When it leaves these states, it has reached a final (terminal) state.

Cancelling a background response

You can also cancel an in-flight response like this:

Cancelling twice is idempotent - subsequent calls simply return the final Response object.

Streaming a background response

You can create a background Response and start streaming events from it right away. This may be helpful if you expect the client to drop the stream and want the option of picking it back up later. To do this, create a Response with both background and stream set to true. You will want to keep track of a “cursor” corresponding to the sequence_number you receive in each streaming event.

Currently, the time to first token you receive from a background response is higher than what you receive from a synchronous one. We are working to reduce this latency gap in the coming weeks.

Limits

  1. Background sampling requires store=true; stateless requests are rejected.
  2. To cancel a synchronous response, terminate the connection
  3. You can only start a new stream from a background response if you created it with stream=true.

Loading docs agent...