Admin Billing — TypeScript SDK
Admin-scope billing reports: Customer, Provider, and RS (Resource Service).
Overview
The admin Billing resource exposes three billing report families, each with a paginated list and an aggregate total:
- Customer Billing — spend rolled up by end-customer (bizUser)
- Provider Billing — spend rolled up by upstream model provider
- RS Billing — spend rolled up by resource service (fine-grained)
Customer and Provider Billing use full timestamps (startTime / endTime, YYYY-MM-DD HH:mm:ss); RS Billing uses date-only (startDate / endDate, YYYY-MM-DD).
Accessed via admin.billing.
Available Operations
| Method | Description |
|---|---|
customerList() | Customer Billing rows (paginated) |
customerTotal() | Customer Billing aggregate total |
providerList() | Provider Billing rows (paginated) |
providerTotal() | Provider Billing aggregate total |
rsList() | RS Billing rows (paginated) |
rsTotal() | RS Billing aggregate total |
customerList
Paginated Customer Billing rows for a time window.
Example Usage
const result = await admin.billing.customerList({
startTime: '2026-06-01 00:00:00',
endTime: '2026-06-30 23:59:59',
pageNum: 1,
pageSize: 20,
});
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| startTime | string | Yes | -- | Window start, YYYY-MM-DD HH:mm:ss |
| endTime | string | Yes | -- | Window end, YYYY-MM-DD HH:mm:ss |
| pageNum | number | No | 1 | Page number, starting from 1 |
| pageSize | number | No | 10 | Items per page |
| userId | number | No | -- | Filter to a single customer user id |
| userName | string | No | -- | Fuzzy filter by customer userName |
Response
Returns an object with total, list, totalPages, currentPage, pageSize. Each row aggregates a customer's spend over the window.
Errors
| Code | Exception | When |
|---|---|---|
1001 | ValidationError | Invalid time-window or pagination |
2007 | PermissionError | Admin lacks Billing permission |
3001 | AuthenticationError | Session expired and refresh failed |
customerTotal
Aggregate Customer Billing total for a time window.
Example Usage
const total = await admin.billing.customerTotal({
startTime: '2026-06-01 00:00:00',
endTime: '2026-06-30 23:59:59',
});
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| startTime | string | Yes | -- | Window start, YYYY-MM-DD HH:mm:ss |
| endTime | string | Yes | -- | Window end, YYYY-MM-DD HH:mm:ss |
| userId | number | No | -- | Filter to a single customer user id |
| userName | string | No | -- | Fuzzy filter by customer userName |
Response
Returns an object with aggregate totals (pretaxAmount, afterDiscountAmount, currency, ...).
Errors
Same as customerList.
providerList
Paginated Provider Billing rows for a time window.
Example Usage
const result = await admin.billing.providerList({
startTime: '2026-06-01 00:00:00',
endTime: '2026-06-30 23:59:59',
pageNum: 1,
pageSize: 20,
});
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| startTime | string | Yes | -- | Window start, YYYY-MM-DD HH:mm:ss |
| endTime | string | Yes | -- | Window end, YYYY-MM-DD HH:mm:ss |
| pageNum | number | No | 1 | Page number, starting from 1 |
| pageSize | number | No | 10 | Items per page |
| provider | string | No | -- | Filter by provider id (e.g. dashscope) |
Response
Returns an object with total, list, and pagination fields. Each row aggregates one provider's spend over the window.
Errors
Same as customerList.
providerTotal
Aggregate Provider Billing total for a time window.
Example Usage
const total = await admin.billing.providerTotal({
startTime: '2026-06-01 00:00:00',
endTime: '2026-06-30 23:59:59',
});
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| startTime | string | Yes | -- | Window start, YYYY-MM-DD HH:mm:ss |
| endTime | string | Yes | -- | Window end, YYYY-MM-DD HH:mm:ss |
| provider | string | No | -- | Filter by provider id |
Response
Returns an object with aggregate totals.
Errors
Same as customerList.
rsList
Paginated RS (Resource Service) Billing rows for a date range.
Example Usage
const result = await admin.billing.rsList({
startDate: '2026-06-01',
endDate: '2026-06-30',
pageNum: 1,
pageSize: 20,
});
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| startDate | string | Yes | -- | Window start, YYYY-MM-DD |
| endDate | string | Yes | -- | Window end, YYYY-MM-DD |
| pageNum | number | No | 1 | Page number, starting from 1 |
| pageSize | number | No | 10 | Items per page |
| modelId | string | No | -- | Filter by model id |
Response
Returns an object with total, list, and pagination fields. Each row aggregates one resource-service's spend over the date range.
Errors
Same as customerList.
rsTotal
Aggregate RS Billing total for a date range.
Example Usage
const total = await admin.billing.rsTotal({
startDate: '2026-06-01',
endDate: '2026-06-30',
});
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| startDate | string | Yes | -- | Window start, YYYY-MM-DD |
| endDate | string | Yes | -- | Window end, YYYY-MM-DD |
| modelId | string | No | -- | Filter by model id |
Response
Returns an object with aggregate totals.
Errors
Same as customerList.