限制
限制
JoyToken 当前公开限制主要来自 API Key 额度、Key 策略和钱包余额预检查。不要假设固定 QPS、RPM 或 TPM 配额。
当前限制
Tier 回退
当请求使用 model: "auto" 或省略 model 时,JoyToken 可在当前 tier 余额不足时尝试其他 tier。
指定具体模型时,JoyToken 不会因为余额不足自动换成其他模型。
限制
JoyToken 当前公开限制主要来自 API Key 额度、Key 策略和钱包余额预检查。不要假设固定 QPS、RPM 或 TPM 配额。
| 限制 | 来源 | 命中结果 |
|---|---|---|
| 每日额度 | API Key 预算 | 402 insufficient_quota |
| 每周额度 | API Key 预算 | 402 insufficient_quota |
| 钱包余额 | 个人或组织钱包 | 402 insufficient_quota |
| 固定模型 | API Key 策略 | 403 policy_rejected |
| 模型黑名单 | API Key 策略 | 403 policy_rejected |
| Tier 白名单 | API Key 策略和请求 tier | 403 policy_rejected |
| IP 白名单/黑名单 | API Key 策略 | 403 policy_rejected |
当请求使用 model: "auto" 或省略 model 时,JoyToken 可在当前 tier 余额不足时尝试其他 tier。
| 当前 tier | 回退顺序 |
|---|---|
premium | standard -> economy |
standard | premium -> economy |
economy | standard -> premium |
指定具体模型时,JoyToken 不会因为余额不足自动换成其他模型。
| 错误 | 是否重试 | 处理方式 |
|---|---|---|
400 | 否 | 修正请求体 |
401 | 否 | 补充 API Key |
402 | 否 | 充值或调整 Key 预算 |
403 | 否 | 调整策略、IP、tier 或模型 |
502 | 可短退避 | 可能是路由或上游临时失败 |
503 / 504 | 是 | 指数退避重试 |
1 const retryableStatuses = new Set([502, 503, 504]); 2 3 export async function withJoyTokenRetry<T>(fn: () => Promise<T>, attempts = 3) { 4 let lastError: unknown; 5 6 for (let attempt = 0; attempt < attempts; attempt += 1) { 7 try { 8 return await fn(); 9 } catch (error: any) { 10 lastError = error; 11 const status = error?.status ?? error?.response?.status; 12 if (!retryableStatuses.has(status) || attempt === attempts - 1) throw error; 13 await new Promise((resolve) => setTimeout(resolve, 300 * 2 ** attempt)); 14 } 15 } 16 17 throw lastError; 18 }