commands.run runs a shell command (/bin/bash -l -c) in the sandbox and waits for it. It returns stdout, stderr and the exit code; a non-zero exit raises an exception you can catch.
Sandbox-wide environment variables go on create: Sandbox.create("base", envs={"API_TOKEN": "…"}) or anona-compute create -e API_TOKEN=….

Install packages

Every template has sudo for user. Install what you need at runtime:
install.py
For Python and Node work, start from the python or node template so the toolchain is already there. Pause the sandbox between runs to keep what you installed.

JSON output from the CLI

--json prints one JSON object per line, which suits scripts:
exec_json.sh