Payment — Python SDK
Query recharge records, balance statistics, and per-model usage billing.
Overview
The Payment resource covers two related areas: recharge transactions (records, statistics, single lookup by transaction number) and per-model usage billing (paginated list and aggregated total). Recharge endpoints accept datetime; model-usage billing endpoints accept formatted time strings.
Accessed via client.payment.
Available Operations
| Method | Description |
|---|---|
records() | Query recharge records with pagination |
statistics() | Query recharge statistics summary |
getRecord() | Get a single recharge record by transaction number |
billingList() | Query model usage billing list |
billingQueryAllAmount() | Query model usage billing total amount |
records
Query recharge records with pagination.
Example Usage
from wlt import WltClient
from datetime import datetime
client = WltClient(api_key="your-api-key", base_url="https://console.example.com")
# List successful recharge records
result = client.payment.records(
page_num=1,
page_size=10,
status_list=["1"], # 0=processing, 1=success, 2=failed, 3=closed
)
print(f"Total: {result.data.total}")
for record in result.data.list:
print(record.transactionNo, record.amount, record.status)
# With time range and transaction type
result = client.payment.records(
start_time=datetime(2026, 4, 1),
end_time=datetime(2026, 4, 21),
transaction_type="Recharge",
)
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| page_num | int | No | 1 | Page number, starting from 1 |
| page_size | int | No | 10 | Items per page (max 1000) |
| status_list | list[str] | No | None | Status filter: "0"=processing, "1"=success, "2"=failed, "3"=closed |
| start_time | datetime | No | None | Query start time |
| end_time | datetime | No | None | Query end time |
| transaction_type | str | No | None | Transaction type: "Recharge" or "Refund" |
Response
Returns BaseResponse[PageResponse] where the list field contains RechargeTransactionResponse items.
PageResponse fields (Payment-specific pagination):
| Field | Type | Description |
|---|---|---|
| pageNum | int | Current page number |
| pageSize | int | Items per page |
| total | int | Total record count |
| pages | int | Total number of pages |
| hasNext | bool | Whether there is a next page |
| hasPrevious | bool | Whether there is a previous page |
| list | list | Data list |
RechargeTransactionResponse fields:
| Field | Type | Description |
|---|---|---|
| id | int | Record primary key ID |
| createdAtUtc | str | Creation time (UTC) |
| updatedAtUtc | str | Update time (UTC) |
| userId | int | User ID |
| payChannel | str | Payment channel (e.g. "Stripe") |
| payType | str | Payment type (APP / WEB) |
| transactionType | str | Transaction type (Recharge / Refund) |
| status | str | Status: 0=processing, 1=success, 2=failed, 3=closed |
| callbackAtUtc | str | Callback time (UTC) |
| transactionNo | str | Platform transaction number |
| externalNo | str | External transaction number (Stripe ID) |
| amount | str | Transaction amount |
| refundAmount | str | Refunded amount |
| currency | str | Currency (ISO 4217) |
| refundStatus | str | Refund status: 0=none, 1=partial, 2=full |
| originalTransactionNo | str | Original transaction number (for refund records) |
| extend | str | Extension field (JSON) |
Errors
| Code | Exception | When |
|---|---|---|
2000 / 2002 | AuthenticationError | API Key invalid |
2007 | PermissionError | Permission denied |
3001 | AuthenticationError | Token expired and refresh failed |
statistics
Query recharge statistics summary.
Example Usage
from wlt import WltClient
client = WltClient(api_key="your-api-key", base_url="https://console.example.com")
stats = client.payment.statistics()
print(f"Total recharged: {stats.data.totalRechargedAmount}")
Parameters
None.
Response
Returns BaseResponse[RechargeStatisticsResponse].
RechargeStatisticsResponse fields:
| Field | Type | Description |
|---|---|---|
| totalRechargedAmount | str | Total recharged amount |
| totalUsedRechargedAmount | str | Total used recharged amount |
| totalBalanceRechargedAmount | str | Unused recharge balance |
| totalRefundAmount | str | Total refund amount |
| totalFreeAmount | str | Free quota amount |
| currency | str | Currency code |
Errors
| Code | Exception | When |
|---|---|---|
2000 / 2002 | AuthenticationError | API Key invalid |
2007 | PermissionError | Permission denied |
3001 | AuthenticationError | Token expired and refresh failed |
getRecord
Get a single recharge record by transaction number.
Example Usage
from wlt import WltClient
client = WltClient(api_key="your-api-key", base_url="https://console.example.com")
record = client.payment.get_record(transaction_no="TXN20260421001")
print(f"Amount: {record.data.amount}")
print(f"Status: {record.data.status}")
print(f"Created: {record.data.createdAtUtc}")
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| transaction_no | str | Yes | -- | Platform transaction number |
Response
Returns BaseResponse[RechargeTransactionResponse].
RechargeTransactionResponse fields: see
client.payment.records()above.
Errors
| Code | Exception | When |
|---|---|---|
1001 | ValidationError | Invalid request parameters |
1002 | NotFoundError | Transaction not found |
2000 / 2002 | AuthenticationError | API Key invalid |
2007 | PermissionError | Permission denied |
3001 | AuthenticationError | Token expired and refresh failed |
billingList
Query model usage billing list with pagination.
Example Usage
from wlt import WltClient
client = WltClient(api_key="your-api-key", base_url="https://console.example.com")
result = client.payment.billing_list(
page_num=1,
page_size=10,
start_time="2026-04-01 00:00:00",
end_time="2026-04-21 23:59:59",
)
print(f"Total: {result.data.total}")
for item in result.data.list:
print(item.modelName, item.amount)
# Filter by model
result = client.payment.billing_list(
start_time="2026-04-01 00:00:00",
end_time="2026-04-21 23:59:59",
model_id="qwen-turbo",
)
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| page_num | int | No | 1 | Page number, starting from 1 |
| page_size | int | No | 10 | Items per page (max 1000) |
| start_time | str | No | None | Start time, format "yyyy-MM-dd HH:mm:ss" |
| end_time | str | No | None | End time, format "yyyy-MM-dd HH:mm:ss" |
| model_id | str | No | None | Model ID for exact filtering |
Response
Returns BaseResponse[PageInfo[LmModelUsageBillingResponse]].
LmModelUsageBillingResponse fields:
| Field | Type | Description |
|---|---|---|
| id | int | Record primary key ID |
| createdAtUtc | str | Record creation time (UTC) |
| userId | int | User ID |
| username | str | Username |
| modelName | str | Model name |
| modelType | str | Model type |
| feeType | str | Fee type (e.g. "input tokens" / "output tokens") |
| unitPrice | str | Unit price (per 1K tokens) |
| currency | str | Currency (ISO 4217) |
| usedAmout | str | Usage amount (token count). Note: field name matches backend spelling |
| amount | str | Billed amount |
| billingTimeStart | str | Billing start time |
| billingTimeEnd | str | Billing end time |
| extend | str | Extension field (JSON) |
| inputs | set[str] | Input type list |
| outputs | set[str] | Output type list |
Errors
| Code | Exception | When |
|---|---|---|
2000 / 2002 | AuthenticationError | API Key invalid |
2007 | PermissionError | Permission denied |
3001 | AuthenticationError | Token expired and refresh failed |
billingQueryAllAmount
Query model usage billing total amount.
Example Usage
from wlt import WltClient
client = WltClient(api_key="your-api-key", base_url="https://console.example.com")
total = client.payment.billing_query_all_amount(
start_time="2026-04-01 00:00:00",
end_time="2026-04-21 23:59:59",
)
print(f"Total billing amount: {total.data.totalBillingAmount}")
# Filter by specific model
total = client.payment.billing_query_all_amount(
start_time="2026-04-01 00:00:00",
end_time="2026-04-21 23:59:59",
model_id="qwen-turbo",
)
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| start_time | str | No | None | Start time, format "yyyy-MM-dd HH:mm:ss" |
| end_time | str | No | None | End time, format "yyyy-MM-dd HH:mm:ss" |
| model_id | str | No | None | Model ID for exact filtering |
Response
Returns BaseResponse[ModelUsageBillingAmountResponse].
ModelUsageBillingAmountResponse fields:
| Field | Type | Description |
|---|---|---|
| totalBillingAmount | str | Total billing amount |
| currency | str | Currency code |
Errors
| Code | Exception | When |
|---|---|---|
2000 / 2002 | AuthenticationError | API Key invalid |
2007 | PermissionError | Permission denied |
3001 | AuthenticationError | Token expired and refresh failed |