Skip to main content
GET
/
v1
/
models
/
{model_id}
/
deployments
/
{deployment_id}
/
metrics
cURL
curl --request GET \
--url https://api.baseten.co/v1/models/{model_id}/deployments/{deployment_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/models/{model_id}/deployments/{deployment_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/models/{model_id}/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/models/{model_id}/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 => "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/models/{model_id}/deployments/{deployment_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/models/{model_id}/deployments/{deployment_id}/metrics")
  .header("Authorization", "Bearer <token>")
  .asString();
require 'uri'
require 'net/http'

url = URI("https://api.baseten.co/v1/models/{model_id}/deployments/{deployment_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
{
  "start_epoch_millis": 123,
  "end_epoch_millis": 123,
  "step_seconds": 123,
  "metric_descriptors": [
    {
      "name": "<string>",
      "label_sets": [
        {}
      ]
    }
  ],
  "metric_values": [
    {
      "start_epoch_millis": 123,
      "values": [
        [
          123
        ]
      ]
    }
  ]
}
This endpoint is in beta. The request and response structure may change before it’s generally available.

Authorizations

Authorization
string
header
required

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

Path Parameters

model_id
string
required
deployment_id
string
required

Query Parameters

mode
enum<string>
default:CURRENT

'CURRENT': a single instantaneous snapshot at now; start/end must be omitted. 'SUMMARY': a single value set aggregating the whole window. 'SERIES': evenly-spaced value sets across the window, with the step derived from the window duration. How metric values are aggregated over the request.

Available options:
CURRENT,
SUMMARY,
SERIES
start_epoch_millis
integer | null

Epoch millis timestamp to start fetching metrics. Defaults to one hour before the end.

end_epoch_millis
integer | null

Epoch millis timestamp to end fetching metrics. Defaults to the current time. The window between start and end must not exceed 7 days.

metrics
string[]

Names of the metrics to return; see https://docs.baseten.co/observability/export-metrics/supported-metrics for the available names. When omitted, a default set is returned: baseten_replicas_active, baseten_inference_requests_total, and baseten_end_to_end_response_time_seconds. Unknown names are rejected; valid names that do not apply are omitted from the response.

Response

200 - application/json

Model metrics over a time window, index-mapped: metric descriptors appear once in metric_descriptors; each value set's values are aligned to that order.

start_epoch_millis
integer
required

Start of the returned window.

end_epoch_millis
integer
required

End of the returned window.

mode
enum<string>
required

The aggregation mode used.

Available options:
CURRENT,
SUMMARY,
SERIES
step_seconds
integer | null
required

Seconds per step; populated only in SERIES mode, null otherwise.

metric_descriptors
ModelMetricDescriptorV1 · object[]
required

Descriptors for each metric; position defines the values index.

metric_values
ModelMetricValueSetV1 · object[]
required

Metric values per time step covering the window. In summary mode this always contains exactly one value set spanning the whole window.