Skip to content
Sign Up Free
API Reference

Query account balance

Use a BetterToken API Key to check how much it can spend, the account wallet balance, and active subscriptions.

Use a BetterToken API Key to check how much it can spend, the account wallet balance, and active subscriptions.

Send a request

Set your BetterToken API Key as the local environment variable BETTERTOKEN_API_KEY before running this command.

Send a read-only GET request with Authorization: Bearer <API_KEY>. The request has no parameters or body. Use the full URL with /v1 and omit the trailing slash.

Terminal window
curl -sS 'https://bettertoken.ai/v1/account/balance' \
-H "Authorization: Bearer ${BETTERTOKEN_API_KEY}"

If the API Key is missing or invalid, the API returns HTTP 401. Read the top-level message for the error details.

Successful response

success: true indicates a successful query. The numbers in this example are for illustration only.

{
"success": true,
"message": "",
"data": {
"object": "account_balance",
"token": {
"name": "example-key",
"status": 1,
"unlimited_quota": true,
"currency": "USD",
"remaining_quota": null,
"used_quota": 250000,
"remaining_amount": null,
"used_amount": 0.5,
"expires_at": 0,
"payment_order": ["USD", "RUB"]
},
"available": [
{ "currency": "USD", "quota": 6250000, "amount": 12.5 },
{ "currency": "RUB", "quota": 300000000, "amount": 600 }
],
"wallet": [
{ "currency": "USD", "quota": 6250000, "amount": 12.5, "symbol": "$" },
{ "currency": "RUB", "quota": 150000000, "amount": 300, "symbol": "₽" }
],
"subscriptions": [
{
"plan_title": "Example plan",
"currency": "RUB",
"total_quota": 250000000,
"used_quota": 100000000,
"remaining_quota": 150000000,
"total_amount": 500,
"used_amount": 200,
"remaining_amount": 300,
"model_scope": [],
"start_time": 1764000000,
"end_time": 1766592000,
"next_reset_time": 0
}
]
}
}

Response fields

FieldMeaning
data.objectAlways "account_balance".
data.tokenname is the Key name. status is 1 (enabled), 2 (disabled), 3 (expired), or 4 (exhausted). unlimited_quota indicates whether the Key has unlimited quota, and currency is the Key’s quota currency.
data.token.remaining_quota, data.token.remaining_amountThe Key’s own remaining quota and corresponding amount. Both are null for an unlimited Key.
data.token.used_quota, data.token.used_amountThe Key’s cumulative used quota and corresponding amount.
data.token.expires_at, data.token.payment_orderThe expiration time in Unix seconds (0 means the Key never expires) and the order in which currencies are charged.
data.availableThe maximum this Key can spend now. Each entry has currency, quota, and amount. Keep amounts in different currencies separate.
data.walletThe account wallet balance in currencies enabled on the platform. Each entry has currency, symbol, quota, and amount.
data.subscriptionsActive subscriptions. Each entry includes the plan title (plan_title), currency (currency), total, used, and remaining quotas (total_quota, used_quota, remaining_quota), and corresponding amounts (total_amount, used_amount, remaining_amount). An empty model_scope array means the subscription covers all models. The start, end, and next reset times (start_time, end_time, next_reset_time) are in Unix seconds.

All *_amount fields already contain the amount in the corresponding currency, calculated by dividing the quota by its conversion factor. Use these amounts directly without calling /api/status.

How available amounts are calculated

  • For a limited Key, available lists a single currency. Its quota is the smaller of the Key’s remaining quota and the sum of the wallet balance and remaining active subscription quota in that currency.
  • For an unlimited Key, available lists currencies in payment_order first, followed by any other currencies with remaining active subscription quota.
  • If the Key is disabled, expired, or exhausted, every quota and amount in available is zero.

A subscription may cover only some models. available is a spending upper bound. The amount you can spend on a particular model may be lower.

Which details a Key can see

wallet and subscriptions are visible only to an enabled, unexpired Key with unlimited quota. Both fields are null for other Keys. If you share a limited Key with a team member, they cannot see the account wallet or subscriptions.