Use async lifecycle methods
Use native async creation and cleanup when your application runs an event loop. The owner example terminates its Sandbox, while the named variant attaches without taking ownership or creates a Sandbox that it owns.
Attach to an existing desktop
Attach to a desktop that another process owns. The example detaches on exit and leaves the Sandbox running.
Configure and prewarm a browser
Create a desktop with an explicit browser profile and prewarm setting. The example creates a billable Sandbox and disables GPU use by default.
Capture a recording
Capture a desktop session through an existing local daemon. The example writes an MP4 file, so your application must define storage and retention rules.
Persist artifacts
Persist run artifacts in a Modal Volume v2. The example terminates its Sandbox but retains the caller-owned Volume and its data.
Run an OpenAI computer loop
Run a bounded OpenAI computer loop with batching and screenshot reuse. Your application owns action approval, credentials, provider output retention, and model cost.
Run an Anthropic computer loop
Run a bounded Anthropic computer loop with a reviewed batch tool. Your application owns policy for the hosted actions and the custom batch tool.
Review actions before execution
Add an application policy before an adapter executes an action. This credential-free example uses a fake computer and does not control a desktop.
Hand a desktop to a Modal Function
Borrow an owned desktop for one stateful Function trajectory. Cancellation does not reverse desktop effects, so the owner must reconcile an ambiguous result.
Keep warm capacity
Provision and claim bounded warm desktop capacity. Reserved Sandboxes can remain billable while idle, and each claim is one-shot.

