Skip to main content

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​

MethodDescription
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​

ParameterTypeRequiredDefaultDescription
startTimestringYes--Window start, YYYY-MM-DD HH:mm:ss
endTimestringYes--Window end, YYYY-MM-DD HH:mm:ss
pageNumnumberNo1Page number, starting from 1
pageSizenumberNo10Items per page
userIdnumberNo--Filter to a single customer user id
userNamestringNo--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​

CodeExceptionWhen
1001ValidationErrorInvalid time-window or pagination
2007PermissionErrorAdmin lacks Billing permission
3001AuthenticationErrorSession 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​

ParameterTypeRequiredDefaultDescription
startTimestringYes--Window start, YYYY-MM-DD HH:mm:ss
endTimestringYes--Window end, YYYY-MM-DD HH:mm:ss
userIdnumberNo--Filter to a single customer user id
userNamestringNo--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​

ParameterTypeRequiredDefaultDescription
startTimestringYes--Window start, YYYY-MM-DD HH:mm:ss
endTimestringYes--Window end, YYYY-MM-DD HH:mm:ss
pageNumnumberNo1Page number, starting from 1
pageSizenumberNo10Items per page
providerstringNo--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​

ParameterTypeRequiredDefaultDescription
startTimestringYes--Window start, YYYY-MM-DD HH:mm:ss
endTimestringYes--Window end, YYYY-MM-DD HH:mm:ss
providerstringNo--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​

ParameterTypeRequiredDefaultDescription
startDatestringYes--Window start, YYYY-MM-DD
endDatestringYes--Window end, YYYY-MM-DD
pageNumnumberNo1Page number, starting from 1
pageSizenumberNo10Items per page
modelIdstringNo--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​

ParameterTypeRequiredDefaultDescription
startDatestringYes--Window start, YYYY-MM-DD
endDatestringYes--Window end, YYYY-MM-DD
modelIdstringNo--Filter by model id

Response​

Returns an object with aggregate totals.

Errors​

Same as customerList.