> ## Documentation Index
> Fetch the complete documentation index at: https://docs.baseten.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Get Model API metrics

> Gets Model API metrics for a time range, labeled by team.



## OpenAPI

````yaml get /v1/model_apis/{model_api_name}/metrics
openapi: 3.1.0
info:
  description: REST API for management of Baseten resources
  title: Baseten management API
  version: 1.0.0
servers:
  - url: https://api.baseten.co
security:
  - BearerAuth: []
paths:
  /v1/model_apis/{model_api_name}/metrics:
    parameters:
      - $ref: '#/components/parameters/model_api_name'
    get:
      summary: Gets the metrics for a Model API
      description: >-
        Gets the metrics for a Model API in the given time range for the teams
        you can manage, with each series labeled by team_id. Organization admins
        receive organization-wide metrics by default. For a Model API your lab
        organization lists, other organizations' consumption is included
        regardless of team_ids.
      parameters:
        - name: mode
          in: query
          required: false
          description: >-
            '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.
          schema:
            $ref: '#/components/schemas/MetricModeV1'
            default: CURRENT
        - name: start_epoch_millis
          in: query
          required: false
          description: >-
            Epoch millis timestamp to start fetching metrics. Defaults to one
            hour before the end.
          schema:
            anyOf:
              - type: integer
              - type: 'null'
            default: null
            title: Start Epoch Millis
        - name: end_epoch_millis
          in: query
          required: false
          description: >-
            Epoch millis timestamp to end fetching metrics. Defaults to the
            current time. The window between start and end must not exceed 7
            days.
          schema:
            anyOf:
              - type: integer
              - type: 'null'
            default: null
            title: End Epoch Millis
        - name: metrics
          in: query
          required: false
          description: >-
            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_model_api_inference_requests_total,
            baseten_model_api_incoming_inference_requests_total, and
            baseten_model_api_tokens_total. Unknown names are rejected; valid
            names that are not enabled for your organization are omitted from
            the response.
          schema:
            items:
              type: string
            title: Metrics
            type: array
        - name: team_ids
          in: query
          required: false
          description: >-
            Return only metrics for these teams, repeated once per team.
            Defaults to all teams you can manage. Any unauthorized team causes a
            403.
          schema:
            items:
              type: string
            title: Team Ids
            type: array
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GetMetricsResponseV1'
      x-codeSamples:
        - lang: bash
          source: >
            curl --request GET \

            --url https://api.baseten.co/v1/model_apis/{model_api_name}/metrics
            \

            --header "Authorization: Bearer $BASETEN_API_KEY"
        - lang: python
          source: >-
            import requests

            import os

            API_KEY = os.environ.get("BASETEN_API_KEY", "<YOUR_API_KEY>")

            url =
            "https://api.baseten.co/v1/model_apis/{model_api_name}/metrics"


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


            response = requests.request(
                "GET",
                url,
                headers=headers,
                params={'mode': 'CURRENT', 'start_epoch_millis': None, 'end_epoch_millis': None}
            )


            print(response.text)
