Run a process
curl --request POST \
--url https://{identifier}.sandbox.tensorlake.ai/api/v1/processes/run \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"command": "<string>",
"args": [
"<string>"
],
"env": {},
"working_dir": "<string>",
"user": "<string>",
"timeout": 123
}
'import requests
url = "https://{identifier}.sandbox.tensorlake.ai/api/v1/processes/run"
payload = {
"command": "<string>",
"args": ["<string>"],
"env": {},
"working_dir": "<string>",
"user": "<string>",
"timeout": 123
}
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({
command: '<string>',
args: ['<string>'],
env: {},
working_dir: '<string>',
user: '<string>',
timeout: 123
})
};
fetch('https://{identifier}.sandbox.tensorlake.ai/api/v1/processes/run', 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://{identifier}.sandbox.tensorlake.ai/api/v1/processes/run",
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([
'command' => '<string>',
'args' => [
'<string>'
],
'env' => [
],
'working_dir' => '<string>',
'user' => '<string>',
'timeout' => 123
]),
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://{identifier}.sandbox.tensorlake.ai/api/v1/processes/run"
payload := strings.NewReader("{\n \"command\": \"<string>\",\n \"args\": [\n \"<string>\"\n ],\n \"env\": {},\n \"working_dir\": \"<string>\",\n \"user\": \"<string>\",\n \"timeout\": 123\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://{identifier}.sandbox.tensorlake.ai/api/v1/processes/run")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"command\": \"<string>\",\n \"args\": [\n \"<string>\"\n ],\n \"env\": {},\n \"working_dir\": \"<string>\",\n \"user\": \"<string>\",\n \"timeout\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{identifier}.sandbox.tensorlake.ai/api/v1/processes/run")
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 \"command\": \"<string>\",\n \"args\": [\n \"<string>\"\n ],\n \"env\": {},\n \"working_dir\": \"<string>\",\n \"user\": \"<string>\",\n \"timeout\": 123\n}"
response = http.request(request)
puts response.read_body"data: {\"handle\":1,\"pid\":42,\"started_at\":1710000000000}\n\n"Process Management
Run Process
Start a non-interactive process, stream captured output over Server-Sent Events, and emit a final exit event. Stdin is closed for this endpoint.
POST
/
api
/
v1
/
processes
/
run
Run a process
curl --request POST \
--url https://{identifier}.sandbox.tensorlake.ai/api/v1/processes/run \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"command": "<string>",
"args": [
"<string>"
],
"env": {},
"working_dir": "<string>",
"user": "<string>",
"timeout": 123
}
'import requests
url = "https://{identifier}.sandbox.tensorlake.ai/api/v1/processes/run"
payload = {
"command": "<string>",
"args": ["<string>"],
"env": {},
"working_dir": "<string>",
"user": "<string>",
"timeout": 123
}
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({
command: '<string>',
args: ['<string>'],
env: {},
working_dir: '<string>',
user: '<string>',
timeout: 123
})
};
fetch('https://{identifier}.sandbox.tensorlake.ai/api/v1/processes/run', 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://{identifier}.sandbox.tensorlake.ai/api/v1/processes/run",
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([
'command' => '<string>',
'args' => [
'<string>'
],
'env' => [
],
'working_dir' => '<string>',
'user' => '<string>',
'timeout' => 123
]),
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://{identifier}.sandbox.tensorlake.ai/api/v1/processes/run"
payload := strings.NewReader("{\n \"command\": \"<string>\",\n \"args\": [\n \"<string>\"\n ],\n \"env\": {},\n \"working_dir\": \"<string>\",\n \"user\": \"<string>\",\n \"timeout\": 123\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://{identifier}.sandbox.tensorlake.ai/api/v1/processes/run")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"command\": \"<string>\",\n \"args\": [\n \"<string>\"\n ],\n \"env\": {},\n \"working_dir\": \"<string>\",\n \"user\": \"<string>\",\n \"timeout\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{identifier}.sandbox.tensorlake.ai/api/v1/processes/run")
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 \"command\": \"<string>\",\n \"args\": [\n \"<string>\"\n ],\n \"env\": {},\n \"working_dir\": \"<string>\",\n \"user\": \"<string>\",\n \"timeout\": 123\n}"
response = http.request(request)
puts response.read_body"data: {\"handle\":1,\"pid\":42,\"started_at\":1710000000000}\n\n"Start a process, stream its captured output over Server-Sent Events, and receive a final exit event.
Use this endpoint when you want a single request for non-interactive command execution. If the process needs stdin, use Start Process, Process Stdin, and Close Process Stdin instead.
Use this endpoint on the sandbox proxy host:
The first event contains
Endpoint
POST /api/v1/processes/run
https://<sandbox-id-or-name>.sandbox.tensorlake.ai/api/v1/processes/run
Example Request
curl -N -X POST https://<sandbox-id>.sandbox.tensorlake.ai/api/v1/processes/run \
-H "Authorization: Bearer $TENSORLAKE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"command": "python",
"args": ["-c", "import os; print(os.environ[\"MODE\"])"],
"env": {"MODE": "batch"},
"working_dir": "/workspace",
"timeout": 30
}'
Request Body
{
"command": "python",
"args": ["-c", "print('hello')"],
"env": {"MODE": "batch"},
"working_dir": "/workspace",
"user": "tl-user",
"timeout": 30
}
commandis required.argsdefaults to[].envdefaults to{}and is applied to the process environment.working_diris optional.useris optional and accepts a username, UID string,uid:gidstring, or an object such as{"uid": 1000, "gid": 1000}.timeoutis optional. When set, Tensorlake kills the process if it is still running after that many seconds.
/processes/run always starts the process with stdin closed and stdout/stderr captured, even if stdin_mode, stdout_mode, or stderr_mode are present in the request body.SSE Events
Tensorlake streams JSON payloads in SSEdata: frames:
data: {"handle":1,"pid":42,"started_at":1710000000000}
data: {"line":"hello","timestamp":1710000000010,"stream":"stdout"}
data: {"exit_code":0}
handle, pid, and started_at. Output events contain line, timestamp, and stream. The final event contains exit_code or signal; if the kernel OOM killer ended the process, it includes signal: 9 and oom_killed: true.Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
application/json
Was this page helpful?