curl --request GET \
--url https://{identifier}.sandbox.tensorlake.ai/api/v1/resource-usage \
--header 'Authorization: Bearer <token>'import requests
url = "https://{identifier}.sandbox.tensorlake.ai/api/v1/resource-usage"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://{identifier}.sandbox.tensorlake.ai/api/v1/resource-usage', 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/resource-usage",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://{identifier}.sandbox.tensorlake.ai/api/v1/resource-usage"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://{identifier}.sandbox.tensorlake.ai/api/v1/resource-usage")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://{identifier}.sandbox.tensorlake.ai/api/v1/resource-usage")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"observed_at_ms": 1792400000000,
"cpu_total_ticks": 240000,
"cpu_idle_ticks": 180000,
"clock_ticks_per_second": 100,
"cpu_limit_cores": 2,
"memory_used_bytes": 536870912,
"memory_available_bytes": 1610612736,
"memory_limit_bytes": 2147483648,
"source": "guest_procfs"
}{
"error": "Guest resource usage is temporarily unavailable.",
"code": "RESOURCE_USAGE_UNSUPPORTED"
}{
"error": "Guest resource usage is temporarily unavailable.",
"code": "RESOURCE_USAGE_UNAVAILABLE"
}Get resource usage
Query live sandbox CPU counters and memory usage.
curl --request GET \
--url https://{identifier}.sandbox.tensorlake.ai/api/v1/resource-usage \
--header 'Authorization: Bearer <token>'import requests
url = "https://{identifier}.sandbox.tensorlake.ai/api/v1/resource-usage"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://{identifier}.sandbox.tensorlake.ai/api/v1/resource-usage', 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/resource-usage",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://{identifier}.sandbox.tensorlake.ai/api/v1/resource-usage"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://{identifier}.sandbox.tensorlake.ai/api/v1/resource-usage")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://{identifier}.sandbox.tensorlake.ai/api/v1/resource-usage")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"observed_at_ms": 1792400000000,
"cpu_total_ticks": 240000,
"cpu_idle_ticks": 180000,
"clock_ticks_per_second": 100,
"cpu_limit_cores": 2,
"memory_used_bytes": 536870912,
"memory_available_bytes": 1610612736,
"memory_limit_bytes": 2147483648,
"source": "guest_procfs"
}{
"error": "Guest resource usage is temporarily unavailable.",
"code": "RESOURCE_USAGE_UNSUPPORTED"
}{
"error": "Guest resource usage is temporarily unavailable.",
"code": "RESOURCE_USAGE_UNAVAILABLE"
}Example request
SetSANDBOX_URL to the sandbox_url returned by Get Sandbox. Authenticate with your Tensorlake API key:
curl "${SANDBOX_URL%/}/api/v1/resource-usage" \
-H "Authorization: Bearer $TENSORLAKE_API_KEY"
CPU utilization
CPU counters accumulate across all guest CPUs. Take two samples and calculate utilization as a percentage of total guest CPU capacity:delta_total = second.cpu_total_ticks - first.cpu_total_ticks
delta_idle = second.cpu_idle_ticks - first.cpu_idle_ticks
cpu_percent = 100 * (1 - delta_idle / delta_total)
cpu_limit_cores changes. Skip intervals where delta_total is zero.
Memory usage
memory_used_bytes is calculated as (MemTotal − MemAvailable) × 1024 using the sandbox’s /proc/meminfo. MemAvailable is the kernel’s estimate of memory available for new workloads, accounting for reclaimable caches. This follows the used-memory calculation documented by Linux free.Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Response
Current guest CPU and memory counters
Sample time in Unix milliseconds, recorded after reading both CPU and memory counters.
Cumulative CPU ticks across all guest CPUs, including user, nice, system, idle, iowait, irq, softirq, and steal. Guest and guest_nice are already included in user and nice and are not counted again.
x >= 0Cumulative idle and iowait ticks across all guest CPUs. This is a subset of cpu_total_ticks.
x >= 0Linux USER_HZ, the number of clock ticks per second. Divide ticks by this value to convert them to CPU seconds.
x >= 1Number of guest CPU rows exposed by Linux procfs.
x >= 1Calculated as (MemTotal − MemAvailable) × 1024 using the sandbox’s /proc/meminfo. MemAvailable is the kernel’s estimate of memory available for new workloads, accounting for reclaimable caches. This follows the used-memory calculation documented by Linux free.
x >= 0Guest MemAvailable, in bytes. Estimates memory available for new workloads, accounting for reclaimable caches.
x >= 0Guest MemTotal, in bytes.
x >= 0Counters read from Linux /proc/stat and /proc/meminfo inside the sandbox.
guest_procfs Was this page helpful?