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.0 KB
Raw Blame
import test from "node:test";
import assert from "node:assert/strict";
import { detectFormatFromEndpoint } from "@omniroute/open-sse/services/provider.ts";

const ENVELOPE = {
  model: "gemini-2.5-pro",
  project: "projects/test",
  request: { contents: [{ role: "user", parts: [{ text: "oi" }] }] },
};

test("detectFormatFromEndpoint classifies the /v1/antigravity path as antigravity", () => {
  assert.equal(detectFormatFromEndpoint(ENVELOPE, "/v1/antigravity"), "antigravity");
  assert.equal(detectFormatFromEndpoint(ENVELOPE, "/api/v1/antigravity"), "antigravity");
  assert.equal(
    detectFormatFromEndpoint(ENVELOPE, "/v1/antigravity:streamGenerateContent"),
    "antigravity"
  );
});

test("the antigravity carve-out does not disturb the other endpoint formats", () => {
  assert.equal(detectFormatFromEndpoint({ messages: [] }, "/v1/messages"), "claude");
  assert.equal(detectFormatFromEndpoint({ messages: [] }, "/v1/chat/completions"), "openai");
  assert.equal(detectFormatFromEndpoint({ input: "x" }, "/v1/responses"), "openai-responses");
});