Add fal.ai queue REST API video backend to MediaGen and FableLoom - #6222
Merged
Conversation
…om (#6213) Adds server/services/videoGen/fal.js — a queue-submit/poll/download provider mirroring videoGen/grok.js's job-map/SSE contract — as a first-class mediaJobQueue cloud-lane video backend, replacing the brittle Playwright browser automation FableLoom used for fal.ai (services/fableLoom/falVideoAutomation.js, left in place as a fallback) with a direct API call. Wires 'fal' through the VIDEO_GEN_MODE alphabet, the video pin ladder, prepareVideoGenParams' backend short-circuit, submitJob's dispatch, and the VideoGen page's backend switch, plus a Settings > Image Gen field for the FAL_KEY / API key.
- Derive aspect_ratio from width/height (nearest of 16:9/9:16/1:1) when the caller doesn't name one explicitly, mirroring grok's deriveAspectRatio — a standalone VideoGen text-to-video request previously always fell back to fal's own default ratio. - Route mediaJobQueue's cloud-lane/local-python gates through CLOUD_VIDEO_GEN_MODES.includes() instead of enumerating GROK/FAL literals, so a future cloud video backend is one alphabet entry instead of three call sites. - Drop the dead `fal` field prepareParams returned on the short-circuit — fal.js re-resolves its API key from live settings itself, so nothing ever read it. - Settings save now sends `undefined` (dropped by JSON.stringify) instead of a literal empty string when the fal.ai API key field is cleared.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
server/services/videoGen/fal.js— a queue-submit/poll/download provider for fal.ai's metered REST API, mirroringvideoGen/grok.js's job-map/SSE contract somediaJobQueuedispatches to it as a first-class cloud-lane video backend.falthrough theVIDEO_GEN_MODEalphabet, the video pin ladder (isVideoModeUsable),prepareVideoGenParams's backend short-circuit, andsubmitJob's dispatch.fal.aibackend option to the VideoGen page's backend switch and a matching option in FableLoom's render-backend picker, plus a Settings → Image Gen field to configure the fal.ai API key (or theFAL_KEYenv var).aspect_ratiofrom width/height (nearest of16:9/9:16/1:1) when not explicitly supplied, same as the existing grok backend.data/media-jobs.jsonin plaintext.services/fableLoom/falVideoAutomation.js) is left in place; this adds a reliable API-based alternative alongside it.Test plan
cd server && npx vitest run— 1936 files / 39076 tests passing.cd client && npx vitest run— 837 files / 10301 tests passing.server/services/videoGen/fal.test.jscovers key resolution precedence (settings >FAL_KEYenv, and re-resolution via live settings when neither is passed explicitly), aspect-ratio derivation, request-body building, and the full submit → poll → download → history-finalize flow against a mockedfetch.Closes #6213