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.5 KB
Raw Blame
/**
 * VS Code Combos endpoint — re-export base Ollama-compatible routes
 * and intercept GET to return combo metadata.
 *
 * The VS Code extension expects a standard Ollama server at the base URL,
 * so we re-export /api/version, /api/tags, etc. from the [token] parent route.
 */
import { getCombos } from "@/lib/db/combos";
import { projectComboCollectionWithCapabilities } from "@/app/api/v1/combos/projectCombo";

// Re-export Ollama-compatible endpoints from the parent [token] route
// so VS Code can validate the server version and list models normally
export { OPTIONS } from "@/app/api/v1/vscode/[token]/route";
export async function GET(request: Request) {
  // If client requests /api/version or other Ollama endpoints, delegate to parent
  const url = new URL(request.url);
  if (url.pathname.includes("/api/version") || url.pathname.includes("/api/tags")) {
    const { GET: parentGET } = await import("@/app/api/v1/vscode/[token]/route");
    return parentGET(request);
  }

  // Default: return combos metadata
  try {
    const combos = await getCombos();
    const allCombos = Array.isArray(combos) ? combos : [];
    const data = projectComboCollectionWithCapabilities(allCombos);

    return new Response(JSON.stringify({ object: "list", data, combos: data }), {
      headers: {
        "Content-Type": "application/json",
        "Cache-Control": "no-store",
      },
    });
  } catch {
    return new Response(JSON.stringify({ error: "Failed to fetch combos" }), {
      status: 500,
      headers: { "Content-Type": "application/json" },
    });
  }
}