Get account balance
Read your account data with a system access token
Note for users in mainland China: Please use https://toapis.cn as the API endpoint (Base URL). Replace https://toapis.com with https://toapis.cn in the examples in this document.
See Getting started for authentication, pagination, and errors.
Behavior
balance_kind=account_balance identifies the account balance; subaccount_budget identifies the subaccount's own budget, not its parent's funds. The remaining_* and used_* values share one quota snapshot. Use the returned credits_per_usd.
Authentication
AuthorizationstringheaderrequiredUse Bearer YOUR_SYSTEM_ACCESS_TOKEN. Model API keys are not accepted. X-User-Id is not required.
Parameters
This endpoint accepts no path or query parameters and requires no request body.
requestExample
curl --request GET \
--url 'https://toapis.com/api/v1/account/balance' \
--header 'Authorization: Bearer YOUR_SYSTEM_ACCESS_TOKEN'import requests
response = requests.get(
"https://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://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.
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"
}
}