MCPcopy Create free account
hub / github.com/arctic-cli/interface / fetchMinimaxUsage

Function fetchMinimaxUsage

packages/arctic/src/provider/usage.ts:442–486  ·  view source on GitHub ↗
(input: {
    provider: Provider.Info
    sessionID?: string
    timePeriod?: TimePeriod
  })

Source from the content-addressed store, hash-verified

440 }
441
442 async function fetchMinimaxUsage(input: {
443 provider: Provider.Info
444 sessionID?: string
445 timePeriod?: TimePeriod
446 }): Promise<Omit<Record, "providerID" | "providerName" | "fetchedAt">> {
447 const sessionData = await fetchSessionUsage(input)
448
449 let limitSummary:
450 | {
451 planType?: string
452 allowed?: boolean
453 limitReached?: boolean
454 limits?: { primary?: RateLimitWindowSummary }
455 }
456 | undefined
457 let limitError: string | undefined
458
459 const auth = await Auth.get(input.provider.id)
460 if (auth?.type === "api" && auth.groupId) {
461 const apiKey = auth.key || input.provider.key || input.provider.options?.apiKey
462 if (apiKey) {
463 limitSummary = await fetchMinimaxUsageLimits(auth.groupId, apiKey).catch((error) => {
464 limitError = error instanceof Error ? error.message : String(error)
465 return undefined
466 })
467 }
468 }
469
470 const record: Omit<Record, "providerID" | "providerName" | "fetchedAt"> = {
471 ...sessionData,
472 }
473
474 if (limitSummary) {
475 record.planType = limitSummary.planType
476 record.allowed = limitSummary.allowed
477 record.limitReached = limitSummary.limitReached
478 record.limits = limitSummary.limits
479 }
480
481 if (limitError) {
482 record.error = limitError
483 }
484
485 return record
486 }
487
488 async function fetchMinimaxUsageLimits(groupId: string, apiKey: string): Promise<{
489 planType?: string

Callers

nothing calls this directly

Calls 3

fetchSessionUsageFunction · 0.85
fetchMinimaxUsageLimitsFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected