Get account balance
Read the account balance or subaccount budget
Note for users in mainland China: Please use https://api.toapis.cn as the API endpoint (Base URL). Replace https://api.toapis.com with https://api.toapis.cn in the examples in this document.
See Access for authentication, pagination, and errors.
Behavior
Returns the current account's balance for checking remaining credit. balance_kind distinguishes the balance type: account_balance is the account balance and subaccount_budget is a sub-account's own budget (excluding the parent's).
The remaining_* and used_* fields come from the same quota snapshot. USD amounts are converted at credits_per_usd in the response.
Authentication
AuthorizationstringheaderrequiredUse Bearer YOUR_SYSTEM_ACCESS_TOKEN. Model API keys are not accepted. X-User-Id is not required.
Request parameters
This endpoint accepts no path or query parameters and requires no request body.
Request examples
requestExample
curl --request GET \
--url 'https://api.toapis.com/api/v1/account/balance' \
--header 'Authorization: Bearer YOUR_SYSTEM_ACCESS_TOKEN'import requests
response = requests.get(
"https://api.toapis.com/api/v1/account/balance",
headers={"Authorization": "Bearer YOUR_SYSTEM_ACCESS_TOKEN"},
timeout=30,
)
response.raise_for_status()
print(response.json())const url = new URL("https://api.toapis.com/api/v1/account/balance");
const response = await fetch(url, {
headers: { Authorization: "Bearer YOUR_SYSTEM_ACCESS_TOKEN" },
signal: AbortSignal.timeout(30_000),
});
if (!response.ok) {
throw new Error(`HTTP ${response.status}: ${await response.text()}`);
}
console.log(await response.json());Response fields
Examples use fictional data and assume credits_per_usd="100". Use the conversion rate returned by the API.
codeintegerNumeric result code; 0 means success.
messagestringResponse message; empty on success. Error messages are localized.
dataobjectResult object for this query.
data.remaining_creditsstringRemaining account quota in credits. Returned as a decimal string to preserve precision.
data.used_creditsstringUsed quota in credits. Returned as a decimal string to preserve precision.
data.remaining_usdstringRemaining quota expressed in USD. Returned as a decimal string to preserve precision.
data.used_usdstringUsed quota expressed in USD. Returned as a decimal string to preserve precision.
data.credits_per_usdstringCredits per 1 USD. Use this rate for conversion. Returned as a decimal string to preserve precision.
data.balance_kindstringaccount_balance is the account balance; subaccount_budget is the subaccount budget, not its parent balance.
Response examples
responseExample
{
"code": 0,
"message": "",
"data": {
"remaining_credits": "1000",
"remaining_usd": "10",
"used_credits": "100",
"used_usd": "1",
"credits_per_usd": "100",
"balance_kind": "account_balance"
}
}