查询:账户信息
简洁描述:查询当前账户的详细信息,包括剩余额度、已用额度、累计请求次数等。
概览
- 请求方法:
GET - 路径:
/api/user/self - 内容类型:
application/json
认证方式
- Header:
Authorization: Bearer <token> - Header:
X-Api-User: <user_id>(可选)
请求示例
Header
| Header | 示例 | 必填 |
|---|---|---|
| Authorization | Bearer sk-xxxx | 是 |
| X-Api-User | 0 | 否 |
curl 示例
bash
curl -X GET "https://api.gpt.ge/api/user/self" \
-H "Authorization: Bearer sk-xxxx" \
-H "X-Api-User: 0"JavaScript (fetch) 示例
javascript
fetch('https://api.gpt.ge/api/user/self', {
method: 'GET',
headers: {
'Authorization': 'Bearer sk-xxxx',
'X-Api-User': '0'
}
}).then(r => r.json()).then(console.log);Python(requests)示例
python
import requests
url = 'https://api.gpt.ge/api/user/self'
headers = {
'Authorization': 'Bearer sk-xxxx',
'X-Api-User': '0'
}
response = requests.get(url, headers=headers)
print(response.json())返回示例(200)
json
{
"data": {
"id": 123,
"username": "user@example.com",
"password": "******",
"display_name": "User Name",
"role": 1,
"status": 1,
"email": "user@example.com",
"github_id": "",
"wechat_id": "",
"oidc_id": "",
"google_id": "",
"verification_code": "",
"access_token": null,
"quota": 500000,
"used_quota": 100000,
"request_count": 42,
"group": "default",
"can_use_self_group": false,
"aff_code": "",
"inviter_id": 0,
"aff_count": 0,
"aff_quota": 0,
"aff_history_quota": 0,
"created_at": 1700000000,
"last_login_at": 1700001000,
"last_login_ip": "1.2.3.4",
"deleted_at": null,
"group_ratio": 100,
"topup_ratio": 100
},
"message": "success",
"success": true
}注意:返回的
quota与used_quota值需除以500000才能得到实际额度。