限制

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 策略和请求 tier403 policy_rejected
IP 白名单/黑名单API Key 策略403 policy_rejected

Tier 回退

当请求使用 model: "auto" 或省略 model 时,JoyToken 可在当前 tier 余额不足时尝试其他 tier。

当前 tier回退顺序
premiumstandard -> economy
standardpremium -> economy
economystandard -> premium

指定具体模型时,JoyToken 不会因为余额不足自动换成其他模型。

客户端处理

错误是否重试处理方式
400修正请求体
401补充 API Key
402充值或调整 Key 预算
403调整策略、IP、tier 或模型
502可短退避可能是路由或上游临时失败
503 / 504指数退避重试

指数退避

1const retryableStatuses = new Set([502, 503, 504]);
2
3export 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}