feat(quota): support OpenAI business-account spend_control in codex quota display (#2403)
* fix(quota): support OpenAI business-account spend_control in codex Business/enterprise OpenAI accounts return a usage payload with spend_control.individual_limit instead of rate-limit windows. Keep the existing primary/secondary/credits blocks unchanged and add a new spend_limit window that surfaces used_percent and a "used / limit credits" value label. additional_rate_limits is intentionally ignored.
This commit is contained in:
@@ -97,6 +97,24 @@ export const fetchQuota = async () => {
|
||||
});
|
||||
}
|
||||
|
||||
// Business/enterprise accounts expose a dollar spend cap under
|
||||
// `spend_control.individual_limit`. Surface it as an additive `credits`
|
||||
// window so existing consumers keep working.
|
||||
if (payload?.spend_control?.individual_limit) {
|
||||
const spendLimit = payload.spend_control.individual_limit;
|
||||
const used = toNumber(spendLimit.used);
|
||||
const limit = toNumber(spendLimit.limit);
|
||||
const valueLabel = used !== null && limit !== null
|
||||
? `${used.toFixed(0)} / ${limit.toFixed(0)} used`
|
||||
: null;
|
||||
windows.credits = toUsageWindow({
|
||||
usedPercent: toNumber(spendLimit.used_percent),
|
||||
windowSeconds: null,
|
||||
resetAt: null,
|
||||
valueLabel
|
||||
});
|
||||
}
|
||||
|
||||
return buildResult({
|
||||
providerId,
|
||||
providerName,
|
||||
|
||||
Reference in New Issue
Block a user