Computer Actions
Execute Python
Run a Python snippet on the computer and capture its stdout.
POST
/
computers
/
{id}
/
exec
Execute Python
curl --request POST \
--url https://www.orgo.ai/api/computers/{id}/exec \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"code": "import os\nprint(os.getcwd())",
"timeout": 10
}
'import requests
url = "https://www.orgo.ai/api/computers/{id}/exec"
payload = {
"code": "import os
print(os.getcwd())",
"timeout": 10
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({code: 'import os\nprint(os.getcwd())', timeout: 10})
};
fetch('https://www.orgo.ai/api/computers/{id}/exec', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://www.orgo.ai/api/computers/{id}/exec",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'code' => 'import os
print(os.getcwd())',
'timeout' => 10
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://www.orgo.ai/api/computers/{id}/exec"
payload := strings.NewReader("{\n \"code\": \"import os\\nprint(os.getcwd())\",\n \"timeout\": 10\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://www.orgo.ai/api/computers/{id}/exec")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"code\": \"import os\\nprint(os.getcwd())\",\n \"timeout\": 10\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://www.orgo.ai/api/computers/{id}/exec")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"code\": \"import os\\nprint(os.getcwd())\",\n \"timeout\": 10\n}"
response = http.request(request)
puts response.read_body{
"output": "/home/user\n",
"success": true
}{
"error": "Invalid API key"
}{
"error": "Resource not found"
}Executes Python code on the computer in a short-lived interpreter and returns its output.
Path parameters
string
required
Computer ID (UUID).
Body parameters
string
required
Python code to execute.
integer
default:"10"
Timeout in seconds (1-300).
Response
string
Captured stdout from the interpreter.
boolean
true if the code ran without raising an uncaught exception.string
Error message, if execution failed.
string
Python exception class (e.g.,
SyntaxError, NameError).boolean
true if execution was killed by the timeout.Example
curl -X POST https://www.orgo.ai/api/computers/a3bb189e-8bf9-3888-9912-ace4e6543002/exec \
-H "Authorization: Bearer $ORGO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"code": "import os\nprint(os.getcwd())",
"timeout": 10
}'
import requests
response = requests.post(
f"https://www.orgo.ai/api/computers/{computer_id}/exec",
headers={"Authorization": f"Bearer {api_key}", "Content-Type": "application/json"},
json={
"code": "import os\nprint(os.getcwd())",
"timeout": 10
}
)
result = response.json()
if result["success"]:
print(result["output"])
else:
print(f"Error: {result.get('error')}")
const response = await fetch(`https://www.orgo.ai/api/computers/${computerId}/exec`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${apiKey}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
code: 'import os\nprint(os.getcwd())',
timeout: 10
})
});
const result = await response.json();
if (result.success) {
console.log(result.output);
} else {
console.error(`Error: ${result.error}`);
}
Successful response
{
"output": "/home/user\n",
"success": true,
"action": "exec",
"timeout": false
}
Error response
{
"output": "",
"success": false,
"action": "exec",
"error": "name 'undefined_var' is not defined",
"error_type": "NameError"
}
For shell commands, use Execute bash instead.
Errors
| Status | Meaning |
|---|---|
400 | Missing or non-string code, or computer instance not available. |
401 | Missing or invalid API key. |
403 | You do not have access to this computer. |
404 | Computer not found. |
500 | Upstream desktop agent failure. |
Authorizations
API key authentication. Get your key at orgo.ai/workspaces
Path Parameters
Computer ID
Body
application/json
⌘I
Execute Python
curl --request POST \
--url https://www.orgo.ai/api/computers/{id}/exec \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"code": "import os\nprint(os.getcwd())",
"timeout": 10
}
'import requests
url = "https://www.orgo.ai/api/computers/{id}/exec"
payload = {
"code": "import os
print(os.getcwd())",
"timeout": 10
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({code: 'import os\nprint(os.getcwd())', timeout: 10})
};
fetch('https://www.orgo.ai/api/computers/{id}/exec', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://www.orgo.ai/api/computers/{id}/exec",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'code' => 'import os
print(os.getcwd())',
'timeout' => 10
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://www.orgo.ai/api/computers/{id}/exec"
payload := strings.NewReader("{\n \"code\": \"import os\\nprint(os.getcwd())\",\n \"timeout\": 10\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://www.orgo.ai/api/computers/{id}/exec")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"code\": \"import os\\nprint(os.getcwd())\",\n \"timeout\": 10\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://www.orgo.ai/api/computers/{id}/exec")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"code\": \"import os\\nprint(os.getcwd())\",\n \"timeout\": 10\n}"
response = http.request(request)
puts response.read_body{
"output": "/home/user\n",
"success": true
}{
"error": "Invalid API key"
}{
"error": "Resource not found"
}