管理 API 金鑰
管理 API 金鑰
管理金鑰(Management Key)專用於程式化管理 API 金鑰:可建立、列出、更新、停用與刪除標準金鑰,但無法呼叫 AI 模型。
備註
管理金鑰無法進行模型呼叫(chat、completions、messages、embeddings)。如需呼叫模型,請使用標準 API 金鑰。
建立管理金鑰
前往「Management API Keys」頁面,點擊「Create」即可 — 這是獨立頁面,不是在一般 API 金鑰頁面裡選類型。
列出金鑰
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
GET https://api.bazaarlink.ai/v1/keys
Authorization: Bearer sk-bl-YOUR_MGMT_KEY
{
"keys": [
{
"id": "clxyz123...",
"name": "Production Key",
"keyType": "standard",
"keyPrefix": "sk-bl-abc1",
"keySuffix": "XyZ9",
"enabled": true,
"spendLimitUsd": 10.00,
"spendLimitPeriod": "month",
"expiresAt": null,
"createdAt": "2026-01-01T00:00:00.000Z",
"lastUsed": "2026-03-01T12:34:56.000Z",
"requestCount": 1234,
"totalTokens": 5678901
}
]
}
建立子金鑰
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
POST https://api.bazaarlink.ai/v1/keys
Authorization: Bearer sk-bl-YOUR_MGMT_KEY
Content-Type: application/json
{
"name": "Agent Key",
"limit": 10.00,
"limit_reset": "monthly",
"expires_at": "2026-12-31T23:59:59Z"
}
{
"id": "clxyz789...",
"name": "Agent Key",
"key": "sk-bl-xyz789abcdef...",
"keyType": "standard",
"spendLimitUsd": 10.00,
"spendLimitPeriod": "month",
"expiresAt": "2026-12-31T23:59:59.000Z",
"enabled": true,
"createdAt": "2026-03-01T00:00:00.000Z"
}
更新金鑰
PATCH https://api.bazaarlink.ai/v1/keys/:id
Authorization: Bearer sk-bl-YOUR_MGMT_KEY
Content-Type: application/json
{"enabled": false}
{"spendLimitUsd": 5, "spendLimitPeriod": "week"}
{"spendLimitUsd": null}
撤銷金鑰
DELETE https://api.bazaarlink.ai/v1/keys/:id
Authorization: Bearer sk-bl-YOUR_MGMT_KEY
查詢餘額
GET https://api.bazaarlink.ai/v1/credits
Authorization: Bearer sk-bl-YOUR_MGMT_KEY
{
"data": {
"total_credits": 12.345,
"total_usage": 3.210
}
}
查詢用量
GET https://api.bazaarlink.ai/v1/usage?period=month
Authorization: Bearer sk-bl-YOUR_MGMT_KEY