Admin Billing — Python 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 (start_time / end_time, YYYY-MM-DD HH:mm:ss); RS Billing uses date-only (start_date / end_date, YYYY-MM-DD).
Accessed via admin.billing.
Available Operations
| Method | Description |
|---|---|
customer_list() | Customer Billing rows (paginated) |
customer_total() | Customer Billing aggregate total |
provider_list() | Provider Billing rows (paginated) |
provider_total() | Provider Billing aggregate total |
rs_list() | RS Billing rows (paginated) |
rs_total() | RS Billing aggregate total |
customer_list
Paginated Customer Billing rows for a time window.
Example Usage
result = admin.billing.customer_list(
start_time="2026-06-01 00:00:00",
end_time="2026-06-30 23:59:59",
page_num=1,
page_size=20,
)
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| start_time | str | Yes | -- | Window start, YYYY-MM-DD HH:mm:ss |
| end_time | str | Yes | -- | Window end, YYYY-MM-DD HH:mm:ss |
| page_num | int | No | 1 | Page number, starting from 1 |
| page_size | int | No | 10 | Items per page |
| user_id | int | No | -- | Filter to a single customer user id |
| user_name | str | No | -- | Fuzzy filter by customer userName |
Response
Returns a dict 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 |
customer_total
Aggregate Customer Billing total for a time window.
Example Usage
total = admin.billing.customer_total(
start_time="2026-06-01 00:00:00",
end_time="2026-06-30 23:59:59",
)
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| start_time | str | Yes | -- | Window start, YYYY-MM-DD HH:mm:ss |
| end_time | str | Yes | -- | Window end, YYYY-MM-DD HH:mm:ss |
| user_id | int | No | -- | Filter to a single customer user id |
| user_name | str | No | -- | Fuzzy filter by customer userName |
Response
Returns a dict with aggregate totals (pretaxAmount, afterDiscountAmount, currency, ...).
Errors
Same as customer_list.
provider_list
Paginated Provider Billing rows for a time window.
Example Usage
result = admin.billing.provider_list(
start_time="2026-06-01 00:00:00",
end_time="2026-06-30 23:59:59",
page_num=1,
page_size=20,
)
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| start_time | str | Yes | -- | Window start, YYYY-MM-DD HH:mm:ss |
| end_time | str | Yes | -- | Window end, YYYY-MM-DD HH:mm:ss |
| page_num | int | No | 1 | Page number, starting from 1 |
| page_size | int | No | 10 | Items per page |
| provider | str | No | -- | Filter by provider id (e.g. dashscope) |
Response
Returns a dict with total, list, and pagination fields. Each row aggregates one provider's spend over the window.
Errors
Same as customer_list.
provider_total
Aggregate Provider Billing total for a time window.
Example Usage
total = admin.billing.provider_total(
start_time="2026-06-01 00:00:00",
end_time="2026-06-30 23:59:59",
)
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| start_time | str | Yes | -- | Window start, YYYY-MM-DD HH:mm:ss |
| end_time | str | Yes | -- | Window end, YYYY-MM-DD HH:mm:ss |
| provider | str | No | -- | Filter by provider id |
Response
Returns a dict with aggregate totals.
Errors
Same as customer_list.
rs_list
Paginated RS (Resource Service) Billing rows for a date range.
Example Usage
result = admin.billing.rs_list(
start_date="2026-06-01",
end_date="2026-06-30",
page_num=1,
page_size=20,
)
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| start_date | str | Yes | -- | Window start, YYYY-MM-DD |
| end_date | str | Yes | -- | Window end, YYYY-MM-DD |
| page_num | int | No | 1 | Page number, starting from 1 |
| page_size | int | No | 10 | Items per page |
| model_id | str | No | -- | Filter by model id |
Response
Returns a dict with total, list, and pagination fields. Each row aggregates one resource-service's spend over the date range.
Errors
Same as customer_list.
rs_total
Aggregate RS Billing total for a date range.
Example Usage
total = admin.billing.rs_total(
start_date="2026-06-01",
end_date="2026-06-30",
)
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| start_date | str | Yes | -- | Window start, YYYY-MM-DD |
| end_date | str | Yes | -- | Window end, YYYY-MM-DD |
| model_id | str | No | -- | Filter by model id |
Response
Returns a dict with aggregate totals.
Errors
Same as customer_list.