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.
| Field | Needed | You send |
|---|---|---|
date | no | one 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.
| Field | Holds |
|---|---|
data | the rows, one per day, model and provider |
date | the day, YYYY-MM-DD, in UTC |
model | the model, lab/model |
model_permaslug | the same model, under the same name |
endpoint_id | the provider endpoint that served these requests |
provider_name | the provider that served them |
prompt_tokens | every token sent that day, to that model, through that provider |
completion_tokens | every token produced |
requests | how many requests |
usage | what 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.
| Status | When |
|---|---|
| 400 | date is not a day written YYYY-MM-DD |
| 401 | the key is missing, wrong, revoked or expired, or it is an API key |
Last modified on