Skip to content

Query API Key Usage ​

Endpoint Path ​

http
GET /api/open/usage/token

Authentication ​

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_rate

Where:

  • quota: after choosing the display scope in Field Usage Logic below, use the corresponding fields — e.g. personal/member keys use total_available / total_used / total_granted; business keys use monthly_quota_limit / current_month_used
  • quota_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 ​

FieldTypeRequiredDescriptionRemarks
codeboolYesRequest success indicatortrue on success; false on failure
messagestringYesStatus message"ok" on success; error description on failure
dataUsageInfoNoToken usage statistics objectReturned only on success

UsageInfo Object

FieldTypeRequiredDescriptionRemarks
objectstringYesObject typeFixed as "token_usage"
namestringYesKey name
busi_typeintYesBusiness type0=personal / 1=member / 2=business; read this first to choose display logic
remain_quotaintYesToken remaining quota (raw DB value)May be negative; prefer total_available for display; see Quota Calculation above
total_availableint64YesToken remaining (numerator)max(0, remain_quota); 0 when token is unlimited; token-scope only; see Quota Calculation above
total_grantedint64YesToken total (denominator)total_available + total_used; 0 when token is unlimited; token-scope only; see Quota Calculation above
total_usedint64YesTotal used quotaToken-scope only; see Quota Calculation above
unlimited_quotaboolYesWhether token quota is unlimited (DB field)Business keys are often true at creation; does not mean monthly unlimited
monthly_quota_limitint64YesMonthly limit raw value-1=unlimited / 0=forbidden / >0=cap; mainly for business keys
current_month_usedint64YesCurrent month used (raw)Mainly for business keys
monthly_unlimitedboolYesWhether monthly quota is unlimitedEquivalent to monthly_quota_limit < 0
model_limits_enabledboolYesWhether model whitelist is enabled
model_limitsobjectYesModel limits map
expires_atint64YesExpiration timeUnix 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 / denominator

Response 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"
}