Skip to main content
You can use the commands.run() method to run terminal commands inside the sandbox.

Basic usage

Call commands.run() with a command string. The returned result contains the command output.

Read command output

Use stdout to read what the command printed.

Run in the background

Pass the background option to start a long-running process (such as a server) without blocking on it.

Override environment variables per command

You can override or append environment variables for a single command with the envs option. It applies only to that command.

Stream output

For long-running commands, pass on_stdout / on_stderr (Python) or onStdout / onStderr (JavaScript) callbacks to receive output as it is produced, instead of waiting for the command to finish. The returned result still contains the final exit code.
Last modified on August 5, 2026