Check API Quota: Endpoint, Response Fields and Top Up
Check API quota in TokenomixAI by sending one GET request to the quota endpoint with the same API key you already use. The JSON response returns status, remainingTokens, maxTokens, usagePercent, expiresAt and a low flag. Those numbers, not hours of use, tell you when a top up is due.
Remaining quota comes from the JSON response of the quota endpoint, and the low flag plus remainingTokens are quicker to act on than counting usage by hand.
API quota is counted in tokens, not in time windows
Quota in TokenomixAI counts the tokens you actually use, not a clock. There is no 5-hour limit that locks the key after a few hours of work. The key keeps working while tokens remain and before it expires.
There is still a rate limit: 600 requests per minute per account, shared by all its keys. Above that number the API returns 429 with a Retry-After header. The rate limit is a separate thing from remaining quota, so keep the two apart when you read the result of a check.
- Remaining quota: how many tokens you have left, read from the quota endpoint.
- Rate limit: how many requests per minute per account, visible as 429 when exceeded.
- Quota decides when you need a top up, the rate limit only decides when to slow down.
How to check API quota with the quota endpoint
The quota endpoint is a GET to the same base URL you already use, with the API key in the Authorization header as Bearer. The command looks like this:
curl https://api.tokenomixai.com/v1/quota -H "Authorization: Bearer sk-tkx-..."A successful response returns JSON with the fields status, remainingTokens, maxTokens, usagePercent, expiresAt and low. A wrong key or a missing Authorization header returns 401 and no quota data at all.
You can call it from a terminal, from a Python or Node script with any HTTP client, or from the request collection you already keep. The gateway logs only request metadata such as model, token count, time and status, so prompt and completion content is not stored.
What status, remainingTokens and usagePercent mean
Each of the six fields in the response does a different job. Reading them together avoids guessing from a single number, and two of them matter more than the rest for decisions.
| Field | What it tells you |
|---|---|
| status | active while tokens remain, exhausted once they are gone |
| remainingTokens | the number of tokens you can still spend |
| maxTokens | the size of the quota on your current package |
| usagePercent | the share of the quota you have used |
| expiresAt | when the key stops working |
| low | true when 10% or less of the tokens remain |
Read remainingTokens together with maxTokens to know where you actually stand. usagePercent is handy for spotting a trend over a week, while low is a simple alarm to wire into a script. Exact field names and response shapes live on the docs if you need the reference.
How to read the low flag and usagePercent
The low flag is true when 10% or less of the tokens remain. If you run an unattended agent, that gives you a clean condition to branch on: send a notification or pause the job queue before the tokens run out mid run.
usagePercent gives you a proportion, not an absolute number. Two keys can show the same usagePercent and still have very different remainingTokens if the packages differ in size. For technical decisions the absolute figure wins.
Read expiresAt separately from the token count. You can have plenty of tokens left with expiry close, and that still stops the key from working. Check two things every time: remainingTokens and expiresAt.
The number shown inside your tool is not always the same as the account quota, especially when the tool tracks its own usage counters. For the official figure, call the quota endpoint and keep that response as your reference.
What changes on your key after a top up
A top up adds new tokens to whatever is left, so remainingTokens grows and the package is not reset to zero. Validity follows the latest top up, not the first package you bought.
The key itself stays the same after a top up, still in the sk-tkx- format and still sitting wherever you stored it. Your configuration in OpenCode, Claude Code, Cursor or your own script needs no change, and the base URL stays as it was.
After paying, call the quota endpoint again to confirm that status is back to active and the new remainingTokens has landed. If status is still exhausted with the same key, make sure the QRIS payment has finished processing, then check once more. If the balance stays low or the key behaves oddly, this breakdown of an exhausted token quota walks through the signs.
Check quota before and after a coding agent session
A reliable way to measure token spend is to compare two readings of the endpoint instead of guessing from the number of messages. The sequence looks like this:
- Call the quota endpoint before a long session, for example a refactor that touches many files.
- Record remainingTokens as your starting point.
- Run the session as usual in your coding agent or script.
- Call the quota endpoint again when the session ends.
- Subtract the two numbers and keep the difference as your estimate for similar tasks.
One large instruction with many files in context can burn far more tokens than ten short conversations. The difference between the two readings shows which kind of work is expensive in your project.
If the agent runs in the background, call the endpoint between jobs rather than on every request. The rate limit of 600 requests per minute per account covers all requests, quota checks included.
When the check looks wrong: 401, 429 or exhausted
- 401 response: the key is wrong, missing, or the Authorization header is not using the Bearer format.
- 429 response: the rate limit was hit, not the quota. Wait for the Retry-After value and send again.
- status exhausted: tokens are genuinely gone and a top up is needed before the key is useful again.
- low is true: 10% or less remain, so prepare a top up before the next session.
Start from status and remainingTokens, not from whatever error the tool printed. Plenty of quota-is-empty reports turn out to be a 401 or a 429 read the wrong way, and the 401 API key error guide covers the first case in detail.
Frequently asked questions
Does the quota endpoint need a different key?
No. Use the same API key you use for chat completions, sent in the Authorization header as Bearer. That key is also the one you keep after a top up, so your base URL and auth token settings do not change.
How often should I check remaining quota?
Before and after long sessions is enough for most work. If you run an automated agent, check between jobs and watch the low flag as an alarm. Remember the rate limit of 600 requests per minute per account applies to every request, quota checks included.
What does the low flag mean?
It is true when 10% or less of your tokens remain against the active quota. That is not the same as empty, but it is a good moment to set up a top up before your next coding session. After a top up the flag goes back to false while the balance is above that threshold.
Is there a usage limit every 5 hours?
No. Quota is counted in tokens rather than in time windows, so a 5-hour limit does not apply here. The only ceiling is the rate limit of 600 requests per minute per account, which counts requests, not tokens.
Do tokens disappear when the key sits idle?
Tokens only decrease when you make requests. Validity still runs on its own schedule, so expiresAt can pass while remainingTokens is still large. Check both fields together so a key that stops working does not catch you by surprise.