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
import { requestViewer } from "@/server/auth";
import { recordExists } from "@/server/records";
import { body, handle } from "@/server/shorts-schemas";
import { planTurnaroundRun, previewTurnaround, TurnaroundBodySchema, turnaroundRun, turnaroundSteps } from "@/server/turnaround";
import { poolPricedCheck } from "@/server/tool-runs";
import { worldcastContextNow } from "@/server/worldcast-on";
/**
* A turnaround's price and plan, as the studio routes' estimates answer it (the evaluation harness prices a job here
* before running it): the model the film runs on, what it costs, whether it would be a demo, the notes.
*/
async function post(request: Request) {
return handle(async () => {
const input = await body(request, TurnaroundBodySchema, "Pick the engine and the character's pictures");
delete input.requestId;
// Characters are the owner's library: a visitor (public sign-up) is never told whether one exists.
if (input.elementId && (requestViewer(request).kind !== "owner" || !recordExists({ kind: "element", ids: [input.elementId] }))) {
return Response.json({ error: "Character not found" }, { status: 404 });
}
await worldcastContextNow();
const p = previewTurnaround(turnaroundRun(input));
return Response.json({ ...p, modelId: p.model.id, modelName: p.model.name });
});
}
/**
* Priced as the asker's run would go: an account's on its own GPU or key, a guest's on the open engine, never a demo;
* with its place, price and line on this install's GPUs when the run would go there (poolPricedCheck).
*/
export async function POST(request: Request) {
return poolPricedCheck(request, () => post(request), (raw) => {
const input = TurnaroundBodySchema.parse(raw);
delete input.requestId;
if (input.elementId) throw new Error("Character not found");
return turnaroundSteps(planTurnaroundRun(turnaroundRun(input)));
});
}