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
export type ServiceTierId = "standard" | "priority" | "flex";
export type TranslationFn = ((key: string, values?: Record<string, unknown>) => string) & {
has?: (key: string) => boolean;
};
const SERVICE_TIER_LABEL_KEYS: Record<ServiceTierId, string> = {
priority: "serviceTierFast",
flex: "serviceTierFlex",
standard: "serviceTierStandard",
};
const SERVICE_TIER_FALLBACK_LABELS: Record<ServiceTierId, string> = {
priority: "Fast",
flex: "Flex",
standard: "Standard",
};
export function normalizeServiceTierId(value: unknown): ServiceTierId {
const tier = typeof value === "string" ? value.trim().toLowerCase() : "";
if (tier === "priority" || tier === "fast") return "priority";
if (tier === "flex") return "flex";
return "standard";
}
export function translateCostText(t: TranslationFn, key: string, fallback: string): string {
return typeof t.has === "function" && t.has(key) ? t(key) : fallback;
}
export function getServiceTierDisplayLabel(
t: TranslationFn,
serviceTier: unknown,
fallback?: unknown
): string {
const normalized = normalizeServiceTierId(serviceTier);
const fallbackText = typeof fallback === "string" ? fallback.trim() : "";
const fallbackLabel =
fallbackText && normalizeServiceTierId(fallbackText) !== normalized
? fallbackText
: SERVICE_TIER_FALLBACK_LABELS[normalized];
return translateCostText(t, SERVICE_TIER_LABEL_KEYS[normalized], fallbackLabel);
}