Get resource 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": "Sandbox 'parked-agent' is suspended and automatic resume is disabled; resume it explicitly before sending traffic.",
"code": "SANDBOX_AUTO_RESUME_DISABLED"
}{
"error": "Guest resource usage is temporarily unavailable.",
"code": "RESOURCE_USAGE_UNSUPPORTED"
}{
"error": "Guest resource usage is temporarily unavailable.",
"code": "RESOURCE_USAGE_UNAVAILABLE"
}Runtime Metadata
Get resource usage
Query live sandbox CPU counters and memory usage.
GET
/
api
/
v1
/
resource-usage
Get resource 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": "Sandbox 'parked-agent' is suspended and automatic resume is disabled; resume it explicitly before sending traffic.",
"code": "SANDBOX_AUTO_RESUME_DISABLED"
}{
"error": "Guest resource usage is temporarily unavailable.",
"code": "RESOURCE_USAGE_UNSUPPORTED"
}{
"error": "Guest resource usage is temporarily unavailable.",
"code": "RESOURCE_USAGE_UNAVAILABLE"
}Get one current CPU and memory sample from inside your sandbox. Use this endpoint to poll live resource usage; it does not return historical samples.
This calculation treats I/O wait as idle and includes steal time in utilization.
For example, an increase of 200 total ticks and 50 idle ticks means 75% utilization across the guest CPUs. Start a new baseline if the timestamp or either counter moves backward, or if
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
Response
Current guest CPU and memory counters
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.
Required range:
x >= 0Was this page helpful?