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

801 B
Raw Blame
export const SELF_USAGE_SCOPE = "self:usage";
export const SELF_ACCOUNT_QUOTA_SCOPE = "self:account-quota";

export const DEFAULT_SELF_SERVICE_SCOPES = [SELF_USAGE_SCOPE] as const;

export function hasSelfUsageScope(scopes: readonly string[] | null | undefined): boolean {
  return Array.isArray(scopes) && scopes.includes(SELF_USAGE_SCOPE);
}

export function hasSelfAccountQuotaScope(scopes: readonly string[] | null | undefined): boolean {
  return Array.isArray(scopes) && scopes.includes(SELF_ACCOUNT_QUOTA_SCOPE);
}

export function normalizeSelfServiceScopesForCreate(
  scopes: readonly string[] | null | undefined
): string[] {
  const normalized = new Set((scopes ?? []).filter((scope) => typeof scope === "string" && scope));
  normalized.add(SELF_USAGE_SCOPE);
  return [...normalized];
}