Skip to main content

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.
Do not expose the full AccessToken in source code, browser apps, logs, screenshots, or support tickets. For support diagnostics, provide the request time, HTTP status code, response message, and a redacted command only.

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

The response may include additional fields depending on the account state. Depend only on the fields your integration needs, and allow unknown fields so your parser does not fail when the response expands.

Quota And Balance Calculation

The quota 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.
Use this formula for balance display. Actual model charges still depend on current model pricing, account group, usage logs, and console display. For production alerts, store both the raw quota value and the converted USD amount so diagnostics keep full precision.

Code Examples

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

Common causes include an empty Authorization header, an incomplete token, an expired token, or using a regular API key instead of the system AccessToken.

HTTP 403 - Permission Denied

Common causes include insufficient token permissions or an account state that needs support confirmation.

Garbled Response Or jq Error

If cURL returns garbled output or jq reports Invalid numeric literal, the gzip response was likely not decompressed. Add --compressed.

Monitoring Recommendations

  • Store LAOZHANG_ACCESS_TOKEN in 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, converted remaining_usd, used_quota, request_count, request time, and HTTP status in alerts
  • Do not log the full Authorization, access_token, or sensitive account fields