components:
  parameters:
    model_api_name:
      schema:
        type: string
      name: model_api_name
      in: path
      required: true
  schemas:
    MetricModeV1:
      description: How metric values are aggregated over the request.
      enum:
        - CURRENT
        - SUMMARY
        - SERIES
      title: MetricModeV1
      type: string
    GetMetricsResponseV1:
      description: >-
        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.
      properties:
        start_epoch_millis:
          description: Start of the returned window.
          title: Start Epoch Millis
          type: integer
        end_epoch_millis:
          description: End of the returned window.
          title: End Epoch Millis
          type: integer
        mode:
          $ref: '#/components/schemas/MetricModeV1'
          description: The aggregation mode used.
        step_seconds:
          anyOf:
            - type: integer
            - type: 'null'
          description: Seconds per step; populated only in SERIES mode, null otherwise.
          title: Step Seconds
        metric_descriptors:
          description: Descriptors for each metric; position defines the values index.
          items:
            $ref: '#/components/schemas/MetricDescriptorV1'
          title: Metric Descriptors
          type: array
        metric_values:
          description: >-
            Metric values per time step covering the window. In summary mode
            this always contains exactly one value set spanning the whole
            window.
          items:
            $ref: '#/components/schemas/MetricValueSetV1'
          title: Metric Values
          type: array
      required:
        - start_epoch_millis
        - end_epoch_millis
        - mode
        - step_seconds
        - metric_descriptors
        - metric_values
      title: GetMetricsResponseV1
      type: object
    MetricDescriptorV1:
      description: >-
        Describes one metric. Its position in the response
        ``metric_descriptors``

        list is the index used to read that metric out of each value set's
        ``values``.


        A metric may break down into multiple labeled series (e.g. latency
        quantiles,

        or volume by status). ``label_sets`` enumerates those series in order;
        each

        value set's value for this metric is a list aligned to that order.
      properties:
        name:
          description: Canonical metric name.
          title: Name
          type: string
        unit_hint:
          $ref: '#/components/schemas/MetricUnitHintV1'
          description: Advisory unit of the metric's values.
        kind:
          $ref: '#/components/schemas/MetricKindV1'
          description: >-
            Semantic hint for how the metric behaves (GAUGE, COUNTER,
            HISTOGRAM).
        label_sets:
          description: >-
            The metric's series, in order. Each entry is the set of labels
            identifying one series; the value at the same index in each value
            set's ``values`` is that series' value. A plain metric has a single
            entry with no labels (`{}`). A histogram has one entry per quantile
            plus an average, e.g. {'quantile': '0.5'} … {'quantile': '0.99'},
            {'stat': 'avg'}.
          items:
            additionalProperties:
              type: string
            type: object
          title: Label Sets
          type: array
      required:
        - name
        - unit_hint
        - kind
        - label_sets
      title: MetricDescriptorV1
      type: object
    MetricValueSetV1:
      description: >-
        The metric values for one time step. ``values`` is aligned by index to
        the

        response ``metric_descriptors`` list.
      properties:
        start_epoch_millis:
          description: >-
            Start of the step. The step spans until the next value set's start,
            or the window end for the last one; a summary has a single value set
            starting at the window start.
          title: Start Epoch Millis
          type: integer
        values:
          description: >-
            Metric values aligned to the ``metric_descriptors`` index. Each
            entry is a list aligned to that descriptor's ``label_sets`` (a
            single-element list for a plain metric). A series with no data in
            this step is null.
          items:
            items:
              anyOf:
                - type: number
                - type: 'null'
            type: array
          title: Values
          type: array
      required:
        - start_epoch_millis
        - values
      title: MetricValueSetV1
      type: object
    MetricUnitHintV1:
      description: >-
        Advisory unit of a metric's values. Values are reported as scraped, so
        the

        hint describes the raw value (e.g. GPU memory is reported in mebibytes).


        - ``PER_SECOND``: a rate per second.

        - ``SECONDS``: a duration in seconds.

        - ``BYTES``: a size in bytes.

        - ``MEBIBYTES``: a size in mebibytes (MiB).

        - ``COUNT``: a dimensionless tally of discrete things.

        - ``RATIO``: a dimensionless ratio. Usually in ``[0, 1]`` but may exceed
        1
          (e.g. CPU usage in cores = cpu-seconds/second).
        - ``CELSIUS``: a temperature in degrees Celsius.

        - ``WATTS``: power draw in watts.
      enum:
        - PER_SECOND
        - SECONDS
        - BYTES
        - MEBIBYTES
        - COUNT
        - RATIO
        - CELSIUS
        - WATTS
      title: MetricUnitHintV1
      type: string
    MetricKindV1:
      description: >-
        Semantic hint for how a metric behaves, to aid client rendering and

        aggregation. It does not describe the value's shape (that is carried by
        the

        descriptor's ``label_sets``; a metric may break down into multiple
        series).


        - ``GAUGE``: an instantaneous value (e.g. queue size, running requests).

        - ``COUNTER``: a cumulative total over the step (e.g. tokens, restarts).

        - ``HISTOGRAM``: a distribution, exposed as quantile/average series.
      enum:
        - GAUGE
        - COUNTER
        - HISTOGRAM
      title: MetricKindV1
      type: string
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: >-
        Send `Authorization: Bearer <api_key>`. The legacy `Authorization:
        Api-Key <api_key>` scheme is also accepted.

````