介面模組使用指南
賬戶計費面板模組
功能說明
介面字首統一為 http(s)://<your-domain>
生產環境應使用 HTTPS 以保證認證令牌。 HTTP 僅建議用於開發環境。
OpenAI SDK 相容的計費查詢介面 。使用 Token 認證,提供訂閱資訊和使用量查詢。主要用於第三方應用和 SDK 整合,確保與 OpenAI API 的完全相容性。
🔐 使用者鑑權
獲取訂閱額度資訊
- 介面名稱:獲取訂閱額度資訊
- HTTP 方法:GET
- 路徑:
/dashboard/billing/subscription - 鑑權要求:使用者 Token
- 功能簡介:獲取使用者的訂閱配額資訊,包括總額度、硬限制和訪問有效期,相容 OpenAI API 格式
💡 請求示例:
const response = await fetch('/dashboard/billing/subscription', {
method: 'GET',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer your_user_token',
'New-Api-User': 'your_user_id'
}
});
const data = await response.json();✅ 成功響應示例:
{
"object": "billing_subscription",
"has_payment_method": true,
"soft_limit_usd": 100.0,
"hard_limit_usd": 100.0,
"system_hard_limit_usd": 100.0,
"access_until": 1640995200
}❗ 失敗響應示例:
{
"error": {
"message": "獲取配額失敗",
"type": "upstream_error"
}
}🧾 欄位說明:
object(字串): 固定值"billing_subscription"has_payment_method(布林型): 是否有支付方式,固定為 truesoft_limit_usd(數字): 軟限制額度(美元)hard_limit_usd(數字): 硬限制額度(美元)system_hard_limit_usd(數字): 系統硬限制額度(美元)access_until(數字): 訪問有效期時間戳,Token 過期時間
相容 OpenAI SDK 路徑 - 獲取訂閱額度資訊
- 介面名稱:相容 OpenAI SDK 路徑 - 獲取訂閱額度資訊
- HTTP 方法:GET
- 路徑:
/v1/dashboard/billing/subscription - 鑑權要求:使用者 Token
- 功能簡介:與上述介面功能完全相同,提供 OpenAI SDK 相容路徑
💡 請求示例:
const response = await fetch('/v1/dashboard/billing/subscription', {
method: 'GET',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer your_user_token',
'New-Api-User': 'your_user_id'
}
});
const data = await response.json();✅ 成功響應示例:
{
"object": "billing_subscription",
"has_payment_method": true,
"soft_limit_usd": 100.0,
"hard_limit_usd": 100.0,
"system_hard_limit_usd": 100.0,
"access_until": 1640995200
}❗ 失敗響應示例:
{
"error": {
"message": "獲取配額失敗",
"type": "upstream_error"
}
}🧾 欄位說明:
object(字串): 固定值"billing_subscription"has_payment_method(布林型): 是否有支付方式,固定為 truesoft_limit_usd(數字): 軟限制額度(美元)hard_limit_usd(數字): 硬限制額度(美元)system_hard_limit_usd(數字): 系統硬限制額度(美元)access_until(數字): 訪問有效期時間戳,Token 過期時間
獲取使用量資訊
- 介面名稱:獲取使用量資訊
- HTTP 方法:GET
- 路徑:
/dashboard/billing/usage - 鑑權要求:使用者 Token
- 功能簡介:獲取使用者的配額使用量資訊,相容 OpenAI API 格式
💡 請求示例:
const response = await fetch('/dashboard/billing/usage', {
method: 'GET',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer your_user_token',
'New-Api-User': 'your_user_id'
}
});
const data = await response.json();✅ 成功響應示例:
{
"object": "list",
"total_usage": 2500.0
}❗ 失敗響應示例:
{
"error": {
"message": "獲取使用量失敗",
"type": "new_api_error"
}
}🧾 欄位說明:
object(字串): 固定值"list"total_usage(數字): 總使用量,單位為 0.01 美元
相容 OpenAI SDK 路徑 - 獲取使用量資訊
- 介面名稱:相容 OpenAI SDK 路徑 - 獲取使用量資訊
- HTTP 方法:GET
- 路徑:
/v1/dashboard/billing/usage - 鑑權要求:使用者 Token
- 功能簡介:與上述介面功能完全相同,提供 OpenAI SDK 相容路徑
💡 請求示例:
const response = await fetch('/v1/dashboard/billing/usage', {
method: 'GET',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer your_user_token',
'New-Api-User': 'your_user_id'
}
});
const data = await response.json();✅ 成功響應示例:
{
"object": "list",
"total_usage": 2500.0
}❗ 失敗響應示例:
{
"error": {
"message": "獲取使用量失敗",
"type": "new_api_error"
}
}🧾 欄位說明:
object(字串): 固定值"list"total_usage(數字): 總使用量,單位為 0.01 美元