Meters

Query meter

post/api/v1/meters/{meterIdOrSlug}/query

Path parameters

meterIdOrSlugstring required

Request body

advancedMeterGroupByFiltersobject

Optional advanced meter group by filters. You can use this to filter for values of the meter groupBy fields.

clientIdstring

Client ID Useful to track progress of a query.

filterCustomerIdstring[]

Filtering by multiple customers.

filterGroupByobject

Simple filter for group bys with exact match.

fromstring date-time

Start date-time in RFC 3339 format.

Inclusive.

groupBystring[]

If not specified a single aggregate will be returned for each subject and time window. subject is a reserved group by value.

subjectstring[]

Filtering by multiple subjects.

tostring date-time

End date-time in RFC 3339 format.

Inclusive.

windowSize'MINUTE' | 'HOUR' | 'DAY' | 'MONTH'

Aggregation window size.

windowTimeZonestring

The value is the name of the time zone as defined in the IANA Time Zone Database (http://www.iana.org/time-zones). If not specified, the UTC timezone will be used.

Example request

{
  "advancedMeterGroupByFilters": {
    "model": {
      "$in": [
        "gpt-4",
        "gpt-4o"
      ]
    },
    "type": {
      "$eq": "input"
    }
  },
  "clientId": "f74e58ed-94ce-4041-ae06-cf45420451a3",
  "filterCustomerId": [
    "id-1",
    "id-2"
  ],
  "filterGroupBy": {
    "model": [
      "gpt-4-turbo",
      "gpt-4o"
    ],
    "type": [
      "prompt"
    ]
  },
  "from": "2023-01-01T01:01:01.001Z",
  "groupBy": [
    "model",
    "type"
  ],
  "subject": [
    "subject-1",
    "subject-2"
  ],
  "to": "2023-01-01T01:01:01.001Z",
  "windowTimeZone": "UTC"
}

Response

The request has succeeded.

fromstring date-time

The start of the period the usage is queried from. If not specified, the usage is queried from the beginning of time.

tostring date-time

The end of the period the usage is queried to. If not specified, the usage is queried up to the current time.

windowSize'MINUTE' | 'HOUR' | 'DAY' | 'MONTH'

Aggregation window size.

Example response

{
  "data": [
    {
      "groupBy": {
        "model": "gpt-4-turbo",
        "type": "prompt"
      },
      "subject": "customer-1",
      "value": 12,
      "windowEnd": "2023-01-02T00:00:00Z",
      "windowStart": "2023-01-01T00:00:00Z"
    }
  ],
  "from": "2023-01-01T00:00:00Z",
  "to": "2023-01-02T00:00:00Z",
  "windowSize": "DAY"
}

Changes

No recorded changes to this endpoint across all 1 revision of this API.