Skip to content
此頁面尚未提供您使用的語言,因此目前以英文顯示。

Query Token Balance

Query remaining and used credits of the current API Key

所有文件
GET/v1/balance
  • Monitor single token usage
  • CORS support for cross-origin requests
  • Real-time balance monitoring

Get the remaining and used balance of the current API Key (token). This endpoint is used to monitor the usage of a single token.

請求範例

curl --request GET \
  --url 'https://api.apisea.ai/v1/balance' \
  --header 'Authorization: Bearer <token>'

Authorization

Authorizationstringrequired

All API endpoints require Bearer Token authentication

Get your API Key:

Visit the API Key Management Page to get your API Key

Add it to the request header:

text
Authorization: Bearer YOUR_API_KEY

Endpoints

text
GET /v1/balance
GET /balance

Both endpoints have the same functionality, you can use either one.

Response

successboolean

Whether the request was successful

messagestring

Error message (only returned on failure)

remain_balancefloat

Token remaining balance (returned on success). Returns -1 when unlimited_quota is true

remain_creditsinteger

Token remaining credits (returned on success). Returns -1 when unlimited_quota is true

used_balancefloat

Token used balance (returned on success)

used_creditsinteger

Token used credits (returned on success)

unlimited_quotaboolean

Whether the token has unlimited quota. true means unlimited, false means limited

Use Cases

  • Monitor consumption of a single API Key
  • Display current token balance in your application
  • Set up balance alerts when balance falls below threshold

Note

Balance Unit Information

The unit of the balance value depends on system configuration:

  • USD - US Dollars
  • Credits - Credits

Tip

Unlimited Quota Token

When a token is set to unlimited quota:

  • unlimited_quota field returns true
  • remain_balance field returns -1
  • remain_credits field returns -1
  • The token has no quota restrictions and can be used without limits

Common Errors

Error MessageCauseSolution
No Authorization headerAuthorization header not providedAdd Authorization: Bearer sk-xxxxx header
Failed to get token infoToken doesn't exist or has been deletedCheck if the token key is correct

Warning

Security Note

Your API Key is like a password. Keep it secure and don't share it with others. Always use HTTPS in production.

回應

{
  "success": true,
  "remain_balance": 10.5,
  "remain_credits": 105,
  "used_balance": 2.3,
  "used_credits": 23,
  "unlimited_quota": false
}

發現文件有問題嗎?請寄信至 support@apisea.ai。