Retrieve AI Aggregate Stats
GET/api/v1/stats/ai
Retrieve aggregated AI credit usage statistics for the Dashboard UI.
Authorization
- Regular users can only query their own stats (
user_idmust match JWT or be omitted). - Admin users can query any user or omit
user_idfor group-wide consolidated stats.
Response (consolidated, no user_id)
{
"usergroup_id": 100,
"period": 720,
"data": {
"*": {
"AI_CREDITS_USED": 342,
"AI_REQUESTS": 13
}
},
"credit_balance": 1158
}
Response (per-user, with user_id=42)
{
"usergroup_id": 100,
"period": 720,
"data": {
"42": {
"AI_CREDITS_USED": 34,
"AI_REQUESTS": 5
}
},
"credit_balance": 1158
}
Metric Keys
| Key | Description |
|---|---|
AI_CREDITS_USED | Total AI credits consumed in the period |
AI_REQUESTS | Number of AI Agent requests in the period |
Request
Responses
- 200
- 401
- 403
- 500
Successful operation
Unauthorized - Invalid or missing authentication
Forbidden - Insufficient permissions (non-admin querying other users)
Internal server error