Get grouped usage¶
Aggregate the current user’s usage by user, model, or credential.
GET https://billing.moi.matrixorigin.cn/api/v1/taas/usage-logs/group-by
Before you begin¶
Prepare a personal access token. For creation and management, see Manage personal access tokens.
Results are scoped to data accessible to the current user.
Query parameters¶
Replace $MOI_PERSONAL_ACCESS_TOKEN in the example with your personal access token.
curl --get "https://billing.moi.matrixorigin.cn/api/v1/taas/usage-logs/group-by" \
-H "X-API-Key: $MOI_PERSONAL_ACCESS_TOKEN" \
--data-urlencode "group_by=model" \
--data-urlencode "page_size=2"
Save the returned next_page_token as $NEXT_PAGE_TOKEN, retain the same filters, and request the next page. Stop when this value is empty or omitted.
curl --get "https://billing.moi.matrixorigin.cn/api/v1/taas/usage-logs/group-by" \
-H "X-API-Key: $MOI_PERSONAL_ACCESS_TOKEN" \
--data-urlencode "group_by=model" \
--data-urlencode "page_size=2" \
--data-urlencode "page_token=$NEXT_PAGE_TOKEN"
Parameter |
Type |
Required |
Description |
|---|---|---|---|
|
integer |
No |
Start time in nonnegative Unix seconds; must not exceed |
|
integer |
No |
End time in nonnegative Unix seconds. |
|
string |
No |
Catalog model object ID. |
|
string |
No |
Model type. |
|
string |
No |
Model name submitted in the inference request. |
|
string |
No |
Call status, such as |
|
string |
No |
Call error category. |
|
string |
No |
Caller IP address. |
|
string |
No |
TaaS local token key ID. |
|
string |
No |
TaaS local key IDs; repeat the parameter or comma-separate values. |
|
string |
Required with |
Credential type: |
|
string |
Required with |
Credential object ID; requires |
|
string |
No |
Billing usage-event ID. |
|
string |
No |
Billing record ID. |
|
string |
No |
Pricing mode. |
|
string |
No |
Settlement method: genesis or |
|
string |
No |
Enterprise plan ID. |
|
string |
No |
Enterprise contract number. |
|
string |
No |
Enterprise plan model ID. |
|
string |
No |
Responses response ID. |
|
string |
No |
Conversation ID. |
|
string |
No |
Usage log IDs; repeat the parameter or comma-separate values. |
|
string |
No |
Alias for ids; values are combined. |
|
string |
No |
Provider ID; results remain scoped to the current user. |
|
string |
No |
Grouping: user, model, or |
|
integer |
No |
Page size; default 100, maximum 1000. |
|
string |
No |
Next-page token from the previous response; omit for the first request. |
Successful response¶
Returns HTTP 200 with call statistics grouped by the selected dimension.
{
"items": [
{
"group_id": "model_example",
"group_name": "Example Chat",
"total_calls": 2,
"total_input_tokens": 12,
"total_output_tokens": 8,
"cache_read_tokens": 0,
"cache_creation_tokens": 0,
"total_cost": "0.0001",
"total_channel_cost": "0.00005",
"total_channel_tokens": 20,
"success_calls": 2,
"failed_calls": 0,
"success_rate": 1,
"success_count": 2,
"total_cache_read_tokens": 0,
"total_cache_creation_tokens": 0,
"avg_latency_ms": 120
}
],
"total": 1,
"next_page_token": ""
}
Field |
Type |
Description |
|---|---|---|
|
array of object |
Records on this page. |
|
string |
Group identifier. |
|
string |
Group display name. |
|
integer |
Total call count. |
|
integer |
Total input tokens. |
|
integer |
Total output tokens. |
|
integer |
Total cache-read tokens. |
|
integer |
Total cache-creation tokens. |
|
string |
Total call cost as a decimal string. |
|
string |
Total cost of associated upstream requests. |
|
integer |
Input, output, and cache tokens across associated upstream requests. |
|
integer |
Successful call count. |
|
integer |
Non-successful call count. |
|
number |
Successful calls divided by total calls; 0 when there are no calls. |
|
integer |
Alias of |
|
integer |
Alias of |
|
integer |
Alias of |
|
integer |
Average |
|
object |
Credential identity when grouped by credential. |
|
string |
Credential type: |
|
string |
Credential object ID. |
|
string |
Service account ID; returned for service-account credentials. |
|
string |
Current credential name, when metadata is available. |
|
string |
Service account name, when metadata is available. |
|
integer |
Total records matching the filters. |
|
string |
Next-page token; empty or omitted on the last page. |
In field paths, [] denotes each array item.
Error response¶
{
"code": 400,
"message": "provider grouping is only available from admin APIs"
}
Field |
Type |
Description |
|---|---|---|
|
integer |
HTTP error status. |
|
string |
Error description. |