Query API Key Usage
Endpoint Path
http
GET /api/open/usage/tokenAuthentication
No Query / Path / Body parameters. Token is obtained from the Authorization header.
Quota Calculation
Usage-related fields are internal units. Convert to CNY as follows:
Amount (¥) = quota ÷ quota_per_unit × usd_exchange_rateWhere:
quota: after choosing the display scope in Field Usage Logic below, use the corresponding fields — e.g. personal/member keys usetotal_available/total_used/total_granted; business keys usemonthly_quota_limit/current_month_usedquota_per_unit,usd_exchange_rate,quota_display_type: from Query Conversion Parameters (GET /api/open/status)
If quota_display_type = USD, omit × usd_exchange_rate.
When displaying “Unlimited” (unlimited_quota = true or monthly_unlimited = true), do not convert remaining balance.
Request Example
json
GET 'https://neolink.com/backend/api/open/usage/token/'
Authorization: Bearer sk-<apikey>Return Information
| Field | Type | Required | Description | Remarks |
|---|---|---|---|---|
| code | bool | Yes | Request success indicator | true on success; false on failure |
| message | string | Yes | Status message | "ok" on success; error description on failure |
| data | UsageInfo | No | Token usage statistics object | Returned only on success |
UsageInfo Object
| Field | Type | Required | Description | Remarks |
|---|---|---|---|---|
| object | string | Yes | Object type | Fixed as "token_usage" |
| name | string | Yes | Key name | |
| busi_type | int | Yes | Business type | 0=personal / 1=member / 2=business; read this first to choose display logic |
| remain_quota | int | Yes | Token remaining quota (raw DB value) | May be negative; prefer total_available for display; see Quota Calculation above |
| total_available | int64 | Yes | Token remaining (numerator) | max(0, remain_quota); 0 when token is unlimited; token-scope only; see Quota Calculation above |
| total_granted | int64 | Yes | Token total (denominator) | total_available + total_used; 0 when token is unlimited; token-scope only; see Quota Calculation above |
| total_used | int64 | Yes | Total used quota | Token-scope only; see Quota Calculation above |
| unlimited_quota | bool | Yes | Whether token quota is unlimited (DB field) | Business keys are often true at creation; does not mean monthly unlimited |
| monthly_quota_limit | int64 | Yes | Monthly limit raw value | -1=unlimited / 0=forbidden / >0=cap; mainly for business keys |
| current_month_used | int64 | Yes | Current month used (raw) | Mainly for business keys |
| monthly_unlimited | bool | Yes | Whether monthly quota is unlimited | Equivalent to monthly_quota_limit < 0 |
| model_limits_enabled | bool | Yes | Whether model whitelist is enabled | |
| model_limits | object | Yes | Model limits map | |
| expires_at | int64 | Yes | Expiration time | Unix timestamp in seconds; 0=never expires |
Field Usage Logic (Integration Pseudocode)
Read busi_type first
if busi_type == 2: # business → use monthly fields only
if monthly_unlimited: # monthly_quota_limit < 0
show "Unlimited"
optional: used = current_month_used
else if monthly_quota_limit == 0:
show remaining 0 / total 0 (calls forbidden)
else:
denominator = monthly_quota_limit # total
numerator = max(0, monthly_quota_limit - current_month_used) # remaining
show numerator / denominator
else: # personal/member → use token fields only
if unlimited_quota:
show "Unlimited"
optional: used = total_used
else:
numerator = total_available # remaining
denominator = total_granted # total
show numerator / denominatorResponse Example
json
Success (personal/member key, limited, busi_type=0 or 1)
{
"code": true,
"message": "ok",
"data": {
"object": "token_usage",
"name": "My Key",
"busi_type": 1,
"remain_quota": 400,
"total_available": 400,
"total_granted": 500,
"total_used": 100,
"unlimited_quota": false,
"monthly_quota_limit": -1,
"current_month_used": 0,
"monthly_unlimited": true,
"model_limits": {},
"model_limits_enabled": false,
"expires_at": 0
}
}
Success (personal/member key, token unlimited)
{
"code": true,
"message": "ok",
"data": {
"object": "token_usage",
"name": "My Key",
"busi_type": 0,
"remain_quota": 0,
"total_available": 0,
"total_granted": 0,
"total_used": 12345,
"unlimited_quota": true,
"monthly_quota_limit": -1,
"current_month_used": 0,
"monthly_unlimited": true,
"model_limits": {},
"model_limits_enabled": false,
"expires_at": 0
}
}
Success (business key, monthly limited, busi_type=2)
{
"code": true,
"message": "ok",
"data": {
"object": "token_usage",
"name": "Business Key",
"busi_type": 2,
"remain_quota": 0,
"total_available": 0,
"total_granted": 0,
"total_used": 20545,
"unlimited_quota": true,
"monthly_quota_limit": 357143,
"current_month_used": 20545,
"monthly_unlimited": false,
"model_limits": {},
"model_limits_enabled": false,
"expires_at": 0
}
}
Success (business key, monthly unlimited)
{
"code": true,
"message": "ok",
"data": {
"object": "token_usage",
"name": "Business Key",
"busi_type": 2,
"remain_quota": 0,
"total_available": 0,
"total_granted": 0,
"total_used": 100,
"unlimited_quota": true,
"monthly_quota_limit": -1,
"current_month_used": 100,
"monthly_unlimited": true,
"model_limits": {},
"model_limits_enabled": false,
"expires_at": 0
}
}
Success (business key, monthly limit 0, forbidden)
{
"code": true,
"message": "ok",
"data": {
"object": "token_usage",
"name": "Business Key",
"busi_type": 2,
"remain_quota": 0,
"total_available": 0,
"total_granted": 0,
"total_used": 50,
"unlimited_quota": true,
"monthly_quota_limit": 0,
"current_month_used": 50,
"monthly_unlimited": false,
"model_limits": {},
"model_limits_enabled": false,
"expires_at": 0
}
}
Failure
{
"code": false,
"message": "No Authorization header"
}
{
"code": false,
"message": "token not found"
}