Skip to main content
GET
/
v1
/
training_projects
/
{training_project_id}
/
jobs
/
{training_job_id}
/
metrics
cURL
curl --request GET \
--url https://api.baseten.co/v1/training_projects/{training_project_id}/jobs/{training_job_id}/metrics \
--header "Authorization: Bearer $BASETEN_API_KEY"
import requests
import os
API_KEY = os.environ.get("BASETEN_API_KEY", "<YOUR_API_KEY>")
url = "https://api.baseten.co/v1/training_projects/{training_project_id}/jobs/{training_job_id}/metrics"

headers = {"Authorization": f"Bearer {API_KEY}"}

response = requests.request(
"GET",
url,
headers=headers,
json={}
)

print(response.text)
const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};

fetch('https://api.baseten.co/v1/training_projects/{training_project_id}/jobs/{training_job_id}/metrics', 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://api.baseten.co/v1/training_projects/{training_project_id}/jobs/{training_job_id}/metrics",
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://api.baseten.co/v1/training_projects/{training_project_id}/jobs/{training_job_id}/metrics"

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://api.baseten.co/v1/training_projects/{training_project_id}/jobs/{training_job_id}/metrics")
.header("Authorization", "Bearer <token>")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.baseten.co/v1/training_projects/{training_project_id}/jobs/{training_job_id}/metrics")

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
{
  "gpu_memory_usage_bytes": {},
  "gpu_utilization": {},
  "cpu_usage": [
    {
      "value": 123,
      "timestamp": "2023-11-07T05:31:56Z"
    }
  ],
  "cpu_memory_usage_bytes": [
    {
      "value": 123,
      "timestamp": "2023-11-07T05:31:56Z"
    }
  ],
  "ephemeral_storage": {
    "usage_bytes": [
      {
        "value": 123,
        "timestamp": "2023-11-07T05:31:56Z"
      }
    ],
    "utilization": [
      {
        "value": 123,
        "timestamp": "2023-11-07T05:31:56Z"
      }
    ]
  },
  "training_job": {
    "id": "<string>",
    "created_at": "2023-11-07T05:31:56Z",
    "current_status": "<string>",
    "instance_type": {
      "id": "<string>",
      "name": "<string>",
      "memory_limit_mib": 123,
      "millicpu_limit": 123,
      "gpu_count": 123,
      "gpu_type": "<string>",
      "gpu_memory_limit_mib": 123
    },
    "updated_at": "2023-11-07T05:31:56Z",
    "training_project_id": "<string>",
    "training_project": {
      "id": "<string>",
      "name": "<string>"
    },
    "error_message": "<string>",
    "name": "gpt-oss-job",
    "priority": 0,
    "availability_model": "dedicated",
    "user": {
      "email": "<string>"
    }
  },
  "cache": {
    "usage_bytes": [
      {
        "value": 123,
        "timestamp": "2023-11-07T05:31:56Z"
      }
    ],
    "utilization": [
      {
        "value": 123,
        "timestamp": "2023-11-07T05:31:56Z"
      }
    ]
  },
  "per_node_metrics": [
    {
      "node_id": "<string>",
      "metrics": {
        "gpu_memory_usage_bytes": {},
        "gpu_utilization": {},
        "cpu_usage": [
          {
            "value": 123,
            "timestamp": "2023-11-07T05:31:56Z"
          }
        ],
        "cpu_memory_usage_bytes": [
          {
            "value": 123,
            "timestamp": "2023-11-07T05:31:56Z"
          }
        ],
        "ephemeral_storage": {
          "usage_bytes": [
            {
              "value": 123,
              "timestamp": "2023-11-07T05:31:56Z"
            }
          ],
          "utilization": [
            {
              "value": 123,
              "timestamp": "2023-11-07T05:31:56Z"
            }
          ]
        }
      }
    }
  ]
}

Authorizations

Authorization
string
header
required

Send Authorization: Bearer <api_key>. The legacy Authorization: Api-Key <api_key> scheme is also accepted.

Path Parameters

training_project_id
string
required
training_job_id
string
required

Query Parameters

end_epoch_millis
integer | null

Epoch millis timestamp to end fetching metrics

start_epoch_millis
integer | null

Epoch millis timestamp to start fetching metrics.

step_seconds
integer | null

Resolution of the returned series, in seconds. When omitted, a step is derived from the time range so large windows return fewer points.

Response

200 - application/json

A response to fetch training job metrics. The outer list for each metric represents that metric across time.

gpu_memory_usage_bytes
Gpu Memory Usage Bytes · object
required

A map of GPU rank to memory usage for the training job. For multinode jobs, this is the memory usage of the leader unless specified otherwise.

gpu_utilization
Gpu Utilization · object
required

A map of GPU rank to fractional GPU utilization. For multinode jobs, this is the GPU utilization of the leader unless specified otherwise.

cpu_usage
TrainingJobMetricV1 · object[]
required

The CPU usage measured in cores. For multinode jobs, this is the CPU usage of the leader unless specified otherwise.

cpu_memory_usage_bytes
TrainingJobMetricV1 · object[]
required

The CPU memory usage for the training job. For multinode jobs, this is the CPU memory usage of the leader unless specified otherwise.

ephemeral_storage
StorageMetricsV1 · object
required

The storage usage for the ephemeral storage. For multinode jobs, this is the ephemeral storage usage of the leader unless specified otherwise.

training_job
TrainingJobV1 · object
required

The training job.

cache
StorageMetricsV1 · object | null
required

The storage usage for the read-write cache.

per_node_metrics
TrainingJobNodeMetricsV1 · object[]
required

The metrics for each node in the training job.