TLDR:查询账户的总额度和已用额度,计算剩余余额。
GET /v1/dashboard/billing/subscription| 请求头 | 必填 | 说明 |
|---|---|---|
Authorization | 是 | Bearer sk-your-api-key,使用你的 API Key 进行认证 |
{
"object": "billing_subscription",
"has_payment_method": true,
"soft_limit_usd": 100.00,
"hard_limit_usd": 100.00
}| 字段 | 类型 | 说明 |
|---|---|---|
soft_limit_usd | number | 总额度(单位:人民币 ¥,字段名为历史兼容) |
hard_limit_usd | number | 硬限制额度 |
💡 注意:字段名含 _usd是 OpenAI 格式兼容遗留,实际金额单位为 CNY(人民币)。
GET /v1/dashboard/billing/usage| 请求头 | 必填 | 说明 |
|---|---|---|
Authorization | 是 | Bearer sk-your-api-key,使用你的 API Key 进行认证 |
{
"object": "list",
"total_usage": 5000
}| 字段 | 类型 | 说明 |
|---|---|---|
total_usage | number | 已用额度(单位:分,需除以 100 换算为元) |
剩余余额(¥)= soft_limit_usd - total_usage / 100soft_limit_usd = 100.00total_usage = 5000(即 50.00 元)100.00 - 5000 / 100 = 50.00 元{
"error": {
"message": "Invalid authentication credentials. Please check your API key.",
"type": "authentication_error",
"code": "invalid_api_key"
}
}{
"error": {
"message": "You do not have permission to access this resource.",
"type": "authorization_error",
"code": "forbidden"
}
}insufficient_quota 错误