查詢餘額
查詢目前 API Key 所屬使用者的餘額狀態。
GET
/api/v1/credits/balance| 欄位 | 值 |
|---|---|
| Base URL | https://api.gate.ai |
| 認證 | Authorization: Bearer <API_KEY> |
| 格式 | Gate.AI REST JSON |
請求參數
| 名稱 | 位置 | 類型 | 必填 | 說明 |
|---|---|---|---|---|
| Authorization | header | string | 是 | API Key 鑑權,格式:Bearer <API_KEY> |
返回欄位說明
| 名稱 | 類型 | 說明 |
|---|---|---|
| code | integer | 業務狀態碼。成功固定為 200。 |
| data | object | 餘額資料。 |
| data.status | integer | 餘額狀態:1 可交易,2 餘額不足,4 已欠費。 |
| data.message | string | 狀態描述。 |
| data.asset_type | string | 資產歸屬類型:user_asset 個人資產,organization_asset 組織資產。 |
| data.recharge_balance | string | 充值餘額。 |
| data.debt_amount | string | 欠費金額;無欠費時為空字串或 0 值字串。 |
回傳範例
json
1{2 "code": 200,3 "data": {4 "status": 1,5 "message": "可以交易",6 "asset_type": "user_asset",7 "recharge_balance": "12.34000000",8 "debt_amount": ""9 }10}回傳結果
| 狀態碼 | 狀態碼含義 | 說明 | 資料模型 |
|---|---|---|---|
| 200 | OK | 查詢成功,回傳 code 和 data。 | CreditsBalanceResponse |
| 401 | Unauthorized | API Key 缺失、無效、過期、撤銷、禁用或未啟用。 | ErrorResponse |
| 403 | Forbidden | 目前 API Key 所屬成員無權限查看餘額。 | ErrorResponse |
| 429 | Too Many Requests | 觸發限流。 | ErrorResponse |
| 500 | Internal Server Error | 閘道內部錯誤,例如 API Key 查詢異常或回應序列化失敗。 | ErrorResponse |
| 502 | Bad Gateway | 餘額上游服務不可用、回傳非成功狀態、回應解析失敗或資料為空。 | ErrorResponse |
錯誤回傳範例
json
1{2 "error": {3 "type": "authentication_error",4 "code": "7022002001",5 "message": "invalid api key"6 }7}