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
import { test } from "node:test";
import assert from "node:assert/strict";
import { isPaidModelTarget, matchesOnlyPaidModels } from "@/shared/utils/freeModels";
test("isPaidModelTarget — documented free model → 'free'", () => {
assert.equal(isPaidModelTarget("openrouter/auto"), "free");
});
test("isPaidModelTarget — provider in free catalog but model not listed free → 'paid'", () => {
assert.equal(isPaidModelTarget("gemini/gemini-3.1-pro-preview"), "paid");
});
test("isPaidModelTarget — no separator (combo/alias name) → 'unknown' (fail open)", () => {
assert.equal(isPaidModelTarget("my-combo-name"), "unknown");
});
test("isPaidModelTarget — provider not in free catalog at all → 'unknown' (fail open)", () => {
assert.equal(isPaidModelTarget("totally-unknown-provider/whatever"), "unknown");
});
test("isPaidModelTarget — comma-separated form matches slash form", () => {
assert.equal(isPaidModelTarget("openrouter,auto"), isPaidModelTarget("openrouter/auto"));
});
test("isPaidModelTarget — empty/non-string input → 'unknown'", () => {
assert.equal(isPaidModelTarget(""), "unknown");
// @ts-expect-error — exercising runtime guard against non-string input
assert.equal(isPaidModelTarget(undefined), "unknown");
});
test("matchesOnlyPaidModels — true when every match is paid", () => {
assert.equal(matchesOnlyPaidModels("together/*"), true);
});
test("matchesOnlyPaidModels — false when at least one match is free", () => {
assert.equal(matchesOnlyPaidModels("openrouter/*"), false);
});
test("matchesOnlyPaidModels — false (fail open) when there are zero matches", () => {
assert.equal(matchesOnlyPaidModels("zzz-totally-nonexistent-pattern-*"), false);
});
test("matchesOnlyPaidModels — false on empty pattern", () => {
assert.equal(matchesOnlyPaidModels(""), false);
});