Skip to content

Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors

fix(claude): correct utilization inversion and propagate remainingPercentage

DavyMassoneto2ec0cd13cd07
diff --git a/open-sse/services/usage.ts b/open-sse/services/usage.ts
index b9166d062d..5fa08b70b4 100644
--- a/open-sse/services/usage.ts
+++ b/open-sse/services/usage.ts
@@ -443,23 +443,25 @@ async function getClaudeUsage(accessToken) {
const data = await oauthResponse.json();
const quotas: Record<string, any> = {};
- // utilization = percentage remaining, not used
+ // utilization = percentage USED (e.g., 22 means 22% used, 78% remaining)
const createQuotaObject = (window: any) => {
- const remaining = window.utilization ?? 0;
+ const used = window?.utilization ?? 0;
+ const remaining = 100 - used;
return {
- used: 100 - remaining,
+ used,
total: 100,
- resetAt: parseResetTime(window.resets_at) || null,
+ remaining,
+ resetAt: parseResetTime(window?.resets_at),
remainingPercentage: remaining,
unlimited: false,
};
};
- if (data.five_hour !== undefined) {
+ if (data.five_hour && typeof data.five_hour === "object") {
quotas["session (5h)"] = createQuotaObject(data.five_hour);
}
- if (data.seven_day !== undefined) {
+ if (data.seven_day && typeof data.seven_day === "object") {
quotas["weekly (7d)"] = createQuotaObject(data.seven_day);
}
@@ -479,7 +481,7 @@ async function getClaudeUsage(accessToken) {
return {
plan: "Claude Code",
quotas,
- extraUsage: data.extra_usage || null,
+ extraUsage: data.extra_usage ?? null,
};
}
diff --git a/src/app/(dashboard)/dashboard/usage/components/ProviderLimits/utils.tsx b/src/app/(dashboard)/dashboard/usage/components/ProviderLimits/utils.tsx
index 86e098832e..3212355141 100644
--- a/src/app/(dashboard)/dashboard/usage/components/ProviderLimits/utils.tsx
+++ b/src/app/(dashboard)/dashboard/usage/components/ProviderLimits/utils.tsx
@@ -159,6 +159,7 @@ export function parseQuotaData(provider, data) {
used: quota.used || 0,
total: quota.total || 0,
resetAt: quota.resetAt || null,
+ remainingPercentage: quota.remainingPercentage,
});
});
}