feat(quota): add usage tracking for Groq
First slice of #3701: quota tracking for Groq via x-ratelimit-* response headers on the models endpoint (no dedicated quota endpoint exists, and reading usage costs zero tokens). - usage/groq.js: parse request+token limit/remaining headers; Go-style duration reset headers ("2m59.56s") resolve to future timestamps; missing key/401/403 -> message, 2xx without headers -> soft "not tracked yet" with quotas:{} - registry/groq.js: transport.usage.url (reuses validateUrl) + features {usage, usageApikey} - services/usage.js: groq entry in USAGE_HANDLERS - ProviderLimits/utils.js: parseQuotaData case (absolute used/total, codex/kiro style) - tests: groq-usage.test.js (registry flags, header parsing, soft not-tracked path, missing key/401, parseQuotaData)
This commit is contained in:
@@ -14,6 +14,7 @@ import { getCodeBuddyCnUsage, getCodeBuddyIntlUsage } from "./usage/codebuddy-cn
|
||||
import { getGrokCliUsage } from "./usage/grok-cli.js";
|
||||
import { getKimiUsage } from "./usage/kimi.js";
|
||||
import { getDeepseekUsage } from "./usage/deepseek.js";
|
||||
import { getGroqUsage } from "./usage/groq.js";
|
||||
import { getZedUsage } from "./usage/zed.js";
|
||||
import { resolveQoderCredentials } from "./qoderModels.js";
|
||||
import { getGlmUsage } from "./usage/glm.js";
|
||||
@@ -55,6 +56,7 @@ const USAGE_HANDLERS = {
|
||||
"grok-cli": (c) => getGrokCliUsage(c.accessToken, c.providerSpecificData, c.proxyOptions),
|
||||
kimi: (c) => getKimiUsage(c.accessToken, c.apiKey, c.proxyOptions, c.providerSpecificData),
|
||||
deepseek: (c) => getDeepseekUsage(c.apiKey, c.proxyOptions),
|
||||
groq: (c) => getGroqUsage(c.apiKey, c.proxyOptions),
|
||||
zed: (c) => getZedUsage(c.accessToken, c.providerSpecificData, c.proxyOptions),
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user