Overview
The Balance Query API returns the current account quota, used quota, request count, and account group. Use it for backend monitoring, low-balance alerts, billing diagnostics, and internal operations dashboards.This endpoint uses a system AccessToken, not the regular API key used for model calls. The AccessToken has broader account permissions, so keep it on the server side and store it in environment variables or a secrets manager.
Get Authorization
1
Open account settings
Log in to the LaoZhang API console and open account settings.
2
Open system token
Select “System Token” and complete the password verification flow shown in the console.
3
Save the AccessToken
Copy the token immediately after it is generated. Creating a new token may invalidate the previous token.
Endpoint
Request
Headers
Parameters
This endpoint does not require query parameters or a request body. Keep alert thresholds, business labels, and notification channels in your monitoring configuration rather than in the endpoint URL.Response
Successful Response
Core Fields
Quota And Balance Calculation
Thequota field is returned in quota units, not directly in USD. Use this conversion for balance display:
In other words,
500K quota is approximately 1 USD. If the API returns quota: 24997909, the current available balance is approximately 50.00 USD.
Code Examples
- cURL
- jq Extract
- Python
- Node.js
--compressed tells cURL to decompress gzip responses. Without it, the terminal may show garbled output and jq may report Invalid numeric literal.Error Responses
HTTP 401 - Authentication Failed
Authorization header, an incomplete token, an expired token, or using a regular API key instead of the system AccessToken.
HTTP 403 - Permission Denied
Garbled Response Or jq Error
If cURL returns garbled output orjq reports Invalid numeric literal, the gzip response was likely not decompressed. Add --compressed.
Monitoring Recommendations
- Store
LAOZHANG_ACCESS_TOKENin environment variables or a secrets manager - Set a reasonable timeout, such as 10 seconds
- Avoid high-frequency polling; balance monitoring usually does not need second-level checks
- Include
quota, convertedremaining_usd,used_quota,request_count, request time, and HTTP status in alerts - Do not log the full
Authorization,access_token, or sensitive account fields
Related Docs
- For the FAQ version, see How to Query Account Balance via API
- If requests fail even with remaining quota, see Insufficient Balance
- To inspect per-request model, token, and billing records, see Usage Logs