账单 — Python SDK
查询月度账单汇总及各资源明细。
概览
Billing 资源提供租户月度账单周期数据:总金额汇总、按 GPU 规格及 AI 服务分页的明细,以及完整的逐实例账单列表。所有查询均限定在 YYYY-MM 账单周期内。
通过 client.billing 访问。
可用操作
| 方法 | 说明 |
|---|---|
queryAllAmount() | 查询账单周期总金额 |
queryBillByGpu() | 按 GPU 规格查询账单明细 |
queryBillByService() | 按 AI 服务查询账单明细 |
queryBillList() | 查询账单明细列表 |
queryAllAmount
查询指定账单周期的总金额。
使用示例
from wlt import WltClient
client = WltClient(api_key="your-api-key", base_url="https://console.example.com")
bill = client.billing.query_all_amount(billing_cycle="2026-04")
print(f"Total amount: {bill.data.pretaxAmountSum}")
print(f"Currency: {bill.data.currency}")
参数
| 参数 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
| billing_cycle | str | 是 | -- | 账单周期,格式为 "YYYY-MM",例如 "2026-04" |
响应
返回 BaseResponse[UserBillingMonthResponse]。
UserBillingMonthResponse 字段:
| 字段 | 类型 | 说明 |
|---|---|---|
| afterDiscountAmountSum | Decimal | 折后金额 |
| deductedByCouponsSum | Decimal | 优惠券抵扣金额 |
| pretaxGrossAmountSum | Decimal | 原始金额(标价) |
| pretaxAmountSum | Decimal | 应付金额 |
| currency | str | 币种代码,例如 "USD" |
错误
| 代码 | 异常 | 发生条件 |
|---|---|---|
1001 | ValidationError | 请求参数无效 |
2000 / 2002 | AuthenticationError | API 密钥无效 |
2007 | PermissionError | 权限不足 |
3001 | AuthenticationError | 令牌过期且刷新失败 |
queryBillByGpu
按 GPU 规格分页查询账单明细。
使用示例
from wlt import WltClient
client = WltClient(api_key="your-api-key", base_url="https://console.example.com")
result = client.billing.query_bill_by_gpu(
billing_cycle="2026-04",
page_size=10,
page_num=1,
)
for item in result.data.list:
print(f"GPU: {item.gpuSpec}, Amount: {item.pretaxAmountSum}")
参数
| 参数 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
| billing_cycle | str | 是 | -- | 账单周期,格式为 "YYYY-MM" |
| page_size | int | 否 | 10 | 每页条数 |
| page_num | int | 否 | 1 | 页码,从 1 开始 |
响应
返回 BaseResponse[PageInfo[UserBillingGpuServiceResponse]]。
UserBillingGpuServiceResponse 字段:
| 字段 | 类型 | 说明 |
|---|---|---|
| afterDiscountAmountSum | Decimal | 折后金额 |
| deductedByCouponsSum | Decimal | 优惠券抵扣金额 |
| pretaxGrossAmountSum | Decimal | 原始金额 |
| pretaxAmountSum | Decimal | 应付金额 |
| listPrice | Decimal | 标价(单价) |
| currency | str | 币种代码 |
| gpuSpec | str | GPU 规格,例如 "A100-80G" |
| servicePeriodUnit | str | 服务时长单位,例如 "Hour" |
| servicePeriodSum | str | 总服务时长 |
| modelResource | str | 模型资源标识符 |
错误
| 代码 | 异常 | 发生条件 |
|---|---|---|
1001 | ValidationError | 请求参数无效 |
2000 / 2002 | AuthenticationError | API 密钥无效 |
2007 | PermissionError | 权限不足 |
3001 | AuthenticationError | 令牌过期且刷新失败 |
queryBillByService
按 AI 服务分页查询账单明细。
使用示例
from wlt import WltClient
client = WltClient(api_key="your-api-key", base_url="https://console.example.com")
result = client.billing.query_bill_by_service(
billing_cycle="2026-04",
page_size=10,
page_num=1,
)
for item in result.data.list:
print(f"Service: {item.bizType}, Amount: {item.pretaxAmountSum}")
参数
| 参数 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
| billing_cycle | str | 是 | -- | 账单周期,格式为 "YYYY-MM" |
| page_size | int | 否 | 10 | 每页条数 |
| page_num | int | 否 | 1 | 页码,从 1 开始 |
响应
返回 BaseResponse[PageInfo[UserBillingAiServiceResponse]]。
UserBillingAiServiceResponse 字段:
| 字段 | 类型 | 说明 |
|---|---|---|
| afterDiscountAmountSum | Decimal | 折后金额 |
| deductedByCouponsSum | Decimal | 优惠券抵扣金额 |
| pretaxGrossAmountSum | Decimal | 原始金额 |
| pretaxAmountSum | Decimal | 应付金额 |
| currency | str | 币种代码 |
| gpuSpec | str | GPU 规格 |
| modelResource | str | 模型资源标识符 |
| servicePeriodUnit | str | 服务时长单位 |
| servicePeriodSum | str | 总服务时长 |
| bizType | str | 业务类型,例如 "Deploy"、"Finetune" |
错误
| 代码 | 异常 | 发生条件 |
|---|---|---|
1001 | ValidationError | 请求参数无效 |
2000 / 2002 | AuthenticationError | API 密钥无效 |
2007 | PermissionError | 权限不足 |
3001 | AuthenticationError | 令牌过期且刷新失败 |
queryBillList
分页查询账单明细列表。
使用示例
from wlt import WltClient
client = WltClient(api_key="your-api-key", base_url="https://console.example.com")
result = client.billing.query_bill_list(
billing_cycle="2026-04",
page_size=20,
page_num=1,
)
print(f"Total records: {result.data.total}")
for item in result.data.list:
print(item)
参数
| 参数 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
| billing_cycle | str | 是 | -- | 账单周期,格式为 "YYYY-MM" |
| page_size | int | 否 | 10 | 每页条数 |
| page_num | int | 否 | 1 | 页码,从 1 开始 |
响应
返回 BaseResponse[PageInfo[UserBillingResponse]]。
UserBillingResponse 字段:
| 字段 | 类型 | 说明 |
|---|---|---|
| afterDiscountAmount | Decimal | 折后金额 |
| deductedByCoupons | Decimal | 优惠券抵扣金额 |
| pretaxGrossAmount | Decimal | 原始金额 |
| pretaxAmount | Decimal | 应付金额 |
| instanceID | str | 实例 ID |
| currency | str | 币种代码 |
| productCode | str | 产品代码 |
| region | str | 地域 |
| gpuSpec | str | GPU 规格 |
| modelResource | str | 模型资源标识符 |
| servicePeriodUnit | str | 服务时长单位 |
| servicePeriod | str | 服务时长 |
| bizType | str | 业务类型,例如 "Deploy"、"Finetune" |
错误
| 代码 | 异常 | 发生条件 |
|---|---|---|
1001 | ValidationError | 请求参数无效 |
2000 / 2002 | AuthenticationError | API 密钥无效 |
2007 | PermissionError | 权限不足 |
3001 | AuthenticationError | 令牌过期且刷新失败 |