Skip to content

Open source CapCut alternative.

TypeScript

feat(cut): caption AI in cloud mode on Gemini, prompts shared with the engine [rebuild]

David Lecd725d0abb50
diff --git a/site/src/cut/lib/backend/cloud.ts b/site/src/cut/lib/backend/cloud.ts
index d93352b6..d5f3989f 100644
--- a/site/src/cut/lib/backend/cloud.ts
+++ b/site/src/cut/lib/backend/cloud.ts
@@ -93,7 +93,7 @@ export const cloudBackend: CutBackend = {
importUrl: true, // executed by the render worker
liveMic: true, // hosted LLM STT (lib/cloudTranscribe.ts)
transcribe: true, // hosted LLM STT (lib/cloudTranscribe.ts)
- captionAi: false, // engine Claude-CLI one-shots; no hosted twin yet
+ captionAi: true, // hosted Gemini twin (server/cloud/captions.ts)
localCliChat: false, // by design: those are the user's local logins
revealInFinder: false,
watch: true, // browser seek + canvas contact sheets (lib/media.ts)
diff --git a/site/src/cut/server/ai/captionPrompts.ts b/site/src/cut/server/ai/captionPrompts.ts
new file mode 100644
index 00000000..d59804f0
--- /dev/null
+++ b/site/src/cut/server/ai/captionPrompts.ts
@@ -0,0 +1,78 @@
+// The caption-AI prompts, shared verbatim by both backends: the engine's
+// Claude one-shots (captions.ts, visualSubtitles.ts) and the hosted Gemini
+// twin (../cloud/captions.ts). Only the model differs between the two — the
+// asks must never drift apart.
+
+export interface CaptionInput {
+ start: number;
+ end: number;
+ text: string;
+}
+
+export const STYLE_GUIDE: Record<string, string> = {
+ clean: "Keep it clear and natural — a light polish, not a rewrite.",
+ hook: "Open with a strong curiosity gap that makes people need to keep watching; stay punchy throughout.",
+ punchy: "Bold, high-energy phrasing. Make the opening line especially loud and impossible to scroll past.",
+};
+
+/** Cues per model call. A long track runs as several small calls — each one
+ * finishes well inside the timeout, and a hiccup costs one batch, not the
+ * whole track. */
+export const BATCH_SIZE = 30;
+export const BATCH_CONCURRENCY = 3;
+export const BATCH_TIMEOUT_MS = 90_000;
+
+/** The locale tag as an English language name for the prompt ("es" → "Spanish");
+ * an unknown tag still reads fine raw. */
+export function languageName(locale: string): string {
+ try {
+ return new Intl.DisplayNames(["en"], { type: "language" }).of(locale) ?? locale;
+ } catch {
+ return locale;
+ }
+}
+
+export function rewritePrompt(cues: CaptionInput[], guide: string, isOpener: boolean): string {
+ const numbered = cues.map((c, i) => `${i + 1}. ${c.text}`).join("\n");
+ return `You rewrite spoken-word transcript lines into short-form social video captions (TikTok / Reels / Shorts).
+
+Rewrite EACH numbered line below. Rules:
+- Return EXACTLY ${cues.length} lines — one rewrite per input line, in the same order.
+- Preserve the meaning and point of each original line.
+- Keep each caption short so it fits inside the vertical video frame — about 3–8 words. It may wrap onto two lines, but must never be so long it would overflow the frame width.
+- Sprinkle a few relevant emoji across the whole set — not every line, never more than one per line.
+${isOpener ? "- Line 1 is the opener: make it a scroll-stopping hook.\n" : ""}- ${guide}
+
+Return ONLY a JSON array of ${cues.length} strings. No commentary, no code fence.
+
+Lines:
+${numbered}`;
+}
+
+export function translatePrompt(cues: CaptionInput[], language: string): string {
+ const numbered = cues.map((c, i) => `${i + 1}. ${c.text}`).join("\n");
+ return `You translate subtitle lines for a short-form social video.
+
+Translate EACH numbered line below into ${language}. Rules:
+- Return EXACTLY ${cues.length} lines — one translation per input line, in the same order.
+- Translate naturally, preserving the meaning and tone — not word-for-word.
+- Mirror the original's brevity: each caption must stay short enough to fit in a vertical video frame.
+- Keep emoji, proper names, and numbers as they are.
+
+Return ONLY a JSON array of ${cues.length} strings. No commentary, no code fence.
+
+Lines:
+${numbered}`;
+}
+
+export function visualSubtitlesPrompt(duration: number, locale?: string): string {
+ return `You caption silent short-form videos (TikTok / Reels / Shorts). Below are frames sampled from a ${duration.toFixed(1)}-second video, each labeled with its timeline time. Watch what happens across them and write narration captions that tell that story.
+
+Rules:
+- Return ONLY a JSON array: [{"start": seconds, "end": seconds, "text": "caption"}]. No commentary, no code fence.
+- Chronological, non-overlapping cues covering the video from 0 to ${duration.toFixed(1)}s.
+- Each cue runs 1.5–4 seconds; each text is 2–8 punchy words.
+- Narrate what is on screen — actions, changes, the point — not camera trivia.
+- Make the first cue a scroll-stopping hook.
+- Write in the language of locale "${locale ?? "en-US"}".`;
+}
diff --git a/site/src/cut/server/ai/captions.ts b/site/src/cut/server/ai/captions.ts
index 38108b5f..feb4bc5a 100644
--- a/site/src/cut/server/ai/captions.ts
+++ b/site/src/cut/server/ai/captions.ts
@@ -1,31 +1,25 @@
import os from "node:os";
import { query } from "@anthropic-ai/claude-agent-sdk";
+import {
+ BATCH_CONCURRENCY,
+ BATCH_SIZE,
+ BATCH_TIMEOUT_MS,
+ languageName,
+ rewritePrompt,
+ STYLE_GUIDE,
+ translatePrompt,
+ type CaptionInput,
+} from "./captionPrompts";
// Rewrite plain transcript cues into punchy social-video captions, one-to-one so
// the timings stay put. Runs through the user's own Claude login (no hosted
// models), like the rest of Cut's AI. Any failure falls back to the originals.
+// The prompts live in captionPrompts.ts, shared with the hosted Gemini twin.
-export interface CaptionInput {
- start: number;
- end: number;
- text: string;
-}
-
-const STYLE_GUIDE: Record<string, string> = {
- clean: "Keep it clear and natural — a light polish, not a rewrite.",
- hook: "Open with a strong curiosity gap that makes people need to keep watching; stay punchy throughout.",
- punchy: "Bold, high-energy phrasing. Make the opening line especially loud and impossible to scroll past.",
-};
+export type { CaptionInput };
const MODEL = "claude-haiku-4-5-20251001";
-/** Cues per model call. A long track runs as several small calls — each one
- * finishes well inside the timeout, and a hiccup costs one batch, not the
- * whole track. */
-const BATCH_SIZE = 30;
-const BATCH_CONCURRENCY = 3;
-const BATCH_TIMEOUT_MS = 90_000;
-
export async function rewriteCaptions(cues: CaptionInput[], style: string): Promise<string[]> {
const guide = STYLE_GUIDE[style] ?? STYLE_GUIDE.clean;
const batches = chunk(cues, BATCH_SIZE);
@@ -45,12 +39,7 @@ export async function rewriteCaptions(cues: CaptionInput[], style: string): Prom
* Each batch gets one retry first: timeouts and malformed replies are
* transient. */
export async function translateCaptions(cues: CaptionInput[], locale: string): Promise<string[]> {
- let language = locale;
- try {
- language = new Intl.DisplayNames(["en"], { type: "language" }).of(locale) ?? locale;
- } catch {
- /* unknown locale tag — the raw tag still reads fine in the prompt */
- }
+ const language = languageName(locale);
const batches = chunk(cues, BATCH_SIZE);
const texts = await mapLimit(batches, BATCH_CONCURRENCY, async (batch) => {
try {
@@ -62,39 +51,6 @@ export async function translateCaptions(cues: CaptionInput[], locale: string): P
return texts.flat().map((s, i) => (s && s.trim() ? s.trim() : cues[i].text));
}
-function rewritePrompt(cues: CaptionInput[], guide: string, isOpener: boolean): string {
- const numbered = cues.map((c, i) => `${i + 1}. ${c.text}`).join("\n");
- return `You rewrite spoken-word transcript lines into short-form social video captions (TikTok / Reels / Shorts).
-
-Rewrite EACH numbered line below. Rules:
-- Return EXACTLY ${cues.length} lines — one rewrite per input line, in the same order.
-- Preserve the meaning and point of each original line.
-- Keep each caption short so it fits inside the vertical video frame — about 3–8 words. It may wrap onto two lines, but must never be so long it would overflow the frame width.
-- Sprinkle a few relevant emoji across the whole set — not every line, never more than one per line.
-${isOpener ? "- Line 1 is the opener: make it a scroll-stopping hook.\n" : ""}- ${guide}
-
-Return ONLY a JSON array of ${cues.length} strings. No commentary, no code fence.
-
-Lines:
-${numbered}`;
-}
-
-function translatePrompt(cues: CaptionInput[], language: string): string {
- const numbered = cues.map((c, i) => `${i + 1}. ${c.text}`).join("\n");
- return `You translate subtitle lines for a short-form social video.
-
-Translate EACH numbered line below into ${language}. Rules:
-- Return EXACTLY ${cues.length} lines — one translation per input line, in the same order.
-- Translate naturally, preserving the meaning and tone — not word-for-word.
-- Mirror the original's brevity: each caption must stay short enough to fit in a vertical video frame.
-- Keep emoji, proper names, and numbers as they are.
-
-Return ONLY a JSON array of ${cues.length} strings. No commentary, no code fence.
-
-Lines:
-${numbered}`;
-}
-
/** One model call for one batch: raced against the timeout, parsed, and length
* checked. Throws on any shortfall so the caller decides between retry and
* fallback. */
diff --git a/site/src/cut/server/ai/visualSubtitles.ts b/site/src/cut/server/ai/visualSubtitles.ts
index 3374a520..59dfc44f 100644
--- a/site/src/cut/server/ai/visualSubtitles.ts
+++ b/site/src/cut/server/ai/visualSubtitles.ts
@@ -1,5 +1,6 @@
import os from "node:os";
import { query, type SDKUserMessage } from "@anthropic-ai/claude-agent-sdk";
+import { visualSubtitlesPrompt } from "./captionPrompts";
// Write subtitle cues for a cut with no usable audio: the client samples frames
// along the timeline, and the user's own Claude login (like the rest of Cut's
@@ -45,17 +46,9 @@ export async function writeVisualCues(
.filter((f): f is { at: number; block: ImageBlock } => f.block !== null);
if (usable.length === 0) throw new Error("No frames to caption.");
- const prompt = `You caption silent short-form videos (TikTok / Reels / Shorts). Below are frames sampled from a ${duration.toFixed(1)}-second video, each labeled with its timeline time. Watch what happens across them and write narration captions that tell that story.
-
-Rules:
-- Return ONLY a JSON array: [{"start": seconds, "end": seconds, "text": "caption"}]. No commentary, no code fence.
-- Chronological, non-overlapping cues covering the video from 0 to ${duration.toFixed(1)}s.
-- Each cue runs 1.5–4 seconds; each text is 2–8 punchy words.
-- Narrate what is on screen — actions, changes, the point — not camera trivia.
-- Make the first cue a scroll-stopping hook.
-- Write in the language of locale "${locale ?? "en-US"}".`;
-
- const content: ({ type: "text"; text: string } | ImageBlock)[] = [{ type: "text", text: prompt }];
+ const content: ({ type: "text"; text: string } | ImageBlock)[] = [
+ { type: "text", text: visualSubtitlesPrompt(duration, locale) },
+ ];
for (const f of usable) {
content.push({ type: "text", text: `Frame at ${f.at.toFixed(1)}s:` });
content.push(f.block);
diff --git a/site/src/cut/server/cloud/captions.ts b/site/src/cut/server/cloud/captions.ts
new file mode 100644
index 00000000..9cc7af26
--- /dev/null
+++ b/site/src/cut/server/cloud/captions.ts
@@ -0,0 +1,315 @@
+// Hosted caption AI: the cloud twin of the engine's Claude-CLI one-shots
+// (server/ai/captions.ts, visualSubtitles.ts), same JSON contracts, run on
+// Gemini and metered against the user's inference credits like transcribe.
+//
+// POST ai/captions {cues, style?, translateTo?} -> {texts}
+// POST ai/visual-subtitles {frames, duration, locale?} -> {cues}
+import {
+ creditErrorResponse,
+ recordFailedInferenceUsage,
+ recordInferenceUsage,
+ requireInferenceCredits,
+} from "@/lib/credits/inference";
+import {
+ defaultGeminiClientFactory,
+ geminiApiError,
+ geminiCandidateParts,
+ geminiCandidates,
+ geminiClientConfig,
+ stringValue,
+} from "@/lib/inference/adapters/gemini-client";
+import { geminiModelRoles } from "@/lib/inference/gemini-models";
+import { toJsonValue } from "@/lib/inference/json";
+import type { JsonValue } from "@/lib/inference/providers";
+import {
+ BATCH_CONCURRENCY,
+ BATCH_SIZE,
+ BATCH_TIMEOUT_MS,
+ languageName,
+ rewritePrompt,
+ STYLE_GUIDE,
+ translatePrompt,
+ visualSubtitlesPrompt,
+ type CaptionInput,
+} from "../ai/captionPrompts";
+import { err } from "./util";
+
+const PROVIDER = "gemini";
+const MODEL = geminiModelRoles.chat;
+
+const MAX_FRAMES = 24;
+const MAX_BODY_BYTES = 4 * 1024 * 1024; // stay inside the hosted body limit
+
+type GeminiPart = { text: string } | { inlineData: { mimeType: string; data: string } };
+
+/** A terminal Response decided mid-flight (credit exhaustion, provider error)
+ * that must reach the client as-is instead of a generic 500. */
+class RespondWith extends Error {
+ constructor(public readonly response: Response) {
+ super("handled");
+ }
+}
+
+/** One metered Gemini call: generate, record usage (success or failure), and
+ * return the concatenated text parts. */
+async function geminiOnce(
+ userId: string,
+ route: string,
+ requestKind: string,
+ parts: GeminiPart[]
+): Promise<string> {
+ const clientConfig = geminiClientConfig(process.env);
+ if (!clientConfig.configured) throw new Error("Captions are not configured on this deployment.");
+ let raw: unknown;
+ try {
+ const client = defaultGeminiClientFactory(clientConfig.options);
+ raw = await client.models.generateContent({
+ model: MODEL,
+ contents: [{ role: "user", parts }],
+ // JSON mode without a schema — constrained decoding degrades output.
+ config: { responseMimeType: "application/json" },
+ });
+ } catch (error) {
+ await recordFailedInferenceUsage({
+ clientId: null,
+ errorCode: "provider_error",
+ model: MODEL,
+ provider: PROVIDER,
+ requestKind,
+ route,
+ userId,
+ });
+ const credit = creditErrorResponse(error);
+ if (credit) throw new RespondWith(credit);
+ const mapped = geminiApiError("The caption model is unavailable.", error);
+ throw new RespondWith(err(mapped.message, mapped.statusCode ?? 502));
+ }
+ const usage = (raw as { usageMetadata?: unknown }).usageMetadata;
+ try {
+ await recordInferenceUsage({
+ clientId: null,
+ model: MODEL,
+ provider: PROVIDER,
+ requestKind,
+ route,
+ status: "succeeded",
+ usage: toJsonValue(usage ?? null),
+ userId,
+ });
+ } catch (error) {
+ const credit = creditErrorResponse(error);
+ if (credit) throw new RespondWith(credit);
+ throw error;
+ }
+ return geminiCandidateParts(geminiCandidates(raw as JsonValue)[0])
+ .map((p) => stringValue(p.text) ?? "")
+ .join("");
+}
+
+function parseJsonPayload(raw: string): unknown {
+ const cleaned = raw
+ .trim()
+ .replace(/^```(?:json)?\s*/i, "")
+ .replace(/```\s*$/, "")
+ .trim();
+ try {
+ return JSON.parse(cleaned);
+ } catch {
+ const s = cleaned.indexOf("[");
+ const e = cleaned.lastIndexOf("]");
+ if (s < 0 || e <= s) return null;
+ try {
+ return JSON.parse(cleaned.slice(s, e + 1));
+ } catch {
+ return null;
+ }
+ }
+}
+
+function parseStringArray(raw: string, expected: number): string[] | null {
+ const v = parseJsonPayload(raw);
+ if (!Array.isArray(v) || v.length !== expected) return null;
+ return v.map((x) => String(x));
+}
+
+function chunk<T>(items: T[], size: number): T[][] {
+ const out: T[][] = [];
+ for (let i = 0; i < items.length; i += size) out.push(items.slice(i, i + size));
+ return out;
+}
+
+async function mapLimit<T, R>(
+ items: T[],
+ limit: number,
+ fn: (item: T, index: number) => Promise<R>
+): Promise<R[]> {
+ const out = new Array<R>(items.length);
+ let next = 0;
+ await Promise.all(
+ Array.from({ length: Math.min(limit, items.length) }, async () => {
+ while (next < items.length) {
+ const i = next++;
+ out[i] = await fn(items[i], i);
+ }
+ })
+ );
+ return out;
+}
+
+function timeout(ms: number): Promise<never> {
+ return new Promise((_resolve, reject) => {
+ setTimeout(() => reject(new Error("timeout")), ms);
+ });
+}
+
+export const captionsCloud = {
+ /** Style rewrite or translation, one-to-one with the input cues. A failed
+ * rewrite batch falls back to its originals; a failed translation batch gets
+ * one retry, then the whole request errors — silently keeping the source
+ * language would fill the track with wrong text. */
+ async captions(userId: string, req: Request): Promise<Response> {
+ const route = "/api/cut-cloud/ai/captions/";
+ let cues: CaptionInput[] = [];
+ let style = "clean";
+ let translateTo = "";
+ try {
+ const body = (await req.json()) as {
+ cues?: CaptionInput[];
+ style?: string;
+ translateTo?: string;
+ };
+ cues = Array.isArray(body.cues)
+ ? body.cues.filter((c) => c && typeof c.text === "string")
+ : [];
+ if (typeof body.style === "string") style = body.style;
+ if (typeof body.translateTo === "string") translateTo = body.translateTo;
+ } catch {
+ return err("Send JSON with cues.", 400);
+ }
+ if (cues.length === 0) return err("No cues to rewrite.", 400);
+
+ const credits = await requireInferenceCredits({
+ enforceModelPrice: true,
+ model: MODEL,
+ provider: PROVIDER,
+ route,
+ userId,
+ });
+ if (!credits.ok) return credits.response;
+
+ const translating = translateTo.length > 0;
+ const language = languageName(translateTo);
+ const guide = STYLE_GUIDE[style] ?? STYLE_GUIDE.clean;
+
+ try {
+ const batches = chunk(cues, BATCH_SIZE);
+ // Same shape as the engine: concurrency-limited batches, each raced
+ // against the timeout; a failed rewrite batch falls back to its
+ // originals, a failed translation batch gets one retry then errors.
+ // Credit-exhaustion and provider rejections (RespondWith) always abort —
+ // silently swallowing those would hide a real, actionable failure.
+ const texts = await mapLimit(batches, BATCH_CONCURRENCY, async (batch, index) => {
+ const prompt = translating
+ ? translatePrompt(batch, language)
+ : rewritePrompt(batch, guide, index === 0);
+ const run = async () => {
+ const raw = await Promise.race([
+ geminiOnce(userId, route, "captions", [{ text: prompt }]),
+ timeout(BATCH_TIMEOUT_MS),
+ ]);
+ const arr = parseStringArray(raw, batch.length);
+ if (!arr) throw new Error("The reply came back malformed.");
+ return arr;
+ };
+ try {
+ return await run();
+ } catch (e) {
+ if (e instanceof RespondWith) throw e;
+ if (!translating) return batch.map((c) => c.text);
+ return await run(); // one retry — timeouts and malformed replies are transient
+ }
+ });
+ const flat = texts.flat().map((s, i) => (s && s.trim() ? s.trim() : cues[i].text));
+ return Response.json({ texts: flat });
+ } catch (e) {
+ if (e instanceof RespondWith) return e.response;
+ return err(e instanceof Error ? e.message : "Could not write captions.", 500);
+ }
+ },
+
+ /** Subtitle cues written from sampled frames — for cuts with no usable
+ * audio. Frames arrive as data-URL jpegs from the client's canvas. */
+ async visualSubtitles(userId: string, req: Request): Promise<Response> {
+ const route = "/api/cut-cloud/ai/visual-subtitles/";
+ let frames: { at: number; image: string }[] = [];
+ let duration = 0;
+ let locale = "en-US";
+ try {
+ const text = await req.text();
+ if (text.length > MAX_BODY_BYTES) return err("Too many frames.", 413);
+ const body = JSON.parse(text) as {
+ frames?: { at?: number; image?: string }[];
+ duration?: number;
+ locale?: string;
+ };
+ frames = Array.isArray(body.frames)
+ ? body.frames.filter(
+ (f): f is { at: number; image: string } =>
+ !!f && typeof f.at === "number" && typeof f.image === "string"
+ )
+ : [];
+ duration = typeof body.duration === "number" ? body.duration : 0;
+ if (typeof body.locale === "string" && body.locale) locale = body.locale;
+ } catch {
+ return err("Send JSON with frames and duration.", 400);
+ }
+ if (frames.length === 0 || duration <= 0) return err("frames and duration are required.", 400);
+
+ const parts: GeminiPart[] = [];
+ for (const f of frames.slice(0, MAX_FRAMES)) {
+ const m = /^data:(image\/(?:jpeg|png|webp));base64,([A-Za-z0-9+/=]+)$/.exec(f.image);
+ if (!m) continue;
+ parts.push({ text: `Frame at ${Math.max(0, f.at).toFixed(1)}s:` });
+ parts.push({ inlineData: { mimeType: m[1], data: m[2] } });
+ }
+ if (parts.length === 0) return err("No frames to caption.", 400);
+ parts.unshift({ text: visualSubtitlesPrompt(duration, locale) });
+
+ const credits = await requireInferenceCredits({
+ enforceModelPrice: true,
+ model: MODEL,
+ provider: PROVIDER,
+ route,
+ userId,
+ });
+ if (!credits.ok) return credits.response;
+
+ try {
+ const raw = await geminiOnce(userId, route, "visual_subtitles", parts);
+ const parsed = parseJsonPayload(raw);
+ if (!Array.isArray(parsed)) {
+ return err("The caption model returned an unreadable response — try again.", 502);
+ }
+ const cues = parsed
+ .filter(
+ (c): c is { start: number; end: number; text: string } =>
+ !!c &&
+ typeof c === "object" &&
+ typeof (c as { start?: unknown }).start === "number" &&
+ typeof (c as { end?: unknown }).end === "number" &&
+ typeof (c as { text?: unknown }).text === "string"
+ )
+ .map((c) => ({
+ start: Math.max(0, Math.min(c.start, duration)),
+ end: Math.max(0, Math.min(c.end, duration)),
+ text: c.text.trim(),
+ }))
+ .filter((c) => c.text && c.end > c.start)
+ .sort((a, b) => a.start - b.start);
+ return Response.json({ cues });
+ } catch (e) {
+ if (e instanceof RespondWith) return e.response;
+ return err(e instanceof Error ? e.message : "Could not caption the visuals.", 500);
+ }
+ },
+};
diff --git a/site/src/cut/server/cloud/routes.ts b/site/src/cut/server/cloud/routes.ts
index b0633865..aacf3f0c 100644
--- a/site/src/cut/server/cloud/routes.ts
+++ b/site/src/cut/server/cloud/routes.ts
@@ -6,6 +6,7 @@
// every query by it.
import { type DonkeyAuthenticatedRequest, isDonkeySuperUser } from "@/lib/donkey-api-auth";
import { matchRouteTable, type RouteEntry } from "../http/match";
+import { captionsCloud } from "./captions";
import { runGc } from "./gc";
import { jobsCloud } from "./jobs";
import { libraryCloud } from "./library";
@@ -37,7 +38,7 @@ const CUT_CLOUD_ROUTES: CloudRoute[] = [
{ method: "DELETE", path: "/api/cut-cloud/projects/:id", handler: (_r, u, p) => projectsCloud.remove(u, p.id) },
{ method: "POST", path: "/api/cut-cloud/projects/:id/duplicate", handler: (_r, u, p) => projectsCloud.duplicate(u, p.id) },
{ method: "GET", path: "/api/cut-cloud/projects/:id/exports", handler: (_r, u, p) => projectsCloud.listExports(u, p.id) },
- { method: "GET", path: "/api/cut-cloud/projects/:id/exports/:file", handler: (_r, u, p) => projectsCloud.serveExport(u, p.id, p.file) },
+ { method: "GET", path: "/api/cut-cloud/projects/:id/exports/:file", handler: (r, u, p) => projectsCloud.serveExport(u, p.id, p.file, new URL(r.url).searchParams.has("download")) },
{ method: "DELETE", path: "/api/cut-cloud/projects/:id/exports/:file", handler: (_r, u, p) => projectsCloud.removeExport(u, p.id, p.file) },
{ method: "GET", path: "/api/cut-cloud/projects/:id/media/:file", handler: (_r, u, p) => projectsCloud.serveMedia(u, p.id, p.file) },
{ method: "DELETE", path: "/api/cut-cloud/projects/:id/media/:file", handler: (_r, u, p) => projectsCloud.removeMedia(u, p.id, p.file) },
@@ -74,6 +75,8 @@ const CUT_CLOUD_ROUTES: CloudRoute[] = [
{ method: "GET", path: "/api/cut-cloud/jobs/:jobId", handler: (_r, u, p) => jobsCloud.status(u, p.jobId) },
{ method: "POST", path: "/api/cut-cloud/transcribe", handler: (r, u) => transcribeCloud.transcribe(u, r) },
+ { method: "POST", path: "/api/cut-cloud/ai/captions", handler: (r, u) => captionsCloud.captions(u, r) },
+ { method: "POST", path: "/api/cut-cloud/ai/visual-subtitles", handler: (r, u) => captionsCloud.visualSubtitles(u, r) },
{ method: "GET", path: "/api/cut-cloud/usage", handler: (_r, u) => usageApi.get(u) },
// GC also runs unauthenticated from the Vercel cron — see the catch-all