BazaarLinkBazaarLink
登入
文件API 參考SDK 參考Agent 應用Worker 網路暫停使用訂閱制暫停使用AI Skills

訂閱制 API 使用指南

訂閱制讓你將某個 API Key 升級為付費方案,享有更高的 RPM(每分鐘請求數)、Token 配額上限,以及指定方案才能呼叫的獨家模型。

訂閱費用在訂閱當下從帳戶餘額(Credits)立即扣除,不收週期性自動扣款。配額依方案設定的週期(每日 / 每週 / 每月)自動重置。

AI Skill 檔案
把下方連結貼給任意 AI 助理(Claude、Cursor、Copilot…),讓它完整了解 BazaarLink 訂閱制 API: bazaarlink.ai/subscriptionskill.md

查詢可用方案

公開端點,無需驗證,回傳所有啟用中的訂閱方案,包含價格、速率限制、Token 配額、可用模型清單。

GET/api/v1/plans

Response

json
[
  {
    "slug": "standard",
    "priceUsd": 20,
    "rpmLimit": 60,
    "tokenLimit": 2000000,        // null = unlimited
    "tokenLimitPeriod": "day",    // "5h" | "day" | "week" | "month"
    "dailyPoints": 3700,
    "newAccountDailyPoints": 500,
    "newAccountCooldownHrs": 72,
    "models": [
      { "modelId": "openai/gpt-4o",            "basePoints": 15 },
      { "modelId": "anthropic/claude-sonnet-4", "basePoints": 25 }
    ]
  }
]

Example

bash
curl https://bazaarlink.ai/api/v1/plans

訂閱 API Key

將指定 API Key 升級為某個方案。訂閱費用在呼叫當下立即從帳戶餘額扣除,回應中包含扣款後的剩餘餘額 remainingCredits。

POST/api/v1/keys/:id/subscription
身份驗證
此端點需要使用者 Session Cookie(在帳戶入口登入後自動帶入),不接受 Bearer API Key 認證。

Request Body

planSlug必填
string
方案識別碼,例如 "standard"、"pro"、"max"。從 GET /api/v1/plans 取得。

Response

json
{
  "ok": true,
  "remainingCredits": 80.0000,   // balance after deduction
  "subscriptionPlan": {
    "id": "clxxxxx",
    "slug": "standard",
    "priceUsd": 20,
    "rpmLimit": 60,
    "tokenLimit": 2000000,
    "tokenLimitPeriod": "day"
  }
}

Error Codes

400
planSlug 為空或格式錯誤
401
未登入
402
帳戶餘額不足,回應包含 required 欄位(需要的金額)
404
key 不存在或不屬於此帳戶,或 planSlug 找不到對應方案
400
方案未啟用(active: false)

Example

bash
# Login first to obtain a session cookie
curl -X POST https://bazaarlink.ai/api/v1/keys/KEY_ID/subscription \
  -H "Content-Type: application/json" \
  -H "Cookie: next-auth.session-token=YOUR_SESSION" \
  -d '{"planSlug": "standard"}'

可呼叫模型

訂閱方案可能包含一組「獨家模型」,只有訂閱該方案的 Key 才能呼叫。從 GET /api/v1/plans 的 models 陣列取得完整清單。

若方案的 models 陣列為空([]),表示該方案可呼叫所有一般模型(免費方案也能用的模型),以方案的 RPM 與 Token 配額為限制。

bash
# List models included in the standard plan
curl https://bazaarlink.ai/api/v1/plans \
  | jq '.[] | select(.slug == "standard") | .models[] | {modelId, basePoints}'

呼叫訂閱制模型

使用訂閱了該方案的 API Key 發送請求即可,與一般呼叫方式完全相同:

bash
curl https://bazaarlink.ai/api/v1/chat/completions \
  -H "Authorization: Bearer sk-bl-YOUR_SUBSCRIBED_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-4o",
    "messages": [{"role": "user", "content": "Hello!"}]
  }'

查詢剩餘額度

帳戶餘額(Credits)是訂閱費用與 API 使用費的共用資金池。可透過以下端點即時查詢:

GET/api/v1/credits

Response

json
{
  "data": {
    "total_credits": 80.0000,   // current remaining balance (USD)
    "total_usage": 42.1234      // lifetime API spend since account creation
  }
}

Example

bash
curl https://bazaarlink.ai/api/v1/credits \
  -H "Authorization: Bearer sk-bl-YOUR_API_KEY"
訂閱前確認餘額
建議在呼叫 POST /api/v1/keys/:id/subscription 前先確認餘額充足。餘額不足時訂閱 API 會返回 402 錯誤,包含 required 欄位顯示所需金額。

Token 配額與重置時間

每個方案設有 Token 配額(tokenLimit)與重置週期(tokenLimitPeriod)。重置以 UTC 時間為基準:

週期
重置時間
5h每 5 小時整點重置(00:00, 05:00, 10:00, 15:00, 20:00 UTC)
day每日 00:00 UTC
week每週一 00:00 UTC
month每月 1 日 00:00 UTC

查詢方案 Token 配額

bash
# Query quota settings for all plans
curl https://bazaarlink.ai/api/v1/plans \
  | jq '.[] | {slug, tokenLimit, tokenLimitPeriod}'

# Example output:
# {
#   "slug": "standard",
#   "tokenLimit": 2000000,
#   "tokenLimitPeriod": "day"
# }

計算下次重置時間(範例)

python
from datetime import datetime, timezone, timedelta

def next_reset(period: str) -> datetime:
    now = datetime.now(timezone.utc)
    if period == "day":
        return (now + timedelta(days=1)).replace(
            hour=0, minute=0, second=0, microsecond=0)
    elif period == "week":
        days_ahead = 7 - now.weekday()  # Monday = 0
        return (now + timedelta(days=days_ahead)).replace(
            hour=0, minute=0, second=0, microsecond=0)
    elif period == "month":
        if now.month == 12:
            return now.replace(year=now.year+1, month=1, day=1,
                               hour=0, minute=0, second=0, microsecond=0)
        return now.replace(month=now.month+1, day=1,
                           hour=0, minute=0, second=0, microsecond=0)
    elif period == "5h":
        current_block = now.hour // 5
        next_block_hour = (current_block + 1) * 5
        if next_block_hour >= 24:
            next_day = (now + timedelta(days=1)).replace(
                hour=0, minute=0, second=0, microsecond=0)
            return next_day
        return now.replace(hour=next_block_hour, minute=0,
                           second=0, microsecond=0)

plan_period = "day"  # from GET /api/v1/plans
print(f"Next reset: {next_reset(plan_period).isoformat()}")
Token 計數說明
tokenLimit 計算的是實際消耗的 token 數(input + output),與 Credits 消費金額無關。超過配額的請求會收到 429 Token quota exceeded 錯誤。

取消訂閱

取消後 API Key 立即回到免費方案(標準速率限制),訂閱費用不退款。

DELETE/api/v1/keys/:id/subscription

Response

json
{ "ok": true }

Example

bash
curl -X DELETE https://bazaarlink.ai/api/v1/keys/KEY_ID/subscription \
  -H "Cookie: next-auth.session-token=YOUR_SESSION"

完整流程範例

typescript
// 1. Query available plans
const plans = await fetch("/api/v1/plans").then(r => r.json());

// 2. Check account balance
const { data: credits } = await fetch("/api/v1/credits", {
  headers: { Authorization: "Bearer sk-bl-YOUR_KEY" },
}).then(r => r.json());

// 3. Confirm balance then subscribe
const plan = plans.find(p => p.slug === "standard");
if (credits.total_credits < plan.priceUsd) {
  throw new Error(`Insufficient balance: need $${plan.priceUsd}, current $${credits.total_credits}`);
}

const sub = await fetch("/api/v1/keys/KEY_ID/subscription", {
  method: "POST",
  credentials: "include",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ planSlug: "standard" }),
}).then(r => r.json());

console.log("Subscribed! Remaining balance:", sub.remainingCredits);
console.log("Plan:", sub.subscriptionPlan.slug);
console.log("RPM:", sub.subscriptionPlan.rpmLimit);
console.log("Token quota:", sub.subscriptionPlan.tokenLimit, "/", sub.subscriptionPlan.tokenLimitPeriod);

// 4. Cancel subscription (optional)
// await fetch("/api/v1/keys/KEY_ID/subscription", {
//   method: "DELETE", credentials: "include"
// });

AI 點數系統

每個訂閱方案包含每日 AI 點數額度。不同模型每次請求消耗不同點數。

每日點數

Loading plans…

每日重置
點數每日 00:00 UTC+8 重置,不累積。 長回覆按實際 token 用量動態扣點。
新帳號優惠
新帳號(前 72 小時)每日點數減半。

點數分級規則

模型依 API 定價(input + output 每百萬 token)分級,每次請求扣除對應級別的點數。

Loading tier rules…

點數分級規則
點數分級規則也可透過 GET /api/v1/tier-brackets 取得,方便程式使用。
Claude Opus 4.6
Claude Opus 4.6 不包含在訂閱方案中,請使用加值點數(1.5× 加成)。

查詢點數餘額

GET/api/v1/points/balance
json
// GET /api/v1/points/balance
// Authorization: Bearer sk-bl-xxx

{
  "dailyLimit": 3700,
  "dailyUsed": 1250,
  "dailyRemaining": 2450,
  "resetAt": "2026-03-18T00:00:00+08:00"
}
bash
curl https://bazaarlink.ai/api/v1/points/balance \
  -H "Authorization: Bearer sk-bl-YOUR_API_KEY"

API Response Headers

Every chat completion response includes point usage headers:

x-points-used
number
Points consumed by this request.
x-points-remaining
number
Remaining daily points after this request.
x-points-daily-limit
number
Total daily point allowance for the current plan.
bash
# Example response headers:
# x-points-used: 25
# x-points-remaining: 2425
# x-points-daily-limit: 3700
Support
Support
Hi! How can we help you?
Send a message and we'll get back to you soon.
Subscription API — Per-Key Plans, Quotas & Model Access