Token Usage Query
What it does
Retrieve the current Bearer token's quota usage: total granted, used, available, unlimited flag, model limits and expiration time.
๐ฎ Endpoint
GET /api/usage/token- Requires Authorization header
- Returns usage info for the token used in the current request
๐ Authentication
Include the following header for API key authentication:
Authorization: Bearer $API_KEYsk-prefix is accepted but optional; the server normalizes it- Missing or invalid Authorization header returns 401
๐ก Request Example
curl -X GET https://88api.ai/api/usage/token \
-H "Authorization: Bearer $API_KEY"โ Success Response Example
{
"code": true,
"message": "ok",
"data": {
"object": "token_usage",
"name": "Default Token",
"total_granted": 1000000,
"total_used": 12345,
"total_available": 987655,
"unlimited_quota": false,
"model_limits": {
"gpt-4o-mini": true
},
"model_limits_enabled": false,
"expires_at": 0
}
}โ Error Response Examples
- Missing Authorization header:
{
"success": false,
"message": "No Authorization header"
}- Invalid scheme (non-Bearer):
{
"success": false,
"message": "Invalid Bearer token"
}- Token fetch failed (e.g., invalid or deleted):
{
"success": false,
"message": "token not found"
}๐งพ Field Descriptions (data)
object: Alwaystoken_usagename: Token nametotal_granted: Total granted (= used + available)total_used: Used quotatotal_available: Remaining available quotaunlimited_quota: Whether the token has unlimited quotamodel_limits: Allowed model listmodel_limits_enabled: Whether model-specific limits are enabledexpires_at: Expiration Unix timestamp in seconds.0means never expires (backend normalizes-1โ0).
Reference:
GET /api/usage/tokenadded in PR #1161