Actions
Execute Python
Run a Python snippet on the computer and capture its output.
POST
Execute Python
Runs Python code on the computer and returns its output. Each call is a fresh interpreter, so nothing carries over between requests. On Linux the code runs with
python3 -c, HOME=/root, DISPLAY=:99, and PATH=/usr/local/bin:/usr/bin:/bin.
On Windows, the code is written to a temporary file and run with C:\Python312\python.exe from the user’s Desktop folder. The response carries stdout, stderr, exit_code, and output instead of the fields listed under Response, plus error when the code could not run. Code that runs out of time returns 200 with exit_code: 124 and error: "timeout".
Path parameters
Body parameters
How long the code may run, in seconds. Optional, and always clamped to 1-300:
a larger value silently becomes 300, and
0 or a non-numeric value becomes
10. Out-of-range values are never rejected.exec takes no ?screen= parameter. Unlike the pointer and keyboard actions,
sending one here is silently ignored rather than rejected. The code always runs
against the computer’s default display.Response
true only when the interpreter exited zero. Code that raises returns 200
with success: false, not an error status.Combined stdout and stderr, in that order, joined by a newline when both are
non-empty. An uncaught exception’s traceback arrives here, and it is the only
place it appears.
Always
false. Code killed by the timeout also returns false, so this field
carries no information. Infer a timeout from success: false with truncated
output instead.Always
null on a 200. It never carries a Python exception class. Parse
output if you need the exception name.Example
Successful response
Response when the code raises
Still a200. The exception is in output; error and error_type stay null.
Errors
Code that raises is not an error status: it is a
200 with
success: false. Every failure raised after the request leaves the API layer
carries a request_id. Quote it in support requests. When the computer agent
itself answered non-2xx, the body additionally carries upstream_status.
Authorizations
Body
application/json
Response
The code ran. Code that raises is still a 200, with success: false and the traceback in output.