Bill
Updated at:2025-10-27
Generating billing statements and providing resource-level bills are the fundamental core functions of the Baidu AI Cloud Transaction System.
Java
1// Query the bills of the currently logged-in user
2public static void getBills(BillingClient billingClient) {
3 ResourceMonthBillRequest request = new ResourceMonthBillRequest();
4 // Set the month to which the bill belongs
5 request.setMonth("2019-02");
6 // Set to query postpaid bills
7 request.setProductType("postpay");
8 // Set to query resource bills for CDS products
9 request.setServiceType("CDS");
10 // Set pagination flag
11 request.setPageNo(1);
12 // Set size of paginated returned data
13 request.setPageSize(50);
14
15 ResourceMonthBillResponse response = billingClient.getResourceMonthBill(request);
16}
17 // Query the bills of the financial group sub-accounts under the current root account
18public static void getBills(BillingClient billingClient) {
19 ResourceMonthBillRequest request = new ResourceMonthBillRequest();
20 // Set the month to which the bill belongs
21 request.setMonth("2019-02");
22 // Set to query postpaid bills
23 request.setProductType("postpay");
24 // Set to query resource bills for CDS products
25 request.setServiceType("CDS");
26 // Set the accountId of the sub-account added to the financial group; the sub-account must belong to the same enterprise organization, otherwise the access will be deemed unauthorized
27 request.setQueryAccountId("XXX");
28 // Set pagination flag
29 request.setPageNo(1);
30 // Set size of paginated returned data
31 request.setPageSize(50);
32
33 ResourceMonthBillResponse response = billingClient.getResourceMonthBill(request);
34}
- A maximum of 100 bill records can be queried at a time.
- For querying bills on behalf of other accounts, only the root account is allowed to initiate the request, and the queried account must be a sub-account that is part of the financial group for enterprise financial management within the enterprise organization to which the root account belongs.
