Account Management
Query User Balance
- Query overall remaining and used credits of user account
- Get user-level balance information
- CORS support for cross-origin requests
- Real-time balance monitoring
GET
Get the remaining and used balance of the current user account. This endpoint returns user-level balance information, independent of specific tokens, for viewing the overall account balance.
Both endpoints have the same functionality, you can use either one.
Authorization
All API endpoints require Bearer Token authenticationGet your API Key:Visit the API Key Management Page to get your API KeyAdd it to the request header:
Endpoints
Response
Whether the request was successful
Error message (only returned on failure)
User remaining balance (returned on success). Returns
-1 when unlimited_quota is trueUser used balance (returned on success)
Whether the user has unlimited quota.
true means unlimited, false means limitedToken Balance vs User Balance
| Comparison | Token Balance (/v1/balance) | User Balance (/v1/user/balance) |
|---|---|---|
| Scope | Single token | Entire user account |
| Data Source | Token’s RemainQuota and UsedQuota | User’s quota and used_quota |
| Use Case | Monitor single API Key usage | View overall account balance |
| Limited By | Token-level quota limits | User-level quota limits |
Use Cases
- View overall user account balance
- Set up recharge reminders and balance alerts
- Display account balance in user dashboard
Balance Unit InformationThe unit of the balance value depends on system configuration:
- USD - US Dollars
- CNY - Chinese Yuan
- Tokens - Token count
Common Errors
| Error Message | Cause | Solution |
|---|---|---|
| No Authorization header | Authorization header not provided | Add Authorization: Bearer sk-xxxxx header |
| Failed to get user quota | User doesn’t exist | Check if the user associated with the token exists |
| Failed to get used quota | Database query error | Contact admin to check system status |