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

1.6 KB
Raw Blame
/**
 * The catalog paid filter and the `auto/*` pool filter share one predicate:
 * a model stays listed only when its provider documents free models AND the
 * model itself qualifies as free.
 */
import assert from "node:assert/strict";
import { describe, it } from "node:test";
import { decideHidePaid } from "../../src/app/api/v1/models/catalogPaidFilter.ts";

describe("catalog decideHidePaid", () => {
  it("keeps a catalog-free model on a free-tier provider listed", () => {
    assert.equal(decideHidePaid(true, "cerebras", "zai-glm-4.7"), false);
  });

  it("hides a paid model even when the payload claims it is free", () => {
    assert.equal(decideHidePaid(true, "openai", "gpt-4o", undefined, true), true);
  });

  it("lists everything when the paid filter is off", () => {
    assert.equal(decideHidePaid(false, "openai", "gpt-4o", undefined, true), false);
  });

  it("lists a catalog-free model that STRICT still excludes without hard-stop proof", async () => {
    assert.equal(decideHidePaid(true, "bluesminds", "gpt-4o"), false);
    const { classifyStrictZeroCostCandidate, findBudgetEntry } =
      await import("../../open-sse/services/autoCombo/strictZeroCostFilter.ts");
    const candidate = {
      provider: "bluesminds",
      model: "gpt-4o",
      connectionId: "c1",
      allowedConnectionIds: ["c1"],
    };
    const verdict = classifyStrictZeroCostCandidate(
      candidate,
      findBudgetEntry(candidate),
      () => null,
      {
        minRemainingAllowance: 1,
        maxStateAgeMs: 180_000,
      }
    );
    assert.equal(verdict.outcome, "no-hard-stop");
  });
});