限制与错误
每次拒绝都以 JSON 返回,HTTP 状态码见下表:
{
"category": "permission_denied",
"message": "The CLI isn't on for your company",
"details": {}
}
message 可以直接展示给用户(为英文)。details 中可能还有 reason(固定代码)、reasonZh(中文原因)和upstreamStatus(供应商自己的状态码)。因费用限额返回的 429 还会在 message 旁带有 retryAfterSeconds。
限制
| 项目 | 值 |
|---|---|
| 使用者 | 已开启 CLI 的公司的管理员 |
| 令牌有效期 | 90 天 |
| 请求正文 | 8 MB |
| 响应 | 8 MB |
| 路径 | 2,000 个字符 |
| 流式响应 | 逐个事件返回;每个事件最多 8 MB |
| 费用 | 贵公司和您本人的每月 AI 费用限额 |
登录与令牌
| 状态码 | category | details.reason | 原因 |
|---|---|---|---|
| 401 | unauthenticated | 缺少令牌、令牌已过期或已撤销,或持有人已不能再持有令牌。请运行 wb login。 | |
| 401 | unauthenticated | “Sign-in expired. Try again.”:wb login 的浏览器步骤超过 5 分钟,或该授权已被使用。 | |
| 400 | bad_request | “The CLI's sign-in link is not valid; run wb login again”:登录链接无效。 | |
| 403 | permission_denied | cli_off | 贵公司未开启 Workbench CLI。 |
| 403 | permission_denied | pat_admins_only | 试用期间只有公司管理员可以创建个人令牌。 |
| 403 | permission_denied | pat_needs_sign_in | 查看、创建或撤销令牌需要在 Workbench 应用中登录,不能使用个人令牌。 |
| 400 | bad_request | 令牌名称须为 1 到 100 个字符。 | |
| 404 | not_found | 没有这个个人令牌:它不属于您。 |
调用连接
| 状态码 | category | 原因(message) |
|---|---|---|
| 403 | permission_denied | “The CLI acts only for a signed-in person of the company”:令牌不属于本公司的成员本人(例如来自其他公司的访客)。 |
| 403 | permission_denied | “The CLI isn't on for your company”:贵公司未开启 CLI。 |
| 403 | permission_denied | “During the CLI trial only the company's admins can call connections”(或 “call models”):试用期间只有公司管理员可以调用。 |
| 404 | not_found | “No such connection”:该名称不在 wb connections 的列表中。 |
| 400 | bad_request | “Your company has no DigiKey key: a company admin adds it under Company keys”(替换为相应连接名):公司尚未添加该密钥。 |
| 400 | bad_request | “The CLI sends GET, POST, PUT, PATCH, DELETE”:使用了其他方法。 |
| 400 | bad_request | “The CLI sends Anthropic model calls as POST /v1/proxy/anthropic/v1/messages; its other paths take GET”(OpenAI 为 v1/responses)。 |
| 400 | bad_request | “Request too large: the CLI sends at most 8 MB”:请求超过 8 MB。 |
| 400 | bad_request | “That path can't be sent”:路径超过 2,000 个字符,或含有空格、控制字符或反斜杠。 |
| 400 | bad_request | “That address can't be sent”:端口不是数字。 |
| 400 | bad_request | “TrustedParts takes a JSON object body”:TrustedParts 的请求正文必须是 JSON 对象。 |
| 403 | permission_denied | “The CLI calls connections over HTTPS only”:只允许 HTTPS。 |
| 403 | permission_denied | “The DigiKey connection doesn't reach that host”:其他主机、端口,或地址中带有用户名。 |
| 429 | rate_limited | “Your company has used this month's spending limit ($… of $…). A company admin can raise it.”:贵公司已用完本月费用限额。retryAfterSeconds 为距下个月的秒数。 |
| 429 | rate_limited | “You have used this month's spending limit ($… of $…). A company admin can raise it.”:您本人已用完本月费用限额。 |
| 502 | internal | “The DigiKey connection couldn't be reached” 或 “DigiKey sign-in failed (HTTP …)”:无法连接供应商。 |
| 502 | internal | “The DigiKey answer held your company's key, so Workbench withheld it.”:响应中包含贵公司的密钥,已被拦截。 |
| 502 | internal | “The DigiKey answer couldn't be checked for your company's key, so Workbench withheld it.”:响应超过 8 MB,或使用了 Workbench 无法解压的压缩方式,因此无法检查,已被拦截。 |
已经开始的流式响应无法再改变状态码。当某个事件包含贵公司的密钥或无法检查(超过 8 MB),或供应商中途断开时,流式响应会在该处结束,并发送最后一个事件 event: error,其数据为 {"type": "error", "error": {...}}:与上表相同的 Error,或“The DigiKey stream broke off, so Workbench ended it.”。被拦下的那个事件不会发送。
模型调用还要遵守 AI 中继自己的规则:贵公司允许的模型和每人的限额。这些拒绝的格式相同。
供应商拒绝时
Workbench 从不转发供应商的错误正文,因为供应商有时会在其中回显密钥。您收到的是 Workbench 错误:供应商的状态码在details.upstreamStatus 中;如果供应商给出了错误类型和代码,则分别在 details.vendorType 和 details.vendorCode 中。
| 供应商状态码 | 返回给您的状态码 | category |
|---|---|---|
| 400、409、413、415、422 | 相同 | bad_request |
| 401、403 | 403 | permission_denied |
| 404 | 404 | not_found |
| 429 | 429,附带供应商的 Retry-After | rate_limited |
| 其他(包括重定向和 5xx) | 502 | internal |
例如 message 为 “DigiKey answered HTTP 404. Workbench doesn't pass on a vendor's error body.”,details.reasonZh为 “DigiKey 返回了 HTTP 404。Workbench 不转发服务商的错误内容。”。供应商返回 401 或 403 通常表示贵公司为它设置的密钥有误或已过期:请让公司管理员在“公司密钥”中更新。