Get Usage Summary
GET /environments/{env_id}/usage_summary
GET /environments/{env_id}/usage_summaryInteractive request editor loads with JavaScript.
Authorization
BearerAdminToken Organization-scoped admin token. Read operations require a valid token, and write operations require a token with write permission.
In: header
Path Parameters
Environment ID.
uuidQuery Parameters
Inclusive lower bound on occurred_at, RFC 3339.
date-timeExclusive upper bound on occurred_at, RFC 3339. Must be
strictly after from.
date-timeBucket key. day yields a UTC YYYY-MM-DD key; model
yields the model alias the caller addressed (the Model-Group
name for routed requests, a model id for rows from gateways
predating alias capture); api_key yields a caller API key
id. An empty key means the attribute was absent on the row.
Value in
- "day"
- "model"
- "api_key"
Response Body
application/json
application/json
application/json
application/json
application/json
curl -X GET "$AISIX_CP/environments/$ENV_ID/usage_summary?from=2026-08-01T00%3A00%3A00Z&to=2026-08-08T00%3A00%3A00Z&group_by=day" \ -H "Authorization: Bearer $AISIX_TOKEN"OK
{
"data": [
{
"key": "string",
"request_count": 0,
"success_count": 0,
"prompt_tokens": 0,
"completion_tokens": 0,
"cached_prompt_tokens": 0,
"reasoning_tokens": 0,
"cache_creation_tokens": 0,
"cache_read_tokens": 0,
"cache_hit_saved_input_tokens": 0,
"cache_hit_saved_output_tokens": 0,
"cost_usd": 0.1
}
]
}Request body or parameters failed validation.
{
"error": {
"code": "string",
"message": "string"
}
}Missing or invalid bearer.
{
"error": {
"code": "UNAUTHENTICATED",
"message": "no org context"
}
}Resource not found.
{
"error": {
"code": "NOT_FOUND",
"message": "provider key not found"
}
}The deployment is not configured to serve this data.
{
"error": {
"code": "DPMGR_UNAVAILABLE",
"message": "dp-manager node store not configured on this cp-api"
}
}Complete operation details and schema variants
GET /environments/{env_id}/usage_summary
Get Usage Summary
Roll the environment's usage up into one bucket per day, model or caller API key over the given window.
Counts are request-level: request_count is the number of
distinct requests in the bucket, not the number of upstream
attempts, so a request that retried or failed over counts once.
Token and cost figures are sums over the attempt rows, which
comes to the same thing because a failed attempt carries no
tokens and no cost.
A request whose attempts straddle a bucket boundary is counted in
both buckets, so summing buckets over-counts the window total —
read usage_metrics when you need a figure for the whole
window.
Parameters
-
env_id(path, string, required): Environment ID. -
from(query, string, required): Inclusive lower bound onoccurred_at, RFC 3339. -
to(query, string, required): Exclusive upper bound onoccurred_at, RFC 3339. Must be strictly afterfrom. -
group_by(query, string, required): Bucket key.dayyields a UTCYYYY-MM-DDkey;modelyields the model alias the caller addressed (the Model-Group name for routed requests, a model id for rows from gateways predating alias capture);api_keyyields a caller API key id. An empty key means the attribute was absent on the row.
Responses
-
200: OK -
data(array, required): -
data[].key(string, required): Bucket key, in the shapegroup_byselected: a UTCYYYY-MM-DDdate, a model alias, or a caller API key id. An empty string means the attribute was absent on those rows. -
data[].request_count(integer, required): -
data[].success_count(integer, required): Requests in the bucket with at least one 2xx attempt. A request that failed twice and then succeeded counts as one success here, not as two failures and a success. -
data[].prompt_tokens(integer, required): -
data[].completion_tokens(integer, required): -
data[].cached_prompt_tokens(integer, required): -
data[].reasoning_tokens(integer, required): -
data[].cache_creation_tokens(integer, required): -
data[].cache_read_tokens(integer, required): -
data[].cache_hit_saved_input_tokens(integer, required): -
data[].cache_hit_saved_output_tokens(integer, required): -
data[].cost_usd(number, required): -
400: Request body or parameters failed validation. -
error(object, required): Error details. -
error.code(string, required): Machine-readable identifier. Examples:UNAUTHENTICATED,INVALID_REQUEST,MASTER_KEY_UNSET,INTERNAL. -
error.message(string, required): Human-readable explanation; safe to surface to operators. -
401: Missing or invalid bearer. Response fields (application/json): identical toGET /environments/{env_id}/usage_summary, response 400 above. -
404: Resource not found. Response fields (application/json): identical toGET /environments/{env_id}/usage_summary, response 400 above. -
503: The deployment is not configured to serve this data. Response fields (application/json): identical toGET /environments/{env_id}/usage_summary, response 400 above.
cURL
curl -X GET '$AISIX_CP/environments/{env_id}/usage_summary' -H 'Authorization: Bearer $AISIX_TOKEN'