The open creative studio on ComfyUI: images, video, 3D and audio on open weights, on your own GPU or the cloud. Camera motions, effects, apps, Cinema, Layers, Image to 3D and an AI agent.
TypeScript ai-videocomfyuicreative-toolsgenerative-aiideogramimage-generationimage-to-3dimage-to-videoltx-videominimax-h3nextjsopen-sourceopen-weightsqwen-imagetext-to-imagevideo-generationwan
API: GET /api/models says how each model runs today and which ones clone a voice
Claude804fc374c468
diff --git a/src/app/api/models/route.ts b/src/app/api/models/route.tsindex 87436e04..365965ac 100644--- a/src/app/api/models/route.ts+++ b/src/app/api/models/route.ts@@ -1,20 +1,51 @@import { connection } from "next/server";-import { MODELS } from "@/lib/catalog";+import { getModel, MODELS } from "@/lib/catalog";+import { ENGINE_MODELS } from "@/lib/catalog/faceless";import { OPERATION_LABELS, type Engine, type MediaKind, type ModelDef, type Operation } from "@/lib/catalog/types";import { findModels, MODEL_KINDS, toModelInfo } from "@/lib/model-list";-import { AUDIO_STUDIO, EDIT_STUDIO, IMAGE_STUDIO, VIDEO_STUDIO } from "@/lib/studios";+import { AUDIO_STUDIO, DIALOGUE_STUDIO, EDIT_STUDIO, IMAGE_STUDIO, VIDEO_STUDIO } from "@/lib/studios";import { provider } from "@/server/providers";import { llmBackends } from "@/server/providers/llm";-import { engineMode } from "@/server/settings";+import { engineMode, getSetting } from "@/server/settings";-/** A provider for one of its routes is set up (else it runs as a demo). */+/** A provider for one of its routes is set up. */const connected = (m: ModelDef) => m.routes.some((r) => (r.provider === "llm" ? llmBackends(r).length > 0 : provider(r.provider).isConfigured()));+/**+ * How a run of the model goes today, the way chooseRoute decides: "real" on its provider, "demo"+ * (placeholder media, free: Demo mode on, or auto with no provider set up) or "refused" (Demo mode+ * off and no provider: the run fails with "Connect … in Settings").+ */+function runsAs(m: ModelDef, demoMode: string): "real" | "demo" | "refused" {+ if (demoMode === "on") return "demo";+ if (connected(m)) return "real";+ return demoMode === "off" ? "refused" : "demo";+}++/** Per engine, the ids that clone voices (a dialogue studio's cloud default uses premade voices only). */+const cloning = (ids: { cloud?: string; open?: string }) => Object.fromEntries(Object.entries(ids).filter(([, id]) => id && getModel(id)?.options.voiceClone));++/**+ * The studios' own picks per engine: image, edit (images attached), video, audio (text to speech),+ * dialogue, clone (text to speech in the voice of a sample) and cloneDialogue (two speakers, each+ * cloned from a sample).+ */+const DEFAULTS: Record<string, { cloud?: string; open?: string }> = {+ image: IMAGE_STUDIO.defaultModels,+ edit: EDIT_STUDIO.defaultModels,+ video: VIDEO_STUDIO.defaultModels,+ audio: AUDIO_STUDIO.defaultModels,+ dialogue: DIALOGUE_STUDIO.defaultModels,+ clone: cloning({ cloud: ENGINE_MODELS.cloud.cloneNarration, open: ENGINE_MODELS.open.cloneNarration }),+ cloneDialogue: cloning(DIALOGUE_STUDIO.defaultModels),+};+/*** Models this install can run, for scripts and the `fuobe` CLI. Filters: kind, engine (open |* cloud), op, q (words that must all match), hidden=1 (chain helpers too). Models of an engine the* install has switched off (Settings → Engine mode) are left out. `defaults` are the studios' own- * picks (image, edit, video, audio) per engine.+ * picks per engine (DEFAULTS); each item says whether its provider is `connected` and how a run+ * goes today (`runs`, which follows Settings → Demo mode).*/export async function GET(request: Request) {await connection();@@ -30,10 +61,8 @@ export async function GET(request: Request) {(m) => mode === "both" || m.engine === mode,);const defaults = Object.fromEntries(- Object.entries({ image: IMAGE_STUDIO, edit: EDIT_STUDIO, video: VIDEO_STUDIO, audio: AUDIO_STUDIO }).map(([k, s]) => [- k,- { ...(mode !== "open" && s.defaultModels.cloud && { cloud: s.defaultModels.cloud }), ...(mode !== "cloud" && s.defaultModels.open && { open: s.defaultModels.open }) },- ]),+ Object.entries(DEFAULTS).map(([k, ids]) => [k, { ...(mode !== "open" && ids.cloud && { cloud: ids.cloud }), ...(mode !== "cloud" && ids.open && { open: ids.open }) }]),);- return Response.json({ engineMode: mode, defaults, items: list.map((m) => ({ ...toModelInfo(m), connected: connected(m) })) });+ const demoMode = getSetting("demoMode");+ return Response.json({ engineMode: mode, demoMode, defaults, items: list.map((m) => ({ ...toModelInfo(m), connected: connected(m), runs: runsAs(m, demoMode) })) });}diff --git a/src/lib/model-list.ts b/src/lib/model-list.tsindex 22b0481e..a7663275 100644--- a/src/lib/model-list.ts+++ b/src/lib/model-list.ts@@ -23,6 +23,8 @@ export interface ModelInfo extends ModelRow {endFrame?: boolean;/** Premade voice ids (text to speech, voice change). */voices?: string[];+ /** Takes a voice sample (`inputs.voiceAudio`) and speaks or changes into that voice. */+ voiceClone?: true;/** Not offered by any studio picker (chain helpers); runs when asked for by id. */hidden?: true;}@@ -40,6 +42,7 @@ export function toModelInfo(m: ModelDef): ModelInfo {...(o.audio && { audio: o.audio }),...(o.endFrame && { endFrame: true }),...(o.voices?.length && { voices: o.voices.map((v) => v.id) }),+ ...(o.voiceClone && { voiceClone: true as const }),...(m.hidden && { hidden: true as const }),};}diff --git a/tests/cli-api.test.ts b/tests/cli-api.test.tsindex ec47deae..59d781c8 100644--- a/tests/cli-api.test.ts+++ b/tests/cli-api.test.ts@@ -20,7 +20,13 @@ const { listGenerations } = await import("@/server/generations");const { setSetting } = await import("@/server/settings");afterAll(() => fs.rmSync(dir, { recursive: true, force: true }));-type ModelsBody = { engineMode: string; defaults: Record<string, { cloud?: string; open?: string }>; items: (ReturnType<typeof toModelInfo> & { connected: boolean })[]; error?: string };+type ModelsBody = {+ engineMode: string;+ demoMode: string;+ defaults: Record<string, { cloud?: string; open?: string }>;+ items: (ReturnType<typeof toModelInfo> & { connected: boolean; runs: "real" | "demo" | "refused" })[];+ error?: string;+};const models = async (query = "") => {const res = await listModels(new Request(`http://localhost/api/models${query}`));return { status: res.status, body: (await res.json()) as ModelsBody };@@ -68,6 +74,43 @@ describe("GET /api/models", () => {}});+ it("names the models that clone a voice sample, alone and as a dialogue's two speakers", async () => {+ const { defaults, items } = (await models("?kind=audio")).body;+ expect(defaults).toMatchObject({+ audio: { cloud: "elevenlabs-v4", open: "oss-chatterbox" },+ dialogue: { cloud: "elevenlabs-dialogue", open: "oss-chatterbox-dialogue" },+ clone: { cloud: "chatterbox-cloud", open: "oss-chatterbox" },+ });+ // ElevenLabs' dialogue speaks in premade voices only: no cloud model clones two speakers.+ expect(defaults.cloneDialogue).toEqual({ open: "oss-chatterbox-dialogue" });+ const byId = new Map(items.map((m) => [m.id, m]));+ expect(byId.get("chatterbox-cloud")?.voiceClone).toBe(true);+ expect(byId.get("oss-chatterbox-dialogue")?.voiceClone).toBe(true);+ expect(byId.get("elevenlabs-v4")).not.toHaveProperty("voiceClone");+ });++ it("says how a run goes today, following Settings → Demo mode the way routing does", async () => {+ const runs = async () => {+ const { body } = await models("?q=nano-banana-pro");+ const m = body.items.find((x) => x.id === "nano-banana-pro")!;+ return { demoMode: body.demoMode, connected: m.connected, runs: m.runs };+ };+ // auto, no key: a free demo.+ expect(await runs()).toEqual({ demoMode: "auto", connected: false, runs: "demo" });+ try {+ setSetting("demoMode", "off");+ expect(await runs()).toEqual({ demoMode: "off", connected: false, runs: "refused" });+ setSetting("falKey", "fal-test-key");+ expect(await runs()).toEqual({ demoMode: "off", connected: true, runs: "real" });+ // Demo mode on sends every run to the demo provider, key or not.+ setSetting("demoMode", "on");+ expect(await runs()).toEqual({ demoMode: "on", connected: true, runs: "demo" });+ } finally {+ setSetting("falKey", "");+ setSetting("demoMode", "auto");+ }+ });+it("refuses unknown filters with a sentence", async () => {expect(await models("?kind=smell")).toMatchObject({ status: 400, body: { error: "kind is one of image, video, audio, text, model3d" } });expect((await models("?engine=gpu")).status).toBe(400);