curl --request GET \
--url https://api.opper.ai/management/v1/usage \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.opper.ai/management/v1/usage"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.opper.ai/management/v1/usage', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"data": [
{
"api_key_id": 123,
"api_key_name": "<string>",
"bucket": "2023-11-07T05:31:56Z",
"cache_creation_tokens": 123,
"cache_read_tokens": 123,
"cache_savings": 123,
"completion_tokens": 123,
"cost": 123,
"count": 123,
"duration_ms_sum": 123,
"errors_other": 123,
"errors_policy": 123,
"errors_provider": 123,
"errors_rate_limited": 123,
"evals_cost": 123,
"group": "<string>",
"guards_cost": 123,
"last_called_at": "2023-11-07T05:31:56Z",
"project_name": "<string>",
"project_uuid": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"prompt_tokens": 123,
"total_cost": 123,
"total_tokens": 123
}
],
"meta": {
"bucket": "<string>",
"currency": "USD",
"from": "2023-11-07T05:31:56Z",
"group_by": "<string>",
"project_uuid": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"to": "2023-11-07T05:31:56Z",
"total_count": 123
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"details": "<unknown>"
},
"meta": {}
}{
"error": "<string>",
"required_scope": "<string>"
}{
"error": "<string>"
}{
"error": {
"code": "<string>",
"message": "<string>",
"details": "<unknown>"
},
"meta": {}
}Get usage and cost
Calls, tokens and cost for the calling organization over a window of at most 31 days, or for one of its projects with project_uuid, optionally grouped by API key, model, provider or project and split into hourly or daily UTC buckets. The figures are the ones the platform’s usage pages show. count, the token sums and cost cover model calls; evals_cost and guards_cost are what evaluations and guard or routing checks cost, and total_cost is all three. Grouped by api_key_id, each row carries the key’s id and, while the key exists, its name; calls made without a key have neither. Grouped by project, each row carries the project’s UUID and name. Grouped totals are ranked by total_cost, most first. Web search surcharges are not included. Requires the usage:read scope.
curl --request GET \
--url https://api.opper.ai/management/v1/usage \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.opper.ai/management/v1/usage"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.opper.ai/management/v1/usage', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"data": [
{
"api_key_id": 123,
"api_key_name": "<string>",
"bucket": "2023-11-07T05:31:56Z",
"cache_creation_tokens": 123,
"cache_read_tokens": 123,
"cache_savings": 123,
"completion_tokens": 123,
"cost": 123,
"count": 123,
"duration_ms_sum": 123,
"errors_other": 123,
"errors_policy": 123,
"errors_provider": 123,
"errors_rate_limited": 123,
"evals_cost": 123,
"group": "<string>",
"guards_cost": 123,
"last_called_at": "2023-11-07T05:31:56Z",
"project_name": "<string>",
"project_uuid": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"prompt_tokens": 123,
"total_cost": 123,
"total_tokens": 123
}
],
"meta": {
"bucket": "<string>",
"currency": "USD",
"from": "2023-11-07T05:31:56Z",
"group_by": "<string>",
"project_uuid": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"to": "2023-11-07T05:31:56Z",
"total_count": 123
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"details": "<unknown>"
},
"meta": {}
}{
"error": "<string>",
"required_scope": "<string>"
}{
"error": "<string>"
}{
"error": {
"code": "<string>",
"message": "<string>",
"details": "<unknown>"
},
"meta": {}
}