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
TypeScript a2aai-agentsai-gatewayanthropicclaudeclaude-codeclinecodexcopilotcursordeepseekfree-aigeminikimillm-gatewaymcpopenaiopenai-proxyqwentoken-saver
/**
* @file alibabaFreeTierQuotaTypes.ts
* @description Shared types + small primitive helpers for the Alibaba free-tier quota
* fetcher/classifier split (extracted from alibabaFreeTierQuotaFetcher.ts to keep that
* file under the file-size cap; behavior is unchanged).
*/
export type AlibabaFreeTierQuotaEntry = {
model: string;
freeTierOnly: boolean;
quotaStatus: string;
quotaTotal?: number;
quotaInitTotal?: number;
quotaTotalPercentage?: number;
quotaValidityPeriod?: number;
};
export type AlibabaFreeTierQuotaClassification = {
capableModels: string[];
noFreeTierModels: string[];
drainedModels: string[];
entries: AlibabaFreeTierQuotaEntry[];
};
export type AlibabaFreeTierQuotaSnapshot = {
text: AlibabaFreeTierQuotaClassification;
vision: AlibabaFreeTierQuotaClassification;
multimodal: AlibabaFreeTierQuotaClassification;
audio: AlibabaFreeTierQuotaClassification;
entries: AlibabaFreeTierQuotaEntry[];
};
export function asRecord(value: unknown): Record<string, unknown> {
return value && typeof value === "object" && !Array.isArray(value)
? (value as Record<string, unknown>)
: {};
}
export function toTrimmedString(value: unknown): string | null {
return typeof value === "string" && value.trim().length > 0 ? value.trim() : null;
}
export function normalizeModelIdList(raw: unknown): string[] {
if (!Array.isArray(raw)) return [];
return raw.filter((entry): entry is string => typeof entry === "string" && entry.length > 0);
}
export function getAlibabaFreeTierQuotaLastSyncAt(
providerSpecificData: Record<string, unknown> | null | undefined
): string | null {
return toTrimmedString(asRecord(providerSpecificData).alibabaFreeTierQuotaLastSyncAt);
}
/** True when the connection has a live console/API quota snapshot (not builtin fallback). */
export function isAlibabaLiveQuotaSyncAt(syncAt: string | null | undefined): boolean {
if (!syncAt || syncAt === "builtin-allowlist") return false;
return Number.isFinite(Date.parse(syncAt));
}