限制

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

档位回退

每个请求都必须传入 model: "auto";当前 tier 余额不足时,JoyToken 可在策略允许范围内尝试其他 tier。

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

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

客户端处理

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

指数退避

const retryableStatuses = new Set([502, 503, 504]);
export async function withJoyTokenRetry<T>(fn: () => Promise<T>, attempts = 3) {
let lastError: unknown;
for (let attempt = 0; attempt < attempts; attempt += 1) {
try {
return await fn();
} catch (error: any) {
lastError = error;
const status = error?.status ?? error?.response?.status;
if (!retryableStatuses.has(status) || attempt === attempts - 1) throw error;
await new Promise((resolve) => setTimeout(resolve, 300 * 2 ** attempt));
}
}
throw lastError;
}