zen: fix models endpoint to be openai compatible

This commit is contained in:
Aiden Cline
2025-10-28 22:48:57 -05:00
parent 4994bf1b46
commit a0541ba57a

View File

@@ -25,8 +25,8 @@ export async function GET(input: APIEvent) {
object: "list", object: "list",
data: Object.entries(zenData.models) data: Object.entries(zenData.models)
.filter(([id]) => !disabledModels.includes(id)) .filter(([id]) => !disabledModels.includes(id))
.map(([id, model]) => ({ .map(([id, _model]) => ({
id: `opencode/${id}`, id,
object: "model", object: "model",
created: Math.floor(Date.now() / 1000), created: Math.floor(Date.now() / 1000),
owned_by: "opencode", owned_by: "opencode",
@@ -50,7 +50,10 @@ export async function GET(input: APIEvent) {
}) })
.from(KeyTable) .from(KeyTable)
.innerJoin(WorkspaceTable, eq(WorkspaceTable.id, KeyTable.workspaceID)) .innerJoin(WorkspaceTable, eq(WorkspaceTable.id, KeyTable.workspaceID))
.leftJoin(ModelTable, and(eq(ModelTable.workspaceID, KeyTable.workspaceID), isNull(ModelTable.timeDeleted))) .leftJoin(
ModelTable,
and(eq(ModelTable.workspaceID, KeyTable.workspaceID), isNull(ModelTable.timeDeleted)),
)
.where(and(eq(KeyTable.key, apiKey), isNull(KeyTable.timeDeleted))) .where(and(eq(KeyTable.key, apiKey), isNull(KeyTable.timeDeleted)))
.then((rows) => rows.map((row) => row.model)), .then((rows) => rows.map((row) => row.model)),
) )