BazaarLinkBazaarLink
登入
文件API 參考SDK 參考Agent 應用AI Skills
管理金鑰

更新 BYOK 金鑰

更新單一 BYOK 金鑰:啟用/停用、改名、切換回退模式、逐模型開關(modelToggles)、重設適用範圍(scopedApiKeyIds)。所有欄位皆可選;上游金鑰本身不可更換——要換金鑰請刪除後重建。

PATCH/api/v1/management/byok-keys/:id

驗證

Authorization必填
string · header

在 Authorization 標頭以 Bearer token 傳入 API 金鑰。

路徑參數

id必填
string

BYOK 金鑰 id。

Body

enabled
boolean

整把金鑰的總開關。

fallbackMode
string

上游失敗時是否回退到平台路由。

seamlessstrict
name
string

新的顯示名稱。

1-200 chars
modelToggles
{canonicalId, enabled}[]

逐模型開關:每個元素指定一個 canonicalId 與 enabled。只影響列出的模型,未列出的維持原狀。

≤2000 items
scopedApiKeyIds
string[]

整組替換適用範圍:空陣列=恢復為組織全部金鑰適用。含不屬於你組織的金鑰 id 回 400。

≤200 items; must be your own keys
PATCH /api/v1/management/byok-keys/:id
curl -X PATCH https://bazaarlink.ai/api/v1/management/byok-keys/byok_abc123 \
  -H "Authorization: Bearer $BAZAARLINK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"fallbackMode": "strict", "modelToggles": [{"canonicalId": "openai/gpt-4o", "enabled": false}]}'
回應範例

更新成功,回傳更新後的 { key }。

{
  "key": {
    "id": "byok_abc123",
    "ownerType": "org",
    "userId": null,
    "organizationId": "org_abc123",
    "name": "team-upstream",
    "baseUrl": "https://api.example-upstream.com/v1",
    "keyMask": "sk-abc…wxyz",
    "protocol": "openai",
    "enabled": true,
    "fallbackMode": "strict",
    "modelsStale": false,
    "lastVerifiedAt": "2026-07-29T00:00:00.000Z",
    "lastErrorAt": null,
    "lastErrorCode": null,
    "errorCount1h": 0,
    "createdAt": "2026-07-29T00:00:00.000Z",
    "updatedAt": "2026-07-29T00:00:00.000Z",
    "models": [
      {
        "canonicalId": "openai/gpt-4o",
        "upstreamModelId": "gpt-4o",
        "enabled": true
      }
    ],
    "scopedApiKeyIds": []
  }
}
客服
客服
您好!有什麼可以協助?
請留下訊息,我們會盡快回覆。
更新 BYOK 金鑰 — BazaarLink API