Usage and quota
Usage ledger
The spend and token ledger: one entry per model attempt, newest first. Requires usage_read.
The window filters on when each attempt was recorded. There is no offset: narrow the window to read further back.
GET
/
v1
/
usage
/
ledger
Usage ledger
curl --request GET \
--url https://api.opentype.dev/v1/usage/ledger \
--header 'Authorization: Bearer <token>'const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.opentype.dev/v1/usage/ledger', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.opentype.dev/v1/usage/ledger"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text){
"organization_id": "<string>",
"window": {
"start_at": "<string>",
"end_at": "<string>"
},
"limit": 1,
"entries": [
{
"run_id": "<string>",
"retry_ordinal": 1,
"provider": "<string>",
"model_id": "<string>",
"status": "<string>",
"tokens": {
"input_tokens": 1,
"output_tokens": 1,
"total_tokens": 1
},
"cost_micros": 1,
"created_at": "<string>",
"provider_request_id": "<string>"
}
]
}Authorizations
bearerbearer
An API key (otsk_ + 64 hex) or a console session token.
Query Parameters
Window start, exactly YYYY-MM-DDTHH:MM:SSZ (UTC), inclusive. Send it with end_at; omit both for the current UTC calendar month.
Window end, exactly YYYY-MM-DDTHH:MM:SSZ (UTC), exclusive. Send it with start_at.
Entries to return. Defaults to 50; values above 200 are clamped to 200. 0 is refused.
Required range:
x >= 0Usage ledger
curl --request GET \
--url https://api.opentype.dev/v1/usage/ledger \
--header 'Authorization: Bearer <token>'const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.opentype.dev/v1/usage/ledger', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.opentype.dev/v1/usage/ledger"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text){
"organization_id": "<string>",
"window": {
"start_at": "<string>",
"end_at": "<string>"
},
"limit": 1,
"entries": [
{
"run_id": "<string>",
"retry_ordinal": 1,
"provider": "<string>",
"model_id": "<string>",
"status": "<string>",
"tokens": {
"input_tokens": 1,
"output_tokens": 1,
"total_tokens": 1
},
"cost_micros": 1,
"created_at": "<string>",
"provider_request_id": "<string>"
}
]
}