Unrestricted Open-source alternative to AI video platforms — Free AI image & video generation studio with 600+ models (Flux, Midjourney, Kling, Sora, Veo). No content filters. Self-hosted, MIT licensed.
JavaScript ai-art-generatorai-image-generationai-video-generationfal-ai-alternativegenerative-aiimage-to-videoinvideo-alternativekling-ailipsynclitellm-alternativemidjourney-alternativemuapiopen-sourceopenrouter-alternativeseedance2sora-alternativetext-to-imagetext-to-videouncensoredwan-video
feat(studio): simplify Kling selection and fix video restoration
antilya7b499bc0f238
diff --git a/packages/studio/src/components/VideoModelControls.jsx b/packages/studio/src/components/VideoModelControls.jsxindex f681490c..e3485677 100644--- a/packages/studio/src/components/VideoModelControls.jsx+++ b/packages/studio/src/components/VideoModelControls.jsx@@ -148,6 +148,19 @@ export function VideoSettingsControl({</label>);};+ const profileControl = profile?.options.length > 1 && (+ <fieldset className="min-w-0">+ <legend className="text-xs font-semibold text-white/75">{copy.provider}</legend>+ {copy.providerHelp && <p className="mb-2 mt-1 text-[11px] leading-relaxed text-white/45">{copy.providerHelp}</p>}+ {profile.options.map(renderProfile)}+ {onDefaultResolution && (+ <button type="button" onClick={onDefaultResolution}+ className="mt-2 px-3 py-2 text-xs text-[#22d3ee] hover:underline focus-visible:outline focus-visible:outline-1 focus-visible:outline-[#22d3ee]">+ {copy.restoreDefaultResolution}+ </button>+ )}+ </fieldset>+ );return (<ModelParameterControlsinputs={inputs}@@ -162,20 +175,9 @@ export function VideoSettingsControl({solidadvancedKeys={ADVANCED_KEYS}advancedLabel={copy.advanced}- advancedChildren={profile?.options.length > 1 && (- <fieldset className="min-w-0">- <legend className="text-xs font-semibold text-white/75">{copy.provider}</legend>- <p className="mb-2 mt-1 text-[11px] leading-relaxed text-white/45">{copy.providerHelp}</p>- {profile.options.map(renderProfile)}- {onDefaultResolution && (- <button type="button" onClick={onDefaultResolution}- className="mt-2 px-3 py-2 text-xs text-[#22d3ee] hover:underline focus-visible:outline focus-visible:outline-1 focus-visible:outline-[#22d3ee]">- {copy.restoreDefaultResolution}- </button>- )}- </fieldset>- )}+ advancedChildren={profile?.advanced !== false && profileControl}>+ {profile?.advanced === false && profileControl}{qualities.length > 0 && (<label className="flex flex-col gap-2 text-xs text-white/75"><span className="font-semibold">{copy.quality}</span>diff --git a/packages/studio/src/components/VideoStudio.jsx b/packages/studio/src/components/VideoStudio.jsxindex 498e490f..7aa0821d 100644--- a/packages/studio/src/components/VideoStudio.jsx+++ b/packages/studio/src/components/VideoStudio.jsx@@ -53,6 +53,7 @@ import {buildSupplementalInputPayload,createModelParameterValues,getSupplementalModelInputs,+ mergeModelParameterValues,} from "../modelParameters.js";import { getCompatibleContinuationSources, getContinuationConfig, isContinuationSourceModel } from "../videoToolCapabilities.js";import {@@ -64,6 +65,7 @@ import {getVideoWorkflowFamily,getVideoWorkflowMediaConfig,getVideoWorkflowMediaSlots,+ migrateVideoWorkflowMediaDrafts,getVideoWorkflowSlotRemaining,inferVideoWorkflowId,legacyVideoMediaToWorkflowDraft,@@ -1066,6 +1068,21 @@ export default function VideoStudio({? getVideoWorkflowDraftKey(selectedFamilyId, selectedWorkflowId): null;const selectedVariant = videoModelCatalog.variantById.get(selectedModel);+ const activeWorkflowMediaDraft = useMemo(+ () => workflowMediaDraftKey+ ? projectVideoWorkflowMedia(+ selectedVariant?.model,+ selectedWorkflowId,+ workflowMediaDrafts[workflowMediaDraftKey] || EMPTY_WORKFLOW_MEDIA_DRAFT,+ )+ : null,+ [+ selectedVariant,+ selectedWorkflowId,+ workflowMediaDraftKey,+ workflowMediaDrafts,+ ],+ );const selectedPickerEntry = videoModelPickerEntryByVariantId.get(selectedModel);const selectedTool = getSeedanceToolConfiguration(selectedModel);const selectedVeoTool = getVeoToolConfiguration(selectedModel);@@ -1081,14 +1098,16 @@ export default function VideoStudio({const getSelectionPlan = useCallback((options = {}) => planGroupedVideoSelection({familyId: selectedFamilyId,workflowId: selectedWorkflowId,+ currentWorkflowId: selectedWorkflowId,+ media: activeWorkflowMediaDraft,currentModelId: selectedModel,nativeResolution: selectedResolution,commonValues: {aspectRatio: selectedAr, duration: selectedDuration,- resolution: selectedResolution, quality: selectedQuality,+ quality: selectedQuality,},...options,- }), [selectedFamilyId, selectedWorkflowId, selectedModel, selectedResolution, selectedAr, selectedDuration, selectedQuality]);+ }), [selectedFamilyId, selectedWorkflowId, selectedModel, selectedResolution, selectedAr, selectedDuration, selectedQuality, activeWorkflowMediaDraft]);const describeSelectionAdjustments = useCallback((adjustments) => {const valueLabel = (key, value) => {if (key === "duration") return getVideoDurationLabel(value, groupCopy);@@ -1131,13 +1150,14 @@ export default function VideoStudio({options: field.options.map((option) => {const adjustments = option.disabled ? [] : getGroupedVideoSelectionAdjustments({currentModelId: selectedModel, nativeResolution: selectedResolution,+ currentWorkflowId: selectedWorkflowId, media: activeWorkflowMediaDraft,commonValues: { aspectRatio: selectedAr, duration: selectedDuration, quality: selectedQuality },selection: option, changes: { resolution: option.value },});return { ...option, adjustmentDescription: describeSelectionAdjustments(adjustments) };}),};- }, [groupedConfiguration, selectedFamilyId, selectedWorkflowId, selectedModel, selectedResolution, selectedAr, selectedDuration, selectedQuality, describeSelectionAdjustments, groupCopy, groupCopyKey]);+ }, [groupedConfiguration, selectedFamilyId, selectedWorkflowId, selectedModel, selectedResolution, selectedAr, selectedDuration, selectedQuality, describeSelectionAdjustments, groupCopy, groupCopyKey, activeWorkflowMediaDraft]);const commonOptions = useMemo(() => getVideoCommonOptions(selectedVariant?.model), [selectedVariant],);@@ -1156,21 +1176,6 @@ export default function VideoStudio({};}): [], [groupedConfiguration, workflowFamily, getSelectionPlan, describeSelectionAdjustments, groupCopy]);- const activeWorkflowMediaDraft = useMemo(- () => workflowMediaDraftKey- ? projectVideoWorkflowMedia(- selectedVariant?.model,- selectedWorkflowId,- workflowMediaDrafts[workflowMediaDraftKey] || EMPTY_WORKFLOW_MEDIA_DRAFT,- )- : null,- [- selectedVariant,- selectedWorkflowId,- workflowMediaDraftKey,- workflowMediaDrafts,- ],- );const promptDisabled = Boolean(selectedVeoTool && !selectedVariant?.model.inputs?.prompt) || shouldDisableVideoPrompt(selectedVariant?.model,currentFamilyMode,@@ -1228,7 +1233,7 @@ export default function VideoStudio({setSelectedModel(model.id);setSelectedWorkflowId(workflowId);setModelParameterValues((values) =>- createModelParameterValues(model, values),+ mergeModelParameterValues(model, values),);setV2vMode(nextV2VMode);setImageMode(nextImageMode);@@ -1282,11 +1287,12 @@ export default function VideoStudio({let restoredWorkflowId = null;let restoredModel = defaultModel;let restoredFamilyId = defaultFamily.id;+ let restoredResolution = data.selectedResolution;if (data.selectedModel) {const restored = resolvePersistedVideoWorkflowSelection(migrateSeedanceResolutionSelection(data.selectedModel, data.selectedResolution),data.selectedWorkflowId || null,- { hasEndFrame: Boolean(data.uploadedEndImageUrl) },+ { hasEndFrame: Boolean(data.uploadedEndImageUrl || data.uploadedImageUrls?.[1]) },);if (restored.family && restored.variant) {restoredModelId = restored.variant.model.id;@@ -1294,12 +1300,19 @@ export default function VideoStudio({restoredWorkflowId = restored.workflowId;restoredModel = restored.variant.model;restoredFamilyId = restored.family.id;+ const resolutionField = getGroupedVideoResolutionOptions(+ restoredFamilyId, restoredWorkflowId, restoredModelId, restoredResolution,+ );+ // Restore the exact endpoint while respecting the workflow's allowed resolutions.+ restoredResolution = resolutionField.options.find((option) =>+ option.modelId === restoredModelId && option.value === resolutionField.value,+ )?.resolution ?? restoredResolution;setSelectedModel(restoredModelId);setSelectedFamilyId(restored.family.id);setSelectedWorkflowId(restored.workflowId);setModelParameterValues(- createModelParameterValues(- restored.variant.model,+ mergeModelParameterValues(+ restoredModel,data.modelParameterValues || {},),);@@ -1309,9 +1322,10 @@ export default function VideoStudio({setV2vMode(restoredMode === "v2v");if (data.selectedAr) setSelectedAr(data.selectedAr);if (data.selectedDuration) setSelectedDuration(data.selectedDuration);- if (data.selectedResolution) setSelectedResolution(data.selectedResolution);+ if (restoredResolution) setSelectedResolution(restoredResolution);if (data.selectedQuality) setSelectedQuality(data.selectedQuality);if (data.selectedEffect) setSelectedEffect(data.selectedEffect);+ if (data.selectedVeoSourceId) setSelectedVeoSourceId(data.selectedVeoSourceId);if (data.uploadedImageUrls) {setUploadedImageUrls(data.uploadedImageUrls);} else if (data.uploadedImageUrl) {@@ -1326,21 +1340,22 @@ export default function VideoStudio({if (data.uploadedAudioUrls) setUploadedAudioUrls(data.uploadedAudioUrls);const persistedDrafts =data.workflowMediaDrafts && typeof data.workflowMediaDrafts === "object"- ? { ...data.workflowMediaDrafts }+ ? migrateVideoWorkflowMediaDrafts(data.workflowMediaDrafts): {};if (restoredWorkflowId) {const draftKey = getVideoWorkflowDraftKey(restoredFamilyId,restoredWorkflowId,);- if (!persistedDrafts[draftKey]) {+ if (!data.selectedWorkflowId || !persistedDrafts[draftKey]) {persistedDrafts[draftKey] = legacyVideoMediaToWorkflowDraft(restoredModel,restoredWorkflowId,{imageUrls: data.uploadedImageUrls ||(data.uploadedImageUrl ? [data.uploadedImageUrl] : []),- endImageUrl: data.uploadedEndImageUrl || null,+ endImageUrl: data.uploadedEndImageUrl ||+ (restoredWorkflowId === "keyframes" ? data.uploadedImageUrls?.[1] : null),videoUrls: data.uploadedVideoUrls ||(data.uploadedVideoUrl ? [data.uploadedVideoUrl] : []),audioUrls: data.uploadedAudioUrls || [],@@ -1356,7 +1371,7 @@ export default function VideoStudio({commonParameterValuesRef.current = {aspectRatio: data.selectedAr,duration: data.selectedDuration,- resolution: data.selectedResolution,+ resolution: restoredResolution,quality: data.selectedQuality,};applyControlsForModel(@@ -1387,6 +1402,7 @@ export default function VideoStudio({selectedResolution,selectedQuality,selectedEffect,+ selectedVeoSourceId,modelParameterValues,uploadedImageUrls,uploadedEndImageUrl,@@ -1413,6 +1429,7 @@ export default function VideoStudio({selectedResolution,selectedQuality,selectedEffect,+ selectedVeoSourceId,modelParameterValues,uploadedImageUrls,uploadedEndImageUrl,@@ -2021,6 +2038,8 @@ export default function VideoStudio({if (option.disabled) return;const adjustments = getGroupedVideoSelectionAdjustments({currentModelId: selectedModel,+ currentWorkflowId: selectedWorkflowId,+ media: activeWorkflowMediaDraft,nativeResolution: selectedResolution,commonValues: commonParameterValuesRef.current,selection: option,@@ -2028,7 +2047,7 @@ export default function VideoStudio({});handleGroupedSelection({ selection: option, adjustments }, selectedFamily, selectedWorkflowId);setOpenDropdown(null);- }, [handleGroupedSelection, selectedFamily, selectedWorkflowId, selectedModel, selectedResolution]);+ }, [handleGroupedSelection, selectedFamily, selectedWorkflowId, selectedModel, selectedResolution, activeWorkflowMediaDraft]);// ── add to local history ──────────────────────────────────────────────────const addToLocalHistory = useCallback((entry) => {@@ -2051,9 +2070,10 @@ export default function VideoStudio({}const currentModel = getCurrentModel();const grouped = getGroupedVideoConfiguration(selectedModel);+ const activeParameterValues = createModelParameterValues(currentModel, modelParameterValues);const generationParameterValues = grouped && currentModel.inputs?.omni_reference_task_type- ? { ...modelParameterValues, omni_reference_task_type: "auto" }- : modelParameterValues;+ ? { ...activeParameterValues, omni_reference_task_type: "auto" }+ : activeParameterValues;const commonParams = grouped? buildVideoCommonPayload(currentModel, {aspectRatio: selectedAr, duration: selectedDuration,diff --git a/packages/studio/src/components/prompt/PromptComposer.jsx b/packages/studio/src/components/prompt/PromptComposer.jsxindex 9fa2f649..3f36df2b 100644--- a/packages/studio/src/components/prompt/PromptComposer.jsx+++ b/packages/studio/src/components/prompt/PromptComposer.jsx@@ -179,13 +179,35 @@ export const PromptPopover = forwardRef(function PromptPopover(const position = () => {const popover = popoverRef.current;popover.style.translate = "";+ popover.style.height = "";+ let left = 16;+ let right = window.innerWidth - 16;+ let top = 16;+ for (let parent = popover.parentElement; parent; parent = parent.parentElement) {+ const style = getComputedStyle(parent);+ const clipsX = /auto|scroll|hidden|clip/.test(style.overflowX);+ const clipsY = /auto|scroll|hidden|clip/.test(style.overflowY);+ if (!clipsX && !clipsY) continue;+ const bounds = parent.getBoundingClientRect();+ if (clipsX) {+ left = Math.max(left, bounds.left + 16);+ right = Math.min(right, bounds.right - 16);+ }+ if (clipsY) top = Math.max(top, bounds.top + 16);+ }const bounds = popover.getBoundingClientRect();- const shift = Math.max(16 - bounds.left, Math.min(0, window.innerWidth - 16 - bounds.right));+ const shift = Math.max(left - bounds.left, Math.min(0, right - bounds.right));popover.style.translate = `${shift}px 0`;+ if (bounds.top < top) popover.style.height = `${Math.max(0, bounds.bottom - top)}px`;};position();+ const popover = popoverRef.current;+ popover.addEventListener("toggle", position, true);window.addEventListener("resize", position);- return () => window.removeEventListener("resize", position);+ return () => {+ popover.removeEventListener("toggle", position, true);+ window.removeEventListener("resize", position);+ };}, [fitViewport, children]);return (<divdiff --git a/packages/studio/src/groupedVideoModels.js b/packages/studio/src/groupedVideoModels.jsindex c7a7f1f2..858192db 100644--- a/packages/studio/src/groupedVideoModels.js+++ b/packages/studio/src/groupedVideoModels.js@@ -3,8 +3,9 @@ import { VEO_MODEL_GROUP } from "./veoModels.js";import { MINIMAX_MODEL_GROUP } from "./minimaxModels.js";import { ALIBABA_MODEL_GROUP } from "./alibabaModels.js";import { HAPPY_HORSE_MODEL_GROUP } from "./happyHorseModels.js";+import { KLING_MODEL_GROUP } from "./klingModels.js";-const groups = [SEEDANCE_MODEL_GROUP, VEO_MODEL_GROUP, MINIMAX_MODEL_GROUP, ALIBABA_MODEL_GROUP, HAPPY_HORSE_MODEL_GROUP];+const groups = [SEEDANCE_MODEL_GROUP, VEO_MODEL_GROUP, MINIMAX_MODEL_GROUP, ALIBABA_MODEL_GROUP, HAPPY_HORSE_MODEL_GROUP, KLING_MODEL_GROUP];const groupByFamilyId = new Map();const configurationByModelId = new Map();const familyNames = {};diff --git a/packages/studio/src/groupedVideoParameters.js b/packages/studio/src/groupedVideoParameters.jsindex 9cf5c66b..f31c1c95 100644--- a/packages/studio/src/groupedVideoParameters.js+++ b/packages/studio/src/groupedVideoParameters.js@@ -10,12 +10,16 @@ import { ALIBABA_MODEL_GROUP } from "./alibabaModels.js";import { alibabaParameters } from "./alibabaParameters.js";import { HAPPY_HORSE_MODEL_GROUP } from "./happyHorseModels.js";import { happyHorseParameters } from "./happyHorseParameters.js";+import { KLING_MODEL_GROUP } from "./klingModels.js";+import { klingParameters } from "./klingParameters.js";import {getMiniMaxResolutionOptions,getMiniMaxSelectionAdjustments,planMiniMaxSelection,} from "./minimaxParameters.js";import { getGroupedVideoConfiguration } from "./groupedVideoModels.js";+import { videoModelCatalog } from "./modelFamilies.js";+import { getVideoWorkflowMediaAdjustments } from "./videoWorkflows.js";import {getVeoResolutionOptions,getVeoSelectionAdjustments,@@ -23,6 +27,7 @@ import {} from "./veoParameters.js";const groups = [+ { familyNames: KLING_MODEL_GROUP.familyNames, ...klingParameters },{ familyNames: HAPPY_HORSE_MODEL_GROUP.familyNames, ...happyHorseParameters },{ familyNames: ALIBABA_MODEL_GROUP.familyNames, ...alibabaParameters },{@@ -49,8 +54,24 @@ for (const group of groups) {for (const familyId of Object.keys(group.familyNames)) handlersByFamilyId.set(familyId, group);}+function mediaAdjustments({ currentModelId, selection, currentWorkflowId, workflowId = currentWorkflowId, media }) {+ if (!media || !currentWorkflowId || workflowId !== currentWorkflowId ||+ getGroupedVideoConfiguration(currentModelId)?.familyId !==+ getGroupedVideoConfiguration(selection.modelId)?.familyId) return [];+ return getVideoWorkflowMediaAdjustments(+ videoModelCatalog.variantById.get(currentModelId)?.model,+ videoModelCatalog.variantById.get(selection.modelId)?.model,+ workflowId, media,+ );+}+export function planGroupedVideoSelection(options) {- return handlersByFamilyId.get(options.familyId)?.plan(options) ?? null;+ const plan = handlersByFamilyId.get(options.familyId)?.plan(options);+ if (!plan) return null;+ const adjustments = mediaAdjustments({ ...options, selection: plan.selection });+ return adjustments.length > 0+ ? { ...plan, adjustments: [...plan.adjustments, ...adjustments] }+ : plan;}export function getGroupedVideoResolutionOptions(familyId, ...args) {@@ -59,5 +80,8 @@ export function getGroupedVideoResolutionOptions(familyId, ...args) {export function getGroupedVideoSelectionAdjustments(options) {const familyId = getGroupedVideoConfiguration(options.selection.modelId)?.familyId;- return handlersByFamilyId.get(familyId)?.adjustments(options) ?? [];+ return [+ ...(handlersByFamilyId.get(familyId)?.adjustments(options) ?? []),+ ...mediaAdjustments(options),+ ];}diff --git a/packages/studio/src/klingModels.js b/packages/studio/src/klingModels.jsnew file mode 100644index 00000000..8368bc8c--- /dev/null+++ b/packages/studio/src/klingModels.js@@ -0,0 +1,74 @@+import { createGroupedVideoRegistry } from "./groupedVideoRegistry.js";++export const KLING_FAMILY_NAMES = Object.freeze({+ "kling-v3": "Kling 3.0",+ "kling-v3-omni": "Kling 3.0 Omni",+ "kling-o1": "Kling O1",+ "kling-v2.6": "Kling 2.6",+ "kling-v2.5": "Kling 2.5 Turbo",+ "kling-v2.1": "Kling 2.1",+});++const registry = createGroupedVideoRegistry({+ facetOptions: {+ profile: [+ { value: "standard", label: "Standard" },+ { value: "pro", label: "Pro" },+ { value: "fast", label: "Fast" },+ { value: "master", label: "Master" },+ ],+ speed: [+ { value: "standard", label: "Standard" },+ { value: "fast", label: "Fast" },+ ],+ },+ facetLabels: { profile: "Generation", speed: "Speed" },+ registerVariants(register) {+ for (const service of ["standard", "pro", "4k"]) {+ register(`kling-v3.0-${service}-text-to-video`, "kling-v3", [null], { service });+ register(`kling-v3.0-${service}-image-to-video`, "kling-v3", ["animate_image", "keyframes"], { service });+ register(`kling-v3.0-omni-${service}-text-to-video`, "kling-v3-omni", [null], { service });+ register(`kling-v3.0-omni-${service}-image-to-video`, "kling-v3-omni", ["references"], { service });+ }+ for (const service of ["standard", "pro"]) {+ register(`kling-v3-turbo-${service}-text-to-video`, "kling-v3", [null], { service, speed: "fast" });+ register(`kling-v3-turbo-${service}-image-to-video`, "kling-v3", ["animate_image"], { service, speed: "fast" });+ for (const version of ["3.0", "2.6"]) {+ register(`kling-v${version}-${service === "standard" ? "std" : service}-motion-control`,+ version === "3.0" ? "kling-v3" : "kling-v2.6", ["motion_transfer"], { profile: service });+ }+ const stem = `kling-o1${service === "standard" ? "-standard" : ""}`;+ register(`${stem}-image-to-video`, "kling-o1", ["animate_image", "keyframes"], { profile: service });+ register(`${stem}-reference-to-video`, "kling-o1", ["references"], { profile: service });+ register(`${stem}-video-edit`, "kling-o1", ["edit_video"], { profile: service });+ register(`kling-v2.5-turbo-${service === "standard" ? "std" : service}-i2v`,+ "kling-v2.5", ["animate_image"], { profile: service });+ register(`kling-v2.1-${service}-i2v`, "kling-v2.1",+ service === "pro" ? ["animate_image", "keyframes"] : ["animate_image"], { profile: service });+ }+ register("kling-o1-text-to-video", "kling-o1", [null], { profile: "pro" });+ register("kling-o1-video-edit-fast", "kling-o1", ["edit_video"], { profile: "fast" });+ for (const [mode, workflowIds] of [["t2v", [null]], ["i2v", ["animate_image"]]]) {+ register(`kling-v2.6-pro-${mode}`, "kling-v2.6", workflowIds, { profile: "pro" });+ }+ register("kling-v2.5-turbo-pro-t2v", "kling-v2.5", [null], { profile: "pro" });+ register("kling-v2.1-master-t2v", "kling-v2.1", [null], { profile: "master" });+ register("kling-v2.1-master-i2v", "kling-v2.1", ["animate_image"], { profile: "master" });+ },+});++export const {+ getConfiguration: getKlingConfiguration,+ getVariants: getKlingVariants,+ resolveVariant: resolveKlingVariant,+} = registry;++export const KLING_MODEL_GROUP = Object.freeze({+ copyKey: "kling",+ familyNames: KLING_FAMILY_NAMES,+ configurations: registry.configurations,+ workflowVariants: registry.workflowVariants,+ resolveVariant: resolveKlingVariant,+ getVariantOptions: (...args) => registry.getVariantOptions(...args)+ .map((field) => ({ ...field, advanced: false })),+});diff --git a/packages/studio/src/klingParameters.js b/packages/studio/src/klingParameters.jsnew file mode 100644index 00000000..e83bfca6--- /dev/null+++ b/packages/studio/src/klingParameters.js@@ -0,0 +1,8 @@+import { createNativeVideoParameters } from "./nativeVideoParameters.js";+import { getKlingConfiguration, getKlingVariants, resolveKlingVariant } from "./klingModels.js";++export const klingParameters = createNativeVideoParameters({+ getConfiguration: getKlingConfiguration,+ resolveVariant: resolveKlingVariant,+ getResolutionVariants: getKlingVariants,+});diff --git a/packages/studio/src/messages/en/videoStudio.json b/packages/studio/src/messages/en/videoStudio.jsonindex 2672f2e3..c4a277f5 100644--- a/packages/studio/src/messages/en/videoStudio.json+++ b/packages/studio/src/messages/en/videoStudio.json@@ -125,7 +125,13 @@"aspectRatio": "Format: {value}","speed": "Speed: {value}","profile": "Service: {value}",- "quality": "Quality: {value}"+ "quality": "Quality: {value}",+ "imageUnused": "Uploaded images won’t be used",+ "videoUnused": "Uploaded videos won’t be used",+ "audioUnused": "Uploaded audio won’t be used",+ "imageCount": "Images used: {value}",+ "videoCount": "Videos used: {value}",+ "audioCount": "Audio files used: {value}"},"fields": {"seed": {@@ -367,5 +373,57 @@}}}+ },+ "kling": {+ "speed": "Speed",+ "speeds": {+ "standard": "Standard speed",+ "fast": "Fast"+ },+ "speedDescriptions": {+ "standard": "",+ "fast": "Faster generation."+ },+ "provider": "Generation",+ "providerHelp": "",+ "profiles": {+ "standard": {+ "label": "Standard",+ "description": ""+ },+ "master": {+ "label": "Master",+ "description": "Improved motion and prompt following."+ },+ "pro": {+ "label": "Pro",+ "description": "More detail."+ },+ "fast": {+ "label": "Fast",+ "description": "Faster video editing."+ }+ },+ "adjustments": {+ "profile": "Generation: {value}"+ },+ "fields": {+ "sound": {+ "title": "Generate audio",+ "description": ""+ },+ "keep_original_sound": {+ "title": "Keep original audio",+ "description": "Use the audio from your video."+ },+ "character_orientation": {+ "title": "Character pose",+ "description": "Choose which source sets the character’s pose.",+ "optionLabels": {+ "image": "From image (up to 10s)",+ "video": "From video (up to 30s)"+ }+ }+ }}}diff --git a/packages/studio/src/messages/zh/videoStudio.json b/packages/studio/src/messages/zh/videoStudio.jsonindex af090182..79f627eb 100644--- a/packages/studio/src/messages/zh/videoStudio.json+++ b/packages/studio/src/messages/zh/videoStudio.json@@ -125,7 +125,13 @@"aspectRatio": "画面比例:{value}","speed": "速度:{value}","profile": "服务:{value}",- "quality": "质量:{value}"+ "quality": "质量:{value}",+ "imageUnused": "不会使用已上传的图片",+ "videoUnused": "不会使用已上传的视频",+ "audioUnused": "不会使用已上传的音频",+ "imageCount": "使用图片数量:{value}",+ "videoCount": "使用视频数量:{value}",+ "audioCount": "使用音频数量:{value}"},"fields": {"seed": {@@ -367,5 +373,57 @@}}}+ },+ "kling": {+ "speed": "速度",+ "speeds": {+ "standard": "标准速度",+ "fast": "快速"+ },+ "speedDescriptions": {+ "standard": "",+ "fast": "更快生成。"+ },+ "provider": "生成方式",+ "providerHelp": "",+ "profiles": {+ "standard": {+ "label": "标准",+ "description": ""+ },+ "master": {+ "label": "Master",+ "description": "改善运动效果和提示词理解。"+ },+ "pro": {+ "label": "Pro",+ "description": "更多细节。"+ },+ "fast": {+ "label": "快速",+ "description": "更快编辑视频。"+ }+ },+ "adjustments": {+ "profile": "生成方式:{value}"+ },+ "fields": {+ "sound": {+ "title": "生成音频",+ "description": ""+ },+ "keep_original_sound": {+ "title": "保留原音频",+ "description": "使用上传视频中的音频。"+ },+ "character_orientation": {+ "title": "角色姿态",+ "description": "选择用于确定角色姿态的素材。",+ "optionLabels": {+ "image": "来自图片(最长10秒)",+ "video": "来自视频(最长30秒)"+ }+ }+ }}}diff --git a/packages/studio/src/minimaxParameters.js b/packages/studio/src/minimaxParameters.jsindex 82a42c4a..f559426e 100644--- a/packages/studio/src/minimaxParameters.js+++ b/packages/studio/src/minimaxParameters.js@@ -1,12 +1,38 @@import { getMiniMaxConfiguration, getMiniMaxVariants, resolveMiniMaxVariant } from "./minimaxModels.js";import { createNativeVideoParameters } from "./nativeVideoParameters.js";+import { normalizeVideoResolution } from "./videoModelParameters.js";-export const {- plan: planMiniMaxSelection,- resolutions: getMiniMaxResolutionOptions,- adjustments: getMiniMaxSelectionAdjustments,-} = createNativeVideoParameters({+const nativeParameters = createNativeVideoParameters({getConfiguration: getMiniMaxConfiguration,resolveVariant: resolveMiniMaxVariant,getResolutionVariants: getMiniMaxVariants,});++const isHailuo02Keyframes = (familyId, workflowId) =>+ familyId === "minimax-hailuo-02" && workflowId === "keyframes";++export const getMiniMaxSelectionAdjustments = nativeParameters.adjustments;++export function planMiniMaxSelection(options) {+ const plan = nativeParameters.plan(options);+ if (!plan || !isHailuo02Keyframes(options.familyId, options.workflowId) ||+ normalizeVideoResolution(plan.selection.resolution) !== "512p") return plan;+ if (Object.hasOwn(options.changes || {}, "resolution")) return null;++ // First & last frames require 768P or 1080P; 512P supports the first frame only.+ // https://platform.minimax.io/docs/api-reference/video-generation-fl2v+ const { selection } = nativeParameters.plan({+ ...options, changes: { ...options.changes, resolution: "768P" },+ });+ return { selection, adjustments: nativeParameters.adjustments({ ...options, selection }) };+}++export function getMiniMaxResolutionOptions(familyId, workflowId = null, currentModelId = null, nativeResolution) {+ const field = nativeParameters.resolutions(familyId, workflowId, currentModelId, nativeResolution);+ if (!isHailuo02Keyframes(familyId, workflowId)) return field;+ return {+ ...field,+ value: field.value === "512p" ? "768p" : field.value,+ options: field.options.filter((option) => option.value !== "512p"),+ };+}diff --git a/packages/studio/src/modelFamilies.js b/packages/studio/src/modelFamilies.jsindex 7bec3d67..7b35d795 100644--- a/packages/studio/src/modelFamilies.js+++ b/packages/studio/src/modelFamilies.js@@ -193,6 +193,8 @@ function imageFamilyId(model) {}function videoFamilyId(model) {+ const grouped = getGroupedVideoConfiguration(model.id);+ if (grouped) return grouped.familyId;const modelId = model.id.toLowerCase();const id = VIDEO_FAMILY_ALIASES[modelId] || modelId;let match = id.match(/^kling-(v?\d+(?:\.\d+)?|o1)(?:-|$)/);diff --git a/packages/studio/src/modelParameters.js b/packages/studio/src/modelParameters.jsindex 1d7f12c1..90e6605c 100644--- a/packages/studio/src/modelParameters.js+++ b/packages/studio/src/modelParameters.js@@ -111,6 +111,10 @@ export function createModelParameterValues(model, previousValues = {}) {return values;}+export function mergeModelParameterValues(model, previousValues = {}) {+ return { ...previousValues, ...createModelParameterValues(model, previousValues) };+}+export function buildSupplementalInputPayload(model, values = {}) {const payload = {};for (const { key, schema } of getSupplementalModelInputs(model)) {diff --git a/packages/studio/src/models.js b/packages/studio/src/models.jsindex e7e7cb4b..4155967a 100644--- a/packages/studio/src/models.js+++ b/packages/studio/src/models.js@@ -95,6 +95,54 @@ const HAPPY_HORSE_EDIT_INPUTS = Object.freeze({seed: HAPPY_HORSE_SEED_INPUT,});+// Kling inputs verified against https://api.muapi.ai/openapi.json on 2026-09-09.+// Output sizes are recorded only for documented routes;+// resolution selects an endpoint and is not a native request parameter.+const KLING_ASPECT_RATIO_INPUT = Object.freeze({+ type: "string", title: "Aspect Ratio", name: "aspect_ratio",+ enum: Object.freeze(["16:9", "9:16", "1:1"]), default: "16:9",+});+const KLING_AUDIO_INPUT = Object.freeze({+ type: "boolean", title: "Generate audio", name: "generate_audio", default: true,+});+const KLING_SOUND_INPUT = Object.freeze({+ type: "boolean", title: "Generate audio", name: "sound", default: true,+});+const KLING_KEEP_SOUND_INPUT = Object.freeze({+ type: "boolean", title: "Keep original sound", name: "keep_original_sound",+ default: true,+});+const KLING_MOTION_INPUTS = Object.freeze({+ prompt: { type: "string", title: "Prompt", name: "prompt" },+ image_url: { type: "string", field: "image", title: "Character image", name: "image_url" },+ video_url: { type: "string", field: "video", title: "Motion video", name: "video_url" },+ character_orientation: {+ type: "string", title: "Character orientation", name: "character_orientation",+ enum: ["image", "video"], default: "image",+ },+});+const KLING_3_MOTION_INPUTS = Object.freeze({+ ...KLING_MOTION_INPUTS,+ keep_original_sound: KLING_KEEP_SOUND_INPUT,+});+const KLING_O1_EDIT_INPUTS = Object.freeze({+ prompt: { type: "string", title: "Prompt", name: "prompt" },+ video_url: { type: "string", field: "video", title: "Source video", name: "video_url" },+ images_list: {+ type: "array", items: { type: "string" }, title: "Reference images",+ name: "images_list", maxItems: 4,+ },+ keep_original_sound: KLING_KEEP_SOUND_INPUT,+});+const KLING_O1_PRO_EDIT_INPUTS = Object.freeze({+ ...KLING_O1_EDIT_INPUTS,+ aspect_ratio: KLING_ASPECT_RATIO_INPUT,+});+const KLING_OMNI_REFERENCE_INPUT = Object.freeze({+ type: "array", items: { type: "string" }, title: "Reference images",+ name: "images_list", minItems: 1, maxItems: 4,+});+export const t2iModels = [{"id": "nano-banana",@@ -4284,6 +4332,7 @@ export const t2vModels = [},{"id": "kling-v2.1-master-t2v",+ "fixedParameters": { resolution: "1080p" },"name": "Kling 2.1 Master","inputs": {"prompt": {@@ -4358,6 +4407,7 @@ export const t2vModels = ["id": "kling-v2.6-pro-t2v","name": "Kling 2.6 Pro","inputs": {+ "sound": KLING_SOUND_INPUT,"prompt": {"type": "string","title": "Prompt",@@ -4430,8 +4480,10 @@ export const t2vModels = [},{"id": "kling-v3.0-pro-text-to-video",+ "fixedParameters": { resolution: "1080p" },"name": "Kling 3.0 Pro","inputs": {+ "generate_audio": KLING_AUDIO_INPUT,"prompt": {"type": "string","title": "Prompt",@@ -4466,8 +4518,10 @@ export const t2vModels = [},{"id": "kling-v3.0-standard-text-to-video",+ "fixedParameters": { resolution: "720p" },"name": "Kling 3.0 Standard","inputs": {+ "generate_audio": KLING_AUDIO_INPUT,"prompt": {"type": "string","title": "Prompt",@@ -6696,6 +6750,7 @@ export const t2vModels = [},{"id": "kling-v3.0-4k-text-to-video",+ "fixedParameters": { resolution: "4K" },"name": "Kling 3.0 4K","endpoint": "kling-v3.0-4k-text-to-video","inputs": {@@ -6730,13 +6785,7 @@ export const t2vModels = ["maxValue": 15,"step": 1},- "generate_audio": {- "type": "boolean",- "default": true,- "title": "Generate Audio",- "name": "generate_audio",- "description": "Whether to generate audio for the video"- }+ "generate_audio": KLING_AUDIO_INPUT},"provider": "kling","provider_name": "Kling AI"@@ -7211,6 +7260,7 @@ export const t2vModels = [},{"id": "kling-v3.0-omni-standard-text-to-video",+ "fixedParameters": { resolution: "720p" },"name": "Kling 3.0 Omni Standard","endpoint": "kling-v3.0-omni-standard-text-to-video","inputs": {@@ -7270,6 +7320,7 @@ export const t2vModels = [},{"id": "kling-v3.0-omni-pro-text-to-video",+ "fixedParameters": { resolution: "1080p" },"name": "Kling 3.0 Omni Pro","endpoint": "kling-v3.0-omni-pro-text-to-video","inputs": {@@ -7329,6 +7380,7 @@ export const t2vModels = [},{"id": "kling-v3.0-omni-4k-text-to-video",+ "fixedParameters": { resolution: "4K" },"name": "Kling 3.0 Omni 4K","endpoint": "kling-v3.0-omni-4k-text-to-video","inputs": {@@ -7464,6 +7516,7 @@ export const t2vModels = [},{"id": "kling-v3-turbo-standard-text-to-video",+ "fixedParameters": { resolution: "720p" },"name": "Kling 3.0 Turbo Standard","endpoint": "kling-v3-turbo-standard-text-to-video","inputs": {@@ -7504,6 +7557,7 @@ export const t2vModels = [},{"id": "kling-v3-turbo-pro-text-to-video",+ "fixedParameters": { resolution: "1080p" },"name": "Kling 3.0 Turbo Pro","endpoint": "kling-v3-turbo-pro-text-to-video","inputs": {@@ -13369,11 +13423,11 @@ export const i2vModels = [},{"id": "kling-v2.1-master-i2v",+ "fixedParameters": { resolution: "1080p" },"name": "Kling v2.1 Master I2V","endpoint": "kling-v2.1-master-i2v","family": "kling-v2.1","imageField": "image_url",- "lastImageField": "last_image","hasPrompt": true,"promptRequired": true,"inputs": {@@ -13414,11 +13468,11 @@ export const i2vModels = [},{"id": "kling-v2.1-standard-i2v",+ "fixedParameters": { resolution: "720p" },"name": "Kling 2.1 Standard","endpoint": "kling-v2.1-standard-i2v","family": "kling-v2.1","imageField": "image_url",- "lastImageField": "last_image","hasPrompt": true,"promptRequired": true,"inputs": {@@ -13459,6 +13513,7 @@ export const i2vModels = [},{"id": "kling-v2.1-pro-i2v",+ "fixedParameters": { resolution: "1080p" },"name": "Kling 2.1 Pro","endpoint": "kling-v2.1-pro-i2v","family": "kling-v2.1",@@ -14170,6 +14225,8 @@ export const i2vModels = ["family": "kling-v2.5","imageField": "image_url","hasPrompt": true,+ "promptRequired": true,+ "aspectRatioMode": "inherited","inputs": {"prompt": {"type": "string",@@ -15123,6 +15180,8 @@ export const i2vModels = ["family": "kling-v2.5","imageField": "image_url","hasPrompt": true,+ "promptRequired": true,+ "aspectRatioMode": "inherited","inputs": {"prompt": {"type": "string",@@ -15250,7 +15309,12 @@ export const i2vModels = ["hasPrompt": true,"promptRequired": true,"maxImages": 7,+ "required": ["prompt", "images_list"],"inputs": {+ "images_list": {+ type: "array", items: { type: "string" }, title: "Reference images",+ name: "images_list", maxItems: 7,+ },"prompt": {"type": "string","title": "Prompt",@@ -15282,13 +15346,7 @@ export const i2vModels = ["maxValue": 10,"step": 1},- "keep_original_sound": {- "type": "boolean",- "title": "Keep Original Sound",- "name": "keep_original_sound",- "description": "Select whether to keep the video original sound through the parameter.",- "default": true- }+ "keep_original_sound": KLING_KEEP_SOUND_INPUT},"provider": "kling","provider_name": "Kling AI"@@ -15301,7 +15359,7 @@ export const i2vModels = ["imageField": "image_url","hasPrompt": true,"promptRequired": true,- "parameterNotice": "This integration supports 5 or 10 seconds.",+ "aspectRatioMode": "inherited","inputs": {"prompt": {"type": "string",@@ -15323,13 +15381,7 @@ export const i2vModels = [],"default": 5},- "sound": {- "type": "boolean",- "title": "Sound",- "name": "sound",- "description": "Whether sound is generated simultaneously when generating a video.",- "default": true- }+ "sound": KLING_SOUND_INPUT},"provider": "kling","provider_name": "Kling AI"@@ -15557,6 +15609,7 @@ export const i2vModels = ["lastImageField": "last_image","hasPrompt": true,"promptRequired": true,+ "aspectRatioMode": "inherited","inputs": {"prompt": {"type": "string",@@ -15591,7 +15644,12 @@ export const i2vModels = ["hasPrompt": true,"promptRequired": true,"maxImages": 7,+ "required": ["prompt", "images_list"],"inputs": {+ "images_list": {+ type: "array", items: { type: "string" }, title: "Reference images",+ name: "images_list", minItems: 1, maxItems: 7,+ },"prompt": {"type": "string","title": "Prompt",@@ -15824,6 +15882,7 @@ export const i2vModels = [},{"id": "kling-v3.0-omni-standard-image-to-video",+ "fixedParameters": { resolution: "720p" },"name": "Kling v3.0 Omni Standard Image To Video","endpoint": "kling-v3.0-omni-standard-image-to-video","family": "kling-v3.0-omni",@@ -15832,6 +15891,7 @@ export const i2vModels = ["promptRequired": true,"maxImages": 4,"inputs": {+ "images_list": KLING_OMNI_REFERENCE_INPUT,"prompt": {"type": "string","title": "Prompt",@@ -15888,6 +15948,7 @@ export const i2vModels = [},{"id": "kling-v3.0-omni-pro-image-to-video",+ "fixedParameters": { resolution: "1080p" },"name": "Kling v3.0 Omni Pro Image To Video","endpoint": "kling-v3.0-omni-pro-image-to-video","family": "kling-v3.0-omni",@@ -15896,6 +15957,7 @@ export const i2vModels = ["promptRequired": true,"maxImages": 4,"inputs": {+ "images_list": KLING_OMNI_REFERENCE_INPUT,"prompt": {"type": "string","title": "Prompt",@@ -15952,6 +16014,7 @@ export const i2vModels = [},{"id": "kling-v3.0-omni-4k-image-to-video",+ "fixedParameters": { resolution: "4K" },"name": "Kling v3.0 Omni 4K Image To Video","endpoint": "kling-v3.0-omni-4k-image-to-video","family": "kling-v3.0-omni",@@ -15960,6 +16023,7 @@ export const i2vModels = ["promptRequired": true,"maxImages": 4,"inputs": {+ "images_list": KLING_OMNI_REFERENCE_INPUT,"prompt": {"type": "string","title": "Prompt",@@ -16009,6 +16073,7 @@ export const i2vModels = [},{"id": "kling-v3.0-pro-image-to-video",+ "fixedParameters": { resolution: "1080p" },"name": "Kling v3.0 Pro Image To Video","endpoint": "kling-v3.0-pro-image-to-video","family": "kling-v3.0",@@ -16016,6 +16081,7 @@ export const i2vModels = ["lastImageField": "last_image","hasPrompt": true,"promptRequired": true,+ "aspectRatioMode": "inherited","inputs": {"prompt": {"type": "string",@@ -16036,19 +16102,14 @@ export const i2vModels = ["maxValue": 15,"step": 1},- "generate_audio": {- "type": "boolean",- "title": "Generate Audio",- "name": "generate_audio",- "description": "Whether to generate audio for the video",- "default": true- }+ "generate_audio": KLING_AUDIO_INPUT},"provider": "kling","provider_name": "Kling AI"},{"id": "kling-v3.0-standard-image-to-video",+ "fixedParameters": { resolution: "720p" },"name": "Kling v3.0 Standard Image To Video","endpoint": "kling-v3.0-standard-image-to-video","family": "kling-v3.0",@@ -16056,6 +16117,7 @@ export const i2vModels = ["lastImageField": "last_image","hasPrompt": true,"promptRequired": true,+ "aspectRatioMode": "inherited","inputs": {"prompt": {"type": "string",@@ -16076,13 +16138,7 @@ export const i2vModels = ["maxValue": 15,"step": 1},- "generate_audio": {- "type": "boolean",- "title": "Generate Audio",- "name": "generate_audio",- "description": "Whether to generate audio for the video",- "default": true- }+ "generate_audio": KLING_AUDIO_INPUT},"provider": "kling","provider_name": "Kling AI"@@ -18352,6 +18408,7 @@ export const i2vModels = [},{"id": "kling-v3.0-4k-image-to-video",+ "fixedParameters": { resolution: "4K" },"name": "Kling v3.0 4K","endpoint": "kling-v3.0-4k-image-to-video","family": "kling-v3.0",@@ -18359,6 +18416,7 @@ export const i2vModels = ["lastImageField": "last_image","hasPrompt": true,"promptRequired": true,+ "aspectRatioMode": "inherited","inputs": {"prompt": {"examples": [@@ -18399,13 +18457,7 @@ export const i2vModels = ["maxValue": 15,"step": 1},- "generate_audio": {- "type": "boolean",- "default": true,- "title": "Generate Audio",- "name": "generate_audio",- "description": "Whether to generate audio for the video"- }+ "generate_audio": KLING_AUDIO_INPUT},"provider": "kling","provider_name": "Kling AI"@@ -19211,12 +19263,14 @@ export const i2vModels = [},{"id": "kling-v3-turbo-standard-image-to-video",+ "fixedParameters": { resolution: "720p" },"name": "Kling v3 Turbo Standard","endpoint": "kling-v3-turbo-standard-image-to-video","family": "kling-v3.0","imageField": "image_url","hasPrompt": true,"promptRequired": true,+ "aspectRatioMode": "inherited","inputs": {"prompt": {"type": "string",@@ -19253,12 +19307,14 @@ export const i2vModels = [},{"id": "kling-v3-turbo-pro-image-to-video",+ "fixedParameters": { resolution: "1080p" },"name": "Kling v3 Turbo Pro","endpoint": "kling-v3-turbo-pro-image-to-video","family": "kling-v3.0","imageField": "image_url","hasPrompt": true,"promptRequired": true,+ "aspectRatioMode": "inherited","inputs": {"prompt": {"type": "string",@@ -24657,6 +24713,7 @@ export const v2vModels = ["videoField": "video_url","imageField": "image_url","hasPrompt": true,+ "inputs": KLING_MOTION_INPUTS,"promptRequired": true,"description": "Kling v2.6 Pro Motion Control allows precise control over camera movement, subject motion, and scene dynamics during video generation.","provider": "kling",@@ -24670,6 +24727,7 @@ export const v2vModels = ["videoField": "video_url","imageField": "image_url","hasPrompt": true,+ "inputs": KLING_3_MOTION_INPUTS,"description": "Kling V3.0 Standard Motion Control allows for precise control over the camera and subject movement in generated videos.","provider": "kling","provider_name": "Kling AI"@@ -24682,6 +24740,7 @@ export const v2vModels = ["videoField": "video_url","imageField": "image_url","hasPrompt": true,+ "inputs": KLING_3_MOTION_INPUTS,"description": "Kling V3.0 Pro Motion Control provides the highest level of detail and control for video generation.","provider": "kling","provider_name": "Kling AI"@@ -24819,16 +24878,7 @@ export const v2vModels = ["images_list","video_url"],- "inputs": {- "images_list": {- "field": "images_list",- "type": "array",- "items": {- "type": "string"- },- "maxItems": 4- }- },+ "inputs": KLING_O1_PRO_EDIT_INPUTS,"description": "Kling O1 Video Edit lets you send an existing video clip plus an instruction/prompt to edit or transform the clip while preserving temporal coherence and subject identity.","provider": "kling","provider_name": "Kling AI"@@ -24848,16 +24898,7 @@ export const v2vModels = ["images_list","video_url"],- "inputs": {- "images_list": {- "field": "images_list",- "type": "array",- "items": {- "type": "string"- },- "maxItems": 4- }- },+ "inputs": KLING_O1_PRO_EDIT_INPUTS,"description": "Video Edit Fast is the lightweight, high-speed editing mode of Kling O1.","provider": "kling","provider_name": "Kling AI"@@ -24877,16 +24918,7 @@ export const v2vModels = ["images_list","video_url"],- "inputs": {- "images_list": {- "field": "images_list",- "type": "array",- "items": {- "type": "string"- },- "maxItems": 4- }- },+ "inputs": KLING_O1_EDIT_INPUTS,"description": "Kling O1 Standard Video-to-Video Edit modifies an existing video while preserving its original structure, motion, and realism.","provider": "kling","provider_name": "Kling AI"@@ -25149,6 +25181,7 @@ export const v2vModels = ["videoField": "video_url","imageField": "image_url","hasPrompt": true,+ "inputs": KLING_MOTION_INPUTS,"promptRequired": true,"description": "Kling v2.6 Pro Motion Control allows precise control over camera movement, subject motion, and scene dynamics during video generation.","provider": "kling",diff --git a/packages/studio/src/videoWorkflows.js b/packages/studio/src/videoWorkflows.jsindex 8b3c0110..f7ef72f8 100644--- a/packages/studio/src/videoWorkflows.js+++ b/packages/studio/src/videoWorkflows.js@@ -53,29 +53,6 @@ const WORKFLOW_REQUIRED_MEDIA = Object.freeze({// Opt-in only: models outside this registry retain their existing behavior.export const VIDEO_WORKFLOW_VARIANTS = Object.freeze({- "kling-v3": {- animate_image: [- "kling-v3-turbo-pro-image-to-video",- "kling-v3-turbo-standard-image-to-video",- "kling-v3.0-4k-image-to-video",- "kling-v3.0-standard-image-to-video",- "kling-v3.0-pro-image-to-video",- ],- keyframes: [- "kling-v3.0-4k-image-to-video",- "kling-v3.0-standard-image-to-video",- "kling-v3.0-pro-image-to-video",- ],- references: [- "kling-v3.0-omni-4k-image-to-video",- "kling-v3.0-omni-pro-image-to-video",- "kling-v3.0-omni-standard-image-to-video",- ],- motion_transfer: [- "kling-v3.0-pro-motion-control",- "kling-v3.0-std-motion-control",- ],- },"gemini-omni": {animate_image: ["gemini-omni-image-to-video"],references: ["gemini-omni-image-to-video"],@@ -98,43 +75,13 @@ export const VIDEO_WORKFLOW_VARIANTS = Object.freeze({animate_image: ["pixverse-v6-i2v"],keyframes: ["pixverse-v6-transition"],},- "kling-o1": {- animate_image: ["kling-o1-standard-image-to-video", "kling-o1-image-to-video"],- keyframes: ["kling-o1-standard-image-to-video", "kling-o1-image-to-video"],- references: ["kling-o1-standard-reference-to-video", "kling-o1-reference-to-video"],- edit_video: [- "kling-o1-standard-video-edit",- "kling-o1-video-edit-fast",- "kling-o1-video-edit",- ],- },- "kling-v2.6": {- animate_image: ["kling-v2.6-pro-i2v"],- motion_transfer: ["kling-v2.6-pro-motion-control", "kling-v2.6-std-motion-control"],- },"ltx-2.3": {animate_image: ["ltx-2.3-image-to-video"],extend_uploaded_video: ["ltx-2.3-video-extend"],},- "kling-v2.1": {- animate_image: [- "kling-v2.1-pro-i2v",- "kling-v2.1-standard-i2v",- "kling-v2.1-master-i2v",- ],- keyframes: ["kling-v2.1-pro-i2v"],- },...GROUPED_VIDEO_WORKFLOW_VARIANTS,});-const TECHNICAL_EXCLUDED_VARIANTS = Object.freeze({- "kling-v3": new Set([- "kling-v3.0-omni-4k-text-to-video",- "kling-v3.0-omni-pro-text-to-video",- "kling-v3.0-omni-standard-text-to-video",- ]),-});-function createVariantGroup(variants) {const uniqueVariants = [];const seen = new Set();@@ -186,12 +133,10 @@ function createWorkflowCatalog() {}}- const excluded = TECHNICAL_EXCLUDED_VARIANTS[familyId] || new Set();const base = createVariantGroup(family.variants.t2v.filter((variant) =>!workflowVariantIds.has(variant.model.id) &&- !excluded.has(variant.model.id) &&!variant.model.requiresRequestId,),);@@ -204,7 +149,6 @@ function createWorkflowCatalog() {(variant) =>!base.variantIds.has(variant.model.id) &&!workflowVariantIds.has(variant.model.id) &&- !excluded.has(variant.model.id) &&!variant.model.requiresRequestId,),);@@ -572,9 +516,16 @@ const WAN_REFERENCE_CONSTRAINT = Object.freeze({const MINIMAX_H3_REFERENCE_CONSTRAINT = Object.freeze({combinedSlotIds: MULTIMODAL_REFERENCE_SLOT_IDS,combinedLimit: 12,- requiredSlotIds: VISUAL_REFERENCE_SLOT_IDS,combinedLimitMessage: "MiniMax H3 supports up to 12 references in total.",});+const KLING_O1_REFERENCE_CONSTRAINT = Object.freeze({+ combinedSlotIds: VISUAL_REFERENCE_SLOT_IDS,+ combinedLimit: 7,+ // A video reduces the image allowance from seven to four.+ slotWeights: Object.freeze({ referenceVideos: 3 }),+ requiredSlotIds: VISUAL_REFERENCE_SLOT_IDS,+ combinedLimitMessage: "Kling O1 supports up to 4 reference images when a video is included.",+});export function getVideoWorkflowMediaSlots(model, workflowId) {if (!model || !workflowId) return [];@@ -676,6 +627,12 @@ export function getVideoWorkflowMediaSlots(model, workflowId) {),];}+ const minimaxReferenceConstraint = familyId === "minimax-h3" ? {+ ...MINIMAX_H3_REFERENCE_CONSTRAINT,+ // Open H3 and LoRA support standalone audio references.+ requiredSlotIds: getGroupedVideoConfiguration(model.id)?.service === "official"+ ? VISUAL_REFERENCE_SLOT_IDS : MULTIMODAL_REFERENCE_SLOT_IDS,+ } : {};return [imageField && createMediaSlot("referenceImages",@@ -695,8 +652,9 @@ export function getVideoWorkflowMediaSlots(model, workflowId) {requiredMessage: "Please add a reference image.",}: {}),- ...(familyId === "minimax-h3"- ? MINIMAX_H3_REFERENCE_CONSTRAINT+ ...minimaxReferenceConstraint,+ ...(familyId === "kling-o1" && videoField+ ? KLING_O1_REFERENCE_CONSTRAINT: {}),},),@@ -709,8 +667,9 @@ export function getVideoWorkflowMediaSlots(model, workflowId) {Math.max(capabilities.video.maxItems, 1),{isArray: capabilities.video.isArray,- ...(familyId === "minimax-h3"- ? MINIMAX_H3_REFERENCE_CONSTRAINT+ ...minimaxReferenceConstraint,+ ...(familyId === "kling-o1"+ ? KLING_O1_REFERENCE_CONSTRAINT: {}),},),@@ -723,9 +682,7 @@ export function getVideoWorkflowMediaSlots(model, workflowId) {Math.max(capabilities.audio.maxItems, 1),{isArray: capabilities.audio.isArray,- ...(familyId === "minimax-h3"- ? MINIMAX_H3_REFERENCE_CONSTRAINT- : {}),+ ...minimaxReferenceConstraint,},),].filter(Boolean);@@ -820,6 +777,14 @@ export function getVideoWorkflowDraftKey(familyId, workflowId) {return `${familyId}:${workflowId}`;}+export function migrateVideoWorkflowMediaDrafts(drafts) {+ // Omni references used to share Kling 3.0's draft before becoming a separate model.+ const { "kling-v3:references": omniReferences, ...migrated } = drafts;+ const key = getVideoWorkflowDraftKey("kling-v3-omni", "references");+ if (omniReferences && !Object.hasOwn(migrated, key)) migrated[key] = omniReferences;+ return migrated;+}+export function appendVideoWorkflowMedia(drafts,draftKey,@@ -889,6 +854,22 @@ export function projectVideoWorkflowMedia(model, workflowId, media = {}) {return projected;}+export function getVideoWorkflowMediaAdjustments(currentModel, nextModel, workflowId, media) {+ const current = projectVideoWorkflowMedia(currentModel, workflowId, media);+ const next = projectVideoWorkflowMedia(nextModel, workflowId, media);+ const counts = {};+ for (const slot of getVideoWorkflowMediaSlots(currentModel, workflowId)) {+ const count = counts[slot.mediaType] ||= { from: 0, to: 0 };+ count.from += current[slot.id]?.length || 0;+ count.to += next[slot.id]?.length || 0;+ }+ return Object.entries(counts)+ .filter(([, { from, to }]) => from > to)+ .map(([type, { from, to }]) => ({+ key: `${type}${to === 0 ? "Unused" : "Count"}`, from, to,+ }));+}+export function getVideoWorkflowSlotRemaining(slot, media = {}) {if (!slot) return 0;const ownRemaining = Math.max(@@ -896,10 +877,10 @@ export function getVideoWorkflowSlotRemaining(slot, media = {}) {0,);if (!slot.combinedLimit || !slot.combinedSlotIds) return ownRemaining;- const combinedCount = combinedMediaCount(media, slot.combinedSlotIds);+ const combinedCount = combinedMediaCount(media, slot.combinedSlotIds, slot.slotWeights);return Math.min(ownRemaining,- Math.max(slot.combinedLimit - combinedCount, 0),+ Math.max(Math.floor((slot.combinedLimit - combinedCount) / (slot.slotWeights?.[slot.id] || 1)), 0),);}@@ -916,10 +897,9 @@ function mediaCount(media, slotId) {return mediaValues(media, slotId).length;}-function combinedMediaCount(media, slotIds, excludedSlotId = null) {+function combinedMediaCount(media, slotIds, slotWeights) {return slotIds.reduce(- (total, slotId) =>- slotId === excludedSlotId ? total : total + mediaCount(media, slotId),+ (total, slotId) => total + mediaCount(media, slotId) * (slotWeights?.[slotId] || 1),0,);}@@ -959,6 +939,7 @@ export function validateVideoWorkflowMedia(workflowId, media = {}, model = null)const combinedCount = combinedMediaCount(activeMedia,combinedConstraint.combinedSlotIds,+ combinedConstraint.slotWeights,);if (combinedCount > combinedConstraint.combinedLimit) {return {