opendunes
Your account
Copy page ▾

Usage history

GET /v1/activity answers what your account spent, day by day: one row per day, model and provider, with its requests, its tokens and its total in DADAThe Algerian dinar, the one currency the docs show.More on Balance and charges →.

Request

Send it with a management keyManagement keyThe key that runs your account through the API: the balance, the usage history, your keys, guardrails, observability. It never calls a model.More on API keys →: set OPENDUNES_MANAGEMENT_KEY to it for this call. An API keyAPI keyThe key you create and send with every request that calls a model.More on API keys → gets a 401. The one field goes in the address, after ?. Balance and charges says how each charge is made.

FieldNeededYou send
datenoone day, YYYY-MM-DD, in UTC; absent, the last 30 days
import json
import os
import urllib.request

MANAGEMENT_KEY = os.environ["OPENDUNES_MANAGEMENT_KEY"]
ADDRESS = "https://opendunes.com/v1/activity"

request = urllib.request.Request(
    ADDRESS,
    headers={"Authorization": "Bearer " + MANAGEMENT_KEY},
)
with urllib.request.urlopen(request) as response:
    rows = json.load(response)["data"]

for row in rows:
    print(row["date"], row["model"], row["requests"], row["usage"])

Response

200 OK. The rows run newest day first; a day with no request has no row.

FieldHolds
datathe rows, one per day, model and provider
datethe day, YYYY-MM-DD, in UTC
modelthe model, lab/model
model_permaslugthe same model, under the same name
endpoint_idthe provider endpoint that served these requests
provider_namethe provider that served them
prompt_tokensevery token sent that day, to that model, through that provider
completion_tokensevery token produced
requestshow many requests
usagewhat they were charged, in DA

What it cost

Free. Reading your usage history is never charged.

Errors

error.code carries the status, and error.message says why.

StatusWhen
400date is not a day written YYYY-MM-DD
401the key is missing, wrong, revoked or expired, or it is an API key

Last modified on