Skip to main content
POST
/
v1
/
loops
/
deployments
/
{deployment_id}
/
metrics
cURL
curl --request POST \
--url https://api.baseten.co/v1/loops/deployments/{deployment_id}/metrics \
--header "Authorization: Bearer $BASETEN_API_KEY" \
--data '{
  "end_epoch_millis": null,
  "start_epoch_millis": null,
  "step_seconds": null,
  "time_divisor_seconds": null
}'
import requests
import os
API_KEY = os.environ.get("BASETEN_API_KEY", "<YOUR_API_KEY>")
url = "https://api.baseten.co/v1/loops/deployments/{deployment_id}/metrics"

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

response = requests.request(
"POST",
url,
headers=headers,
json={'end_epoch_millis': None, 'start_epoch_millis': None, 'step_seconds': None, 'time_divisor_seconds': None}
)

print(response.text)
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
end_epoch_millis: 123,
start_epoch_millis: 123,
step_seconds: 123,
time_divisor_seconds: 123
})
};

fetch('https://api.baseten.co/v1/loops/deployments/{deployment_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/loops/deployments/{deployment_id}/metrics",
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([
'end_epoch_millis' => 123,
'start_epoch_millis' => 123,
'step_seconds' => 123,
'time_divisor_seconds' => 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://api.baseten.co/v1/loops/deployments/{deployment_id}/metrics"

payload := strings.NewReader("{\n \"end_epoch_millis\": 123,\n \"start_epoch_millis\": 123,\n \"step_seconds\": 123,\n \"time_divisor_seconds\": 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://api.baseten.co/v1/loops/deployments/{deployment_id}/metrics")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"end_epoch_millis\": 123,\n \"start_epoch_millis\": 123,\n \"step_seconds\": 123,\n \"time_divisor_seconds\": 123\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.baseten.co/v1/loops/deployments/{deployment_id}/metrics")

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 \"end_epoch_millis\": 123,\n \"start_epoch_millis\": 123,\n \"step_seconds\": 123,\n \"time_divisor_seconds\": 123\n}"

response = http.request(request)
puts response.read_body
{
  "deployment_id": "<string>",
  "metrics": {
    "inference_volume": [
      {
        "value": 123,
        "timestamp": "2023-11-07T05:31:56Z"
      }
    ],
    "concurrent_requests": [
      {
        "value": 123,
        "timestamp": "2023-11-07T05:31:56Z"
      }
    ],
    "response_time_stats": [
      {
        "timestamp": "2023-11-07T05:31:56Z",
        "p50": 123,
        "p95": 123,
        "p99": 123
      }
    ],
    "inference_volume_by_status": [
      {
        "timestamp": "2023-11-07T05:31:56Z",
        "status_2xx": 123,
        "status_4xx": 123,
        "status_5xx": 123
      }
    ],
    "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"
        }
      ]
    },
    "per_node_metrics": [
      {
        "node_id": "<string>",
        "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

deployment_id
string
required

Body

application/json

Time-range request for trainer deployment metrics.

end_epoch_millis
integer | null

Epoch millis to end fetching metrics.

start_epoch_millis
integer | null

Epoch millis 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.

time_divisor_seconds
integer | null

Unit of time for request-volume metrics, in seconds (e.g. 60 for requests/minute). Defaults to per-second.

Response

200 - application/json

Response for POST /v1/loops/deployments/<id>/metrics.

deployment_id
string
required

The trainer deployment ID.

metrics
LoopsDeploymentMetricsV1 · object
required

Metrics for the deployment.