BazaarLinkBazaarLink
登入
文件API 参考SDK 参考Agent 应用AI Skills
管理密钥

创建 BYOK 密钥

为组织创建一把 BYOK 上游密钥并立即同步模型目录。上游密钥(apiKey)仅在此请求中以明文出现,存储时加密,之后永远只返回遮蔽形式(keyMask)。创建成功回 201,附上密钥对象与模型同步结果(sync)。

POST/api/v1/management/byok-keys

验证

Authorization必填
string · header

在 Authorization 标头以 Bearer token 传入 API 密钥。

Body

name必填
string

密钥的显示名称。

1-200 chars
baseUrl必填
string

上游供应商的 API base URL。私有/内网地址会被拒绝(400)。

1-2000 chars, public HTTPS endpoint
apiKey必填
string

上游供应商的 API 密钥明文。只在此请求出现;存储加密,之后仅返回 keyMask。

1-2000 chars
protocol
string

上游的 API 接口协议,默认 openai。

openaianthropic
Example: "openai"
fallbackMode
string

上游失败时的行为:seamless(默认)=无缝回退到平台路由;strict=不回退,直接回错误。

seamlessstrict
Example: "seamless"
disabledCanonicalIds
string[]

创建时要先停用的模型(canonical id)清单;同步后这些模型不会经此密钥路由。

≤2000 items
scopedApiKeyIds
string[]

限定此 BYOK 只套用于哪些平台 API 密钥(密钥 id)。空/省略=组织全部密钥适用。含不属于你组织的密钥 id 会被拒(400)。

≤200 items; must be your own keys
POST /api/v1/management/byok-keys
curl https://bazaarlink.ai/api/v1/management/byok-keys \
  -H "Authorization: Bearer $BAZAARLINK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "team-upstream",
    "baseUrl": "https://api.example-upstream.com/v1",
    "apiKey": "'$UPSTREAM_API_KEY'",
    "protocol": "openai",
    "fallbackMode": "seamless"
  }'
响应示例

已创建。key 为密钥对象(仅含 keyMask);sync 回报模型目录同步结果:matched(对上平台目录的模型数)、unmatched(上游有但平台目录没有的模型 id)、stale(是否需要之后重新同步)。

{
  "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": "seamless",
    "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": []
  },
  "sync": {
    "matched": 12,
    "unmatched": [
      "internal-model-x"
    ],
    "stale": false
  }
}
客服
客服
您好!有什么可以协助?
请留下消息,我们会尽快回复。
创建 BYOK 密钥 — BazaarLink API