Skip to main content

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​

MethodDescription
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​

ParameterTypeRequiredDefaultDescription
page_numintNo1Page number, starting from 1
page_sizeintNo10Items per page (max 1000)
status_listlist[str]NoNoneStatus filter: "0"=processing, "1"=success, "2"=failed, "3"=closed
start_timedatetimeNoNoneQuery start time
end_timedatetimeNoNoneQuery end time
transaction_typestrNoNoneTransaction type: "Recharge" or "Refund"

Response​

Returns BaseResponse[PageResponse] where the list field contains RechargeTransactionResponse items.

PageResponse fields (Payment-specific pagination):

FieldTypeDescription
pageNumintCurrent page number
pageSizeintItems per page
totalintTotal record count
pagesintTotal number of pages
hasNextboolWhether there is a next page
hasPreviousboolWhether there is a previous page
listlistData list

RechargeTransactionResponse fields:

FieldTypeDescription
idintRecord primary key ID
createdAtUtcstrCreation time (UTC)
updatedAtUtcstrUpdate time (UTC)
userIdintUser ID
payChannelstrPayment channel (e.g. "Stripe")
payTypestrPayment type (APP / WEB)
transactionTypestrTransaction type (Recharge / Refund)
statusstrStatus: 0=processing, 1=success, 2=failed, 3=closed
callbackAtUtcstrCallback time (UTC)
transactionNostrPlatform transaction number
externalNostrExternal transaction number (Stripe ID)
amountstrTransaction amount
refundAmountstrRefunded amount
currencystrCurrency (ISO 4217)
refundStatusstrRefund status: 0=none, 1=partial, 2=full
originalTransactionNostrOriginal transaction number (for refund records)
extendstrExtension field (JSON)

Errors​

CodeExceptionWhen
2000 / 2002AuthenticationErrorAPI Key invalid
2007PermissionErrorPermission denied
3001AuthenticationErrorToken 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:

FieldTypeDescription
totalRechargedAmountstrTotal recharged amount
totalUsedRechargedAmountstrTotal used recharged amount
totalBalanceRechargedAmountstrUnused recharge balance
totalRefundAmountstrTotal refund amount
totalFreeAmountstrFree quota amount
currencystrCurrency code

Errors​

CodeExceptionWhen
2000 / 2002AuthenticationErrorAPI Key invalid
2007PermissionErrorPermission denied
3001AuthenticationErrorToken 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​

ParameterTypeRequiredDefaultDescription
transaction_nostrYes--Platform transaction number

Response​

Returns BaseResponse[RechargeTransactionResponse].

RechargeTransactionResponse fields: see client.payment.records() above.

Errors​

CodeExceptionWhen
1001ValidationErrorInvalid request parameters
1002NotFoundErrorTransaction not found
2000 / 2002AuthenticationErrorAPI Key invalid
2007PermissionErrorPermission denied
3001AuthenticationErrorToken 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​

ParameterTypeRequiredDefaultDescription
page_numintNo1Page number, starting from 1
page_sizeintNo10Items per page (max 1000)
start_timestrNoNoneStart time, format "yyyy-MM-dd HH:mm:ss"
end_timestrNoNoneEnd time, format "yyyy-MM-dd HH:mm:ss"
model_idstrNoNoneModel ID for exact filtering

Response​

Returns BaseResponse[PageInfo[LmModelUsageBillingResponse]].

LmModelUsageBillingResponse fields:

FieldTypeDescription
idintRecord primary key ID
createdAtUtcstrRecord creation time (UTC)
userIdintUser ID
usernamestrUsername
modelNamestrModel name
modelTypestrModel type
feeTypestrFee type (e.g. "input tokens" / "output tokens")
unitPricestrUnit price (per 1K tokens)
currencystrCurrency (ISO 4217)
usedAmoutstrUsage amount (token count). Note: field name matches backend spelling
amountstrBilled amount
billingTimeStartstrBilling start time
billingTimeEndstrBilling end time
extendstrExtension field (JSON)
inputsset[str]Input type list
outputsset[str]Output type list

Errors​

CodeExceptionWhen
2000 / 2002AuthenticationErrorAPI Key invalid
2007PermissionErrorPermission denied
3001AuthenticationErrorToken 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​

ParameterTypeRequiredDefaultDescription
start_timestrNoNoneStart time, format "yyyy-MM-dd HH:mm:ss"
end_timestrNoNoneEnd time, format "yyyy-MM-dd HH:mm:ss"
model_idstrNoNoneModel ID for exact filtering

Response​

Returns BaseResponse[ModelUsageBillingAmountResponse].

ModelUsageBillingAmountResponse fields:

FieldTypeDescription
totalBillingAmountstrTotal billing amount
currencystrCurrency code

Errors​

CodeExceptionWhen
2000 / 2002AuthenticationErrorAPI Key invalid
2007PermissionErrorPermission denied
3001AuthenticationErrorToken expired and refresh failed