From 9ee8b32887a85ff6667ec89a8554899fb181e615 Mon Sep 17 00:00:00 2001 From: Delcado19 <85063283+Delcado19@users.noreply.github.com> Date: Fri, 29 May 2026 17:07:32 +0700 Subject: [PATCH] fix: include free OpenCode models without -free suffix in suggested models (#1535) The "opencode-free" suggested-models filter only kept models whose id ends in "-free", so free-but-unsuffixed models like `big-pickle` (routed via open-sse/executors/opencode.js MESSAGES_MODELS) never appeared in the import UI. Extract the filters into a testable module and include a KNOWN_FREE_OPENCODE_MODELS allowlist (big-pickle) alongside the "-free" suffix check. Co-Authored-By: Claude Opus 4.8 Co-authored-by: Cursor --- .../api/providers/suggested-models/filters.js | 20 +++++++++++++++++++ .../api/providers/suggested-models/route.js | 19 +----------------- 2 files changed, 21 insertions(+), 18 deletions(-) create mode 100644 src/app/api/providers/suggested-models/filters.js diff --git a/src/app/api/providers/suggested-models/filters.js b/src/app/api/providers/suggested-models/filters.js new file mode 100644 index 00000000..c8d56c51 --- /dev/null +++ b/src/app/api/providers/suggested-models/filters.js @@ -0,0 +1,20 @@ +// Free OpenCode models that don't use the "-free" id suffix +const KNOWN_FREE_OPENCODE_MODELS = ["big-pickle"]; + +export const FILTERS = { + "openrouter-free": (models) => + models + .filter( + (m) => + m.pricing?.prompt === "0" && + m.pricing?.completion === "0" && + m.context_length >= 200000 + ) + .map((m) => ({ id: m.id, name: m.name, contextLength: m.context_length })) + .sort((a, b) => b.contextLength - a.contextLength), + + "opencode-free": (models) => + models + .filter((m) => m.id?.endsWith("-free") || KNOWN_FREE_OPENCODE_MODELS.includes(m.id)) + .map((m) => ({ id: m.id, name: m.id })), +}; diff --git a/src/app/api/providers/suggested-models/route.js b/src/app/api/providers/suggested-models/route.js index 140e3f86..c14f70c8 100644 --- a/src/app/api/providers/suggested-models/route.js +++ b/src/app/api/providers/suggested-models/route.js @@ -1,25 +1,8 @@ import { NextResponse } from "next/server"; +import { FILTERS } from "./filters.js"; export const dynamic = "force-dynamic"; -const FILTERS = { - "openrouter-free": (models) => - models - .filter( - (m) => - m.pricing?.prompt === "0" && - m.pricing?.completion === "0" && - m.context_length >= 200000 - ) - .map((m) => ({ id: m.id, name: m.name, contextLength: m.context_length })) - .sort((a, b) => b.contextLength - a.contextLength), - - "opencode-free": (models) => - models - .filter((m) => m.id?.endsWith("-free")) - .map((m) => ({ id: m.id, name: m.id })), -}; - export async function GET(request) { const { searchParams } = new URL(request.url); const url = searchParams.get("url");