This Skill is used to query Cost Center bill data through the Volcengine Python SDK, and perform summary analysis around billing period, amortization month, date, instance, product, account, and split dimensions.
When to Use This Skill
When the user requests:
- Analyzing Volcengine bills, costs, and consumption trends
- Querying account-level bill overview information
- Querying product-level cost distribution
- Verifying bill details, instance fees, or bill types
- Querying amortized costs, amortized cost bills, or cost bill details
- Querying split bills, split item fees, or allocation results
Main Features
1. Account bill overview query
- Use
ListBillOverviewByCategoryto query the account-level bill overview - Suitable for first viewing the overall monthly bill amount and overall trends
2. Product monthly bill query
- Use
ListBillOverviewByProdto query monthly bills for a single product, multiple products, or all products - Supports paginated retrieval of the complete product list
- Suitable for identifying high-cost products and main sources of expenses
3. Bill details and split bill query
- Use
ListBillDetailto query bill details - Use
ListAmortizedCostBillDetailto query cost bill details - Use
ListSplitBillDetailto query split bills - Supports filtering by billing period, amortization month, date, product, account, instance, and split item
4. Configuration and invocation methods
- Supports environment variable configuration
AK/SK - Supports
.envfile configuration - Supports Python code invocation
- Supports direct invocation through standalone scripts under
scripts/Supports paginated retrieval and local summary analysis - Supports JSON structured result processing
- Processing logic
Bill query processing flow
Determine the interface according to the user's goal
- Use
- for the overall bill
ListBillOverviewByCategory - Use
ListBillOverviewByProd - for monthly product bills
ListBillDetail - Use
ListAmortizedCostBillDetail - for detail verification
ListSplitBillDetail
- for the overall bill
- Determine the billing period and date range according to time requirements
- Prioritize determining
BillPeriod - For cost bills, prioritize determining
AmortizedMonth - Supplement with
ExpenseDate - when a detailed single-day check is needed
AmortizedDay - Cross-month queries need to be split into multiple billing periods and queried separately
- Prioritize determining
- Assemble SDK request parameters according to filter conditions
- For example, product, account, instance, bill type, split item, etc.
- If it is a paginated interface, query in a loop
- Use
Offset + Limit + NeedRecordNumto paginate and retrieve the full amount - You can use
common.pyinfetch_all_pagesutility function to automatically turn pages
- Use
- Perform summary analysis on the results
- Output amounts, rankings, abnormal fluctuations, and items to be verified
Prerequisites
The Volcengine Python SDK needs to be installed:
pip install --upgrade "volcengine-python-sdk>=5.0.30"
Note:
- It is recommended to use the latest 5.x version
- Historical versions
4.0.1 ~ 4.0.42have SDK retry defects, so try not to continue using them
Configuration method
The Volcengine Access Key and Secret Key need to be configured. One of the following two methods is recommended:
Method 1: Environment variables
export VOLCENGINE_AK="your-ak"
export VOLCENGINE_SK="your-sk"
export VOLCENGINE_REGION="cn-beijing"
Method 2:.env file
In ~/.openclaw/workspace/.env configure:
VOLCENGINE_AK=your-ak
VOLCENGINE_SK=your-sk
VOLCENGINE_REGION=cn-beijing
Billing parameter description
Core billing query parameters
- BillPeriod: Billing period, in the format
YYYY-MM - ExpenseDate: Bill date, in the format
YYYY-MM-DD - AmortizedMonth: Allocation month, in the format
YYYY-MM - AmortizedDay: Allocation day, in the format
YYYY-MM-DD - Offset: Pagination offset
- Limit: Number per page, range
[1,300] - NeedRecordNum: Whether to return the total number of records,
1returnsTotal, otherwise it is usually-1 - IgnoreZero: Whether to ignore data with a discounted price of 0,
0do not ignore,1ignore - Product: Product filter condition. For optional product Codes, refer to
references/product-code.md
Key parameter enumeration values
| Parameter | Value | Meaning |
|---|---|---|
BillingMode |
1 |
Subscription |
2 |
Pay-as-you-go | |
3 |
Contract billing | |
4 |
Performance billing | |
BillCategoryParent |
consume |
Consumption |
refund |
Refund | |
transfer |
Adjustment | |
BillCategory |
consume-use |
Consumption-Usage |
consume-new |
Consumption-New purchase | |
consume-renew |
Consumption-Renewal | |
consume-formalize |
Consumption-Conversion to regular | |
consume-modify |
Consumption-Configuration change | |
consume-trial |
Consumption-Trial | |
refund-terminate |
Refund-Unsubscribe | |
refund-modify |
Refund-Configuration change | |
transfer-manual |
Adjustment-Manual | |
transfer-system |
Adjustment-System | |
GroupTerm |
0 |
Billing item |
1 |
Instance | |
2 |
Product | |
3 |
Account | |
GroupPeriod |
0 |
Billing period |
1 |
Daily | |
2 |
Details | |
AmortizedType |
1 |
Performance billing allocation |
2 |
Contract billing allocation | |
3 |
Pay-as-you-go billing allocation | |
4 |
New purchase allocation | |
5 |
Configuration change allocation | |
6 |
Renewal allocation | |
7 |
Unsubscribe allocation | |
8 |
Reserved instance adjustment allocation | |
9 |
Trial allocation | |
10 |
Conversion to regular allocation | |
SplitDimension |
JSON string | Split dimension, such as {"ark_bd":"apikey_id"}, an error will be reported if the product does not support multi-dimensional splitting |
Time parameter description
BillPeriodis the core time parameter for bill queries, queried by monthAmortizedMonthis the core time parameter for cost bill queries, queried by month- If a single-day filter is not specified, the query is performed by the whole month by default
- To query a certain day within a single month, you can add
ExpenseDate - To query the cost allocation for a certain day within a single month, you can add
AmortizedDay - If the user provides a cross-month date range, it needs to be split into multiple
BillPeriodfor separate queries and then aggregated - If the user provides a cross-month cost range, it needs to be split into multiple
AmortizedMonthfor separate queries and then aggregated
Pagination parameter description
ListBillOverviewByProdListBillDetailListAmortizedCostBillDetailListSplitBillDetail
The above four interfaces should all be handled with pagination.
Recommended strategy:
Offsetstarts from0StartLimitprefer100or300NeedRecordNumset to1- After each query completes, use
Offset += Limitto continue fetching - If the number returned is less than
Limit, or the cumulative count coversTotal, then end pagination - You can directly use
common.pythefetch_all_pagestool function to automatically paginate
fetch_all_pages Usage example:
from common import build_billing_api, fetch_all_pages
import volcenginesdkbilling
api = build_billing_api()
# 自动拉取全量账单明细
rows = fetch_all_pages(
api_instance=api,
request_cls=volcenginesdkbilling.ListBillDetailRequest,
list_method_name="list_bill_detail",
raw_kwargs={"BillPeriod": "2025-05"},
limit=100,
)
print(f"共拉取 {len(rows)} 条记录")
Returned fields quick reference
The return structure of all APIs is Result.List + Result.Total(paginated APIs); for complete field definitions, see references/billing-api-notes.md. The following are the most commonly used business fields for each API:
Common amount fields (ListBillOverviewByCategory / ListBillOverviewByProd / ListBillDetail)
| Field | Description | Common scenarios |
|---|---|---|
PayableAmount |
Amount payable | Cost ranking, general ledger reconciliation |
OriginalBillAmount |
Original price | Amount before discount |
DiscountBillAmount |
Discounted price | Post-discount basis |
PreferentialBillAmount |
Discount amount | Discounts excluding vouchers |
CouponAmount |
Voucher deduction | View separately from discount amount |
PaidAmount |
Amount paid | Reconciliation |
UnpaidAmount |
Outstanding amount | Identify unsettled amounts |
Common dimension fields (ListBillDetail / ListSplitBillDetail / ListAmortizedCostBillDetail)
| Field | Description | Common scenarios |
|---|---|---|
Product / ProductZh |
Product English / Chinese name | Aggregation by product dimension |
Region / RegionCode |
Region | Regional cost analysis |
Zone / ZoneCode |
Availability zone | Availability zone-level attribution |
InstanceNo / InstanceName |
Instance ID / name | Single-instance troubleshooting |
Project / ProjectDisplayName |
Project information | Cost attribution |
Tag |
Tag JSON | Tag attribution |
BillCategory |
Bill type | Distinguish consumption/refund/adjustment |
BillingMode |
Billing mode | Distinguish subscription/pay-as-you-go |
ConfigName |
Configuration name | SKU description |
ListSplitBillDetail-specific fields
| Field | Description | Remarks |
|---|---|---|
SplitItemID / SplitItemName |
Split item ID / name | Split billing primary key |
SplitItemAmount / SplitItemRatio |
Split item usage / proportion | Meaningful in detail mode |
CouponDeductionAmount |
Voucher deduction | Note: not CouponAmount |
ListAmortizedCostBillDetail-specific fields
| Field | Description | Remarks |
|---|---|---|
AmortizedMonth / AmortizedDay |
Allocation month / allocation day | Cost attribution time |
AmortizedType |
Allocation type | New purchase/renewal/configuration change, etc. |
DailyAmortizedPayableAmount |
Daily allocated amount payable | Main field for cost analysis |
DailyAmortizedDiscountBillAmount |
Daily allocated discounted price | Post-discount basis |
DailyAmortizedOriginalBillAmount |
Daily allocated original price | Original price basis |
Core API description
For the complete request parameter and response parameter definitions of each API, see references/billing-api-notes.md; the following are the minimal parameter templates.
1. ListBillOverviewByCategory
Query the account summary information of the bill overview.
Applicable scenarios:
- View the full monthly general ledger
- First look at the overall bill, then decide whether to drill down
SDK request parameter template:
# 账号账单总览查询参数
category_request = {
"BillPeriod": "2025-05"
}
2. ListBillOverviewByProd
Paginated query of monthly product bills.
Applicable scenarios:
- View product cost rankings (single-product, multi-product, and full-product monthly bills)
- Identify high-cost products
SDK request parameter template:
# 产品账单总览查询参数
prod_request = {
"BillPeriod": "2025-05",
"Limit": 100,
}
3. ListBillDetail
Paginated query of bill details.
Applicable scenarios:
- Verify the cost composition of a product or instance
- Check the cost details for a certain month, day, bill type, or instance
SDK request parameter template:
# 账单明细查询参数
detail_request = {
"BillPeriod": "2025-05",
"Limit": 100,
}
4. ListSplitBillDetail
Paginated query of split bills.
Applicable scenarios:
- Verify split-item costs
- Investigate split-billing results at the project, tag, or resource granularity
SDK request parameter template:
# 分账账单查询参数
split_request = {
"BillPeriod": "2025-05",
"Limit": 100,
}
5. ListAmortizedCostBillDetail
Paginated query of cost bill details.
Applicable scenarios:
- View amortized costs
- Verify product, instance, and bill type costs under the amortization basis
SDK request parameter template:
# 成本账单明细查询参数
amortized_detail_request = {
"AmortizedMonth": "2025-05",
"Limit": 100,
}
Note:
- The core time field of this API is
AmortizedMonth/AmortizedDay, not theBillPeriod/ExpenseDate BillPeriodin this API is an optional filter condition and cannot replaceAmortizedMonth
Script directory
The Skill has extracted the call examples of the 5 APIs into standalone scripts, located in the scripts/ directory:
scripts/list_bill_overview_by_category.pyscripts/list_bill_overview_by_prod.pyscripts/list_bill_detail.pyscripts/list_amortized_cost_bill_detail.pyscripts/list_split_bill_detail.pyscripts/common.py
Note:
common.pyis responsible for loading.env, initializing the Billing SDK, uniformly outputting JSON, and providing thefetch_all_pagespagination utility function- All 5 API scripts support command-line parameter invocation, and the parameter names by default match the request parameter names in the API documentation
- Array-type parameters are entered using "repeated parameter passing", for example, repeatedly passing
--Product - The pagination script validates the month format, the month to which the date belongs, the
Limitrange, and theSplitDimensionJSON format locally - All optional parameters are passed as needed; if not passed, they do not appear in the request body
Request call examples
Account overview
python3 scripts/list_bill_overview_by_category.py \
--BillPeriod 2025-05
Product overview
# 最小调用
python3 scripts/list_bill_overview_by_prod.py \
--BillPeriod 2025-05 \
--Limit 100
# 按产品筛选
python3 scripts/list_bill_overview_by_prod.py \
--BillPeriod 2025-05 \
--Limit 100 \
--Product ECS --Product VKE
Bill details
# 最小调用
python3 scripts/list_bill_detail.py \
--BillPeriod 2025-05 \
--Limit 100
# 按天 + 按产品 + 按实例筛选
python3 scripts/list_bill_detail.py \
--BillPeriod 2025-05 \
--Limit 100 \
--ExpenseDate 2025-05-15 \
--Product ECS \
--InstanceNo i-xxxxxxxx
Split bill details
# 最小调用
python3 scripts/list_split_bill_detail.py \
--BillPeriod 2025-05 \
--Limit 100
# 按标签维度分账
python3 scripts/list_split_bill_detail.py \
--BillPeriod 2025-05 \
--Limit 100 \
--SplitDimension '{"TOS":"project"}'
Cost bill details
# 最小调用
python3 scripts/list_amortized_cost_bill_detail.py \
--AmortizedMonth 2025-05 \
--Limit 100
# 按天 + 按分摊类型筛选
python3 scripts/list_amortized_cost_bill_detail.py \
--AmortizedMonth 2025-05 \
--Limit 100 \
--AmortizedDay 2025-05-15 \
--AmortizedType 4
Reference materials
- Local preparation notes:
references/install.md - API request parameter and response parameter reference documentation:
references/billing-api-notes.md - Product Code mapping table:
references/product-code.md - Official Python SDK installation package:
volcengine-python-sdk