Skip to content

Add fal.ai queue REST API video backend to MediaGen and FableLoom - #6222

Merged
atomantic merged 2 commits into
mainfrom
claim/issue-6213
Sep 4, 2026
Merged

Add fal.ai queue REST API video backend to MediaGen and FableLoom#6222
atomantic merged 2 commits into
mainfrom
claim/issue-6213

Conversation

@atomantic

Copy link
Copy Markdown
Owner

Summary

  • Adds server/services/videoGen/fal.js — a queue-submit/poll/download provider for fal.ai's metered REST API, mirroring videoGen/grok.js's job-map/SSE contract so mediaJobQueue dispatches to it as a first-class cloud-lane video backend.
  • Wires fal through the VIDEO_GEN_MODE alphabet, the video pin ladder (isVideoModeUsable), prepareVideoGenParams's backend short-circuit, and submitJob's dispatch.
  • Adds a fal.ai backend 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 the FAL_KEY env var).
  • Derives aspect_ratio from width/height (nearest of 16:9/9:16/1:1) when not explicitly supplied, same as the existing grok backend.
  • The API key is re-resolved from live settings inside the provider itself rather than threaded through job params, so it never rides data/media-jobs.json in plaintext.
  • Existing browser-automation fal.ai path in FableLoom (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.
  • New server/services/videoGen/fal.test.js covers key resolution precedence (settings > FAL_KEY env, 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 mocked fetch.
  • Two rounds of local review (opencode) against the branch diff; all findings from round 1 fixed and confirmed resolved in round 2.

Closes #6213

…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.
@atomantic
atomantic merged commit 6adfe6d into main Sep 4, 2026
16 of 24 checks passed
@atomantic
atomantic deleted the claim/issue-6213 branch September 4, 2026 07:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[repo-study-julius-caesar-fal-video-api] Add fal.ai video generator API provider to MediaGen and FableLoom

1 participant