feat(xai): track SuperGrok weekly limit + API usage quota
Fetch OAuth quota from cli-chat-proxy billing, GetGrokCreditsConfig weekly window, and settings plan label so the dashboard matches grok.com usage.
This commit is contained in:
@@ -451,6 +451,48 @@ export function parseQuotaData(provider, data) {
|
||||
}
|
||||
break;
|
||||
|
||||
case "xai":
|
||||
// xAI mixes:
|
||||
// - weekly: percentage window (used/total 0-100) from GetGrokCreditsConfig
|
||||
// - api_usage: absolute monthly credits from /v1/billing
|
||||
// For absolute rows, do not forward remainingCredits as `remaining`
|
||||
// (QuotaTable treats remaining as a 0-100 percentage; same pitfall as Qoder).
|
||||
if (data.quotas) {
|
||||
Object.entries(data.quotas).forEach(([quotaType, quota]) => {
|
||||
const name =
|
||||
quotaType === "weekly"
|
||||
? "Weekly limit"
|
||||
: quotaType === "api_usage"
|
||||
? "Api usage"
|
||||
: quotaType === "monthly"
|
||||
? "Api usage"
|
||||
: quotaType === "on_demand"
|
||||
? "On-demand"
|
||||
: quotaType;
|
||||
|
||||
if (quotaType === "weekly") {
|
||||
normalizedQuotas.push({
|
||||
name,
|
||||
used: quota.used || 0,
|
||||
total: quota.total || 100,
|
||||
remaining: quota.remaining,
|
||||
remainingPercentage: quota.remainingPercentage ?? quota.remaining,
|
||||
resetAt: quota.resetAt || null,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
normalizedQuotas.push({
|
||||
name,
|
||||
used: quota.used || 0,
|
||||
total: quota.total || 0,
|
||||
unit: quota.unit,
|
||||
resetAt: quota.resetAt || null,
|
||||
});
|
||||
});
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
// Generic fallback for unknown providers
|
||||
if (data.quotas) {
|
||||
|
||||
Reference in New Issue
Block a user