Skip to main content
Read your account’s remaining quota, used quota, and request count with a system AccessToken. Use this endpoint for low-balance alerts, billing checks, and internal dashboards.
This endpoint uses a system AccessToken, not the API key you use for model requests. An AccessToken has broader account permissions, so keep it on your server in an environment variable or a secrets manager.

Get an AccessToken

1

Open account settings

Sign in to the console and open account settings.
2

Open the system token dialog

Select System Token, then enter your account password when the console asks for it.
3

Copy the AccessToken

Copy the AccessToken as soon as it appears and store it securely. Generating a new AccessToken may invalidate the previous one, so update every service that uses it.
Do not put the AccessToken in source code, browser apps, logs, screenshots, or support tickets. When you ask support for help, send the request time, HTTP status, response message, and a redacted command.

Endpoint

The request takes no query parameters or body, and the response is JSON. Pass the AccessToken itself as the Authorization value, as the examples below do. Accept: application/json and Content-Type: application/json are optional. With cURL, --compressed is recommended so that the response is decompressed.

Response

A successful request returns:
The response can include other fields, depending on the account. Read only the fields you need, and let your parser ignore unknown ones.

Convert quota to US dollars

quota and used_quota are returned in quota units, not dollars. 500,000 quota units are about 1 USD. Use this conversion for display. What a request actually costs depends on the model price, your token group, and the charge shown in call logs. For alerts, store the raw quota together with the converted amount so that you keep full precision.

Code examples

Set the AccessToken in your terminal once, replacing the placeholder:
Without --compressed, the terminal can show garbled output, and jq can report Invalid numeric literal.

Errors

401 Unauthorized

The Authorization header is empty, the AccessToken is incomplete or no longer valid, or the request sent a model API key instead of the AccessToken. Fix a 401 from the balance API walks through each cause.

403 Forbidden

The credential does not have permission for this endpoint, or the account needs attention from support.

Garbled output or a jq error

If cURL prints garbled characters or jq reports Invalid numeric literal, the compressed response was not decoded. Add --compressed to the cURL command.

Monitoring recommendations

  • Store LAOZHANG_ACCESS_TOKEN in an environment variable or a secrets manager.
  • Set a request timeout, such as 10 seconds.
  • Poll at a modest interval; balance alerts rarely need per-second checks.
  • Include quota, the converted balance, used_quota, request_count, the request time, and the HTTP status in alerts.
  • Never log the Authorization header, access_token, or other sensitive account fields.