GET
/
analytics
/
usage
import requests

url = "https://api.opper.ai/v2/analytics/usage"

headers = {"Authorization": "Bearer <token>"}

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

print(response.text)
[
  {
    "time_bucket": "2023-11-07T05:31:56Z",
    "cost": "<string>"
  }
]

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Query Parameters

from_date
string | null

Start date for the time range (inclusive). If not provided, defaults to the first day of the current month.

to_date
string | null

End date for the time range (exclusive). If not provided, defaults to the last day of the current month.

granularity
enum<string> | null
default:day

Time granularity for grouping (minute, hour, day, month, year)

Available options:
minute,
hour,
day,
month,
year
fields
string[] | null

Fields from event_metadata to include and sum

Examples:
["completion_tokens", "total_tokens"]
group_by
string[] | null

Fields from tags to group by

Examples:
["model", "project.name"]

Response

200
application/json

Successful Response

The response is of type GetUsageResultItem · object[].