Skip to content

armgit / fuobe

Public Imported from GitHub
0

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.

Catalog review: Grok routes take only their own values, frame counts, API limits, Bria Expand

Claudef59ded73817e
diff --git a/scripts/gen-cloud-models.py b/scripts/gen-cloud-models.py
index a31c27e3..75f1dfcc 100644
--- a/scripts/gen-cloud-models.py
+++ b/scripts/gen-cloud-models.py
@@ -56,16 +56,19 @@ M = []
def model(id, name, vendor, family, kind, tagline, routes, badges=None, pricing=None, defaults=None, options=None, fixed=None, hidden=False,
- sliders=None, controls=None, api_defaults=None, formats=None, ranged_durations=False):
+ sliders=None, controls=None, api_defaults=None, formats=None, ranged_durations=False, fit_values=False):
"""sliders / controls: [(field, label)] read from each route's research inputs (dotted = nested field):
numeric fields with minimum/maximum become sliders, enums become composer controls; both travel as params.extra.
fixed: fields always sent. api_defaults: fields sent unless the request sets them (FieldMap.defaults).
formats: {canonical VideoFormat: the API's value} for its output-format field (params.format), checked against the enum.
- ranged_durations: a duration that takes any whole second in a range gets the usual picks inside it."""
+ ranged_durations: a duration that takes any whole second in a range gets the usual picks inside it.
+ fit_values: the model offers the union of its routes' aspect ratios and resolutions, so each route lists the
+ ones it takes (EnumField.accepts) and gets the closest of them (Grok Imagine on fal and Higgsfield).
+ A route's options dict may also set max_images (FieldMap.maxImages) and note."""
M.append(dict(id=id, name=name, vendor=vendor, family=family, kind=kind, tagline=tagline, routes=routes,
badges=badges or [], pricing=pricing, defaults=defaults or {}, options=options or {}, fixed=fixed or {}, hidden=hidden,
sliders=sliders or [], controls=controls or [], api_defaults=api_defaults or {}, formats=formats or {},
- ranged_durations=ranged_durations))
+ ranged_durations=ranged_durations, fit_values=fit_values))
# ----- Image
@@ -604,14 +607,17 @@ model("bria-video-erase-mask", "Bria Video Eraser · mask video", "Bria", "bria"
[("remove-object", "bria/video/erase/mask"), ("remove-object", "bria/video-erase-object", "replicate", {"fixed": {"auto_trim": True}})],
pricing=("second", 0.14, "fal; $0.05/s on Replicate"), hidden=True,
options={"requires": {"mask": True, "msg": "Add the mask video (white = what to remove)"}})
-model("void-video-inpainting", "VOID Video Eraser", "fal", "void", "video",
+# Netflix's VOID (Apache-2.0 weights on a CogVideoX base, comfyui-oss-4.md), hosted by fal.
+model("void-video-inpainting", "VOID Video Eraser", "Netflix", "void", "video",
"Removes an object and what it causes — shadows, reflections, ripples — from clips up to ~8 s",
- [("remove-object", "fal-ai/void-video-inpainting", "fal", {"drop": ["mask"]})], badges=["new"],
+ [("remove-object", "fal-ai/void-video-inpainting", "fal",
+ {"drop": ["mask"], "note": "Up to 197 frames (about 8 s at 24 fps): split longer clips"})], badges=["new"],
pricing=("request", 0.1, "$0.05 per clip + $0.05 for the mask made from your words; Pass 2 refinement doubles the first part; up to 197 frames"),
api_defaults={"prompt": SCENE_AFTER_REMOVAL})
model("ltx-2-3-clean-plate", "LTX 2.3 Clean Plate", "Lightricks", "ltx", "video",
"Removes every person from a shot for a clean background plate",
- [("remove-object", "fal-ai/ltx-2.3-quality/clean-plate", "fal", {"drop": ["prompt"]})],
+ # "720p allows up to ~6s, 480p up to ~15s. A request above the budget is rejected" (num_frames from the clip's length).
+ [("remove-object", "fal-ai/ltx-2.3-quality/clean-plate", "fal", {"drop": ["prompt"], "note": "720p up to about 6 s, 480p up to about 15 s"})],
pricing=("video", 0.27, "121 frames at 720p; billed per megapixel of video"), defaults={"resolution": "720p"})
# Hosted Wan 2.2 VACE Fun: the painted first-frame mask is tracked through the clip (mask_image_url). Erase with a
# description of the background (SCENE_AFTER_REMOVAL unless params.extra.prompt says otherwise); swap and insert
@@ -622,7 +628,9 @@ model("wan-22-vace-inpaint", "Wan 2.2 VACE Fun Inpaint (hosted)", "Alibaba Wan",
"Paint an area on the first frame: erase it, or swap or add something from a reference image",
[("remove-object", _VACE, "fal", {**_VACE_KEYS, "drop": ["image", "endImage", "images", "prompt"], "defaults": {"prompt": SCENE_AFTER_REMOVAL}}),
("video-swap", _VACE, "fal", _VACE_KEYS), ("video-insert", _VACE, "fal", _VACE_KEYS)],
- pricing=("second", 0.1, "720p, counted at 16 fps; 580p $0.075, 480p $0.05", {"byResolution": {"720p": 0.1, "580p": 0.075, "480p": 0.05}}),
+ # "Video seconds calculated at 16 frames per second": the clip keeps its own frame rate, so a 30 fps clip bills ~1.9x its length.
+ pricing=("second", 0.1, "720p, billed as frames ÷ 16 (a 30 fps clip costs about 1.9× its length); 580p $0.075, 480p $0.05",
+ {"byResolution": {"720p": 0.1, "580p": 0.075, "480p": 0.05}}),
api_defaults={"match_input_num_frames": True, "match_input_frames_per_second": True},
options={"requires": {"mask": True, "msg": "Paint the area to change on the first frame"}})
# The mask maker for the erase and swap chains: what you name or click becomes a black-and-white mask video
@@ -649,7 +657,7 @@ model("topaz-fps-boost", "Topaz FPS Boost", "Topaz Labs", "topaz", "video",
api_defaults={"H264_output": True}, controls=[("model", "Model")])
# Doubles the frame rate (one new frame per pair) at the clip's own speed; its fps field only applies with
# use_calculated_fps off, so a target frame rate is not sent.
-model("rife-video-cloud", "RIFE (hosted)", "fal", "rife", "video",
+model("rife-video-cloud", "RIFE (hosted)", "Open source", "rife", "video",
"Cheap frame interpolation: twice the frames, same speed",
[("interpolate", "fal-ai/rife/video", "fal", {"drop": ["fps"]})], badges=["fast"], pricing=("request", 0.001, "billed per compute second ($0.0013/s)"))
model("topaz-sdr-to-hdr", "Topaz SDR to HDR", "Topaz Labs", "topaz", "video",
@@ -718,10 +726,11 @@ model("heygen-video", "HeyGen Video", "HeyGen", "heygen", "video",
pricing=("second", 0.02, "480p and 768p; 1080p and 2K $0.06", {"byResolution": {"480p": 0.02, "768p": 0.02, "1080p": 0.06, "2k": 0.06}}),
controls=[("prompt_enhancement", "Prompt boost")])
# Higgsfield offers Grok Imagine Video 1.5 too (its Higgsfield route is added by gen-higgsfield-models.py).
+# Its routes take different values (fal's reference-to-video stops at 720p), so each lists its own (fit_values).
model("grok-imagine-video-1-5", "Grok Imagine Video 1.5", "xAI", "grok", "video", "xAI's video model with references and audio",
[("t2v", "xai/grok-imagine-video/v1.5/text-to-video"), ("i2v", "xai/grok-imagine-video/v1.5/image-to-video"),
("ref2v", "xai/grok-imagine-video/v1.5/reference-to-video")],
- defaults={"aspectRatio": "16:9", "duration": 6, "resolution": "720p"}, ranged_durations=True,
+ defaults={"aspectRatio": "16:9", "duration": 6, "resolution": "720p"}, ranged_durations=True, fit_values=True,
pricing=("second", 0.14, "720p; 480p $0.08, 1080p $0.25; +$0.01 per input image", {"byResolution": {"480p": 0.08, "720p": 0.14, "1080p": 0.25}}))
model("grok-imagine-video-1-5-lite", "Grok Imagine Video 1.5 Lite", "xAI", "grok", "video", "One of the cheapest 720p video models, 1–15 s",
[("t2v", "xai/grok-imagine-video/v1.5/lite/text-to-video"), ("i2v", "xai/grok-imagine-video/v1.5/lite/image-to-video")],
@@ -767,13 +776,15 @@ model("krea-3", "Krea 3", "Krea", "krea", "image", "Krea's new image model — g
# Both APIs take up to 8 images.
options={"maxImages": 8})
# Higgsfield offers Grok Imagine Image 2.0 too (its Higgsfield route is added by gen-higgsfield-models.py).
+# fal's text-to-image has no "auto" and Higgsfield no 20:9 / 19.5:9 / 9:19.5 / 9:20: each route lists what it takes (fit_values).
model("grok-imagine-image-2", "Grok Imagine Image 2.0", "xAI", "grok", "image", "xAI's image model — bold, fast, few refusals",
- [("t2i", "xai/grok-imagine-image/v2.0/text-to-image"), ("edit", "xai/grok-imagine-image/v2.0/edit")],
- defaults={"aspectRatio": "1:1", "resolution": "1k"},
- pricing=("image", 0.06, "1K medium; low $0.04; 2K $0.06–0.08; +$0.01 per input image", {"byResolution": {"1k": 0.06, "2k": 0.08}}),
- # fal's edit takes "a maximum of 5 images" (Higgsfield's route 10).
- controls=[("quality", "Quality")], options={"maxImages": 5})
-model("bria-fibo-2", "Bria FIBO 2", "Bria", "bria", "image", "Trained on licensed data only — safe for commercial work, with structured prompts",
+ # fal's edit takes "a maximum of 5 images"; Higgsfield's route takes 10, so a run with more than 5 goes there.
+ [("t2i", "xai/grok-imagine-image/v2.0/text-to-image"), ("edit", "xai/grok-imagine-image/v2.0/edit", "fal", {"max_images": 5})],
+ defaults={"aspectRatio": "1:1", "resolution": "1k"}, fit_values=True,
+ pricing=("image", 0.06, "1K medium on fal; low $0.04; 2K $0.06–0.08; +$0.01 per input image; Higgsfield $0.04 (1K) / $0.08 (2K)",
+ {"byResolution": {"1k": 0.06, "2k": 0.08}}),
+ controls=[("quality", "Quality")], options={"maxImages": 10})
+model("bria-fibo-2", "Bria FIBO 2", "Bria", "bria", "image", "Structured prompts; Bria says it is trained on licensed data only",
[("t2i", "bria/fibo-2/generate"), ("edit", "bria/fibo-2/edit")], badges=["new"], defaults={"aspectRatio": "1:1"})
model("ideogram-vector", "Ideogram Vector", "Ideogram", "ideogram", "image", "Editable SVGs from a prompt, or any image traced to SVG",
[("t2i", "ideogram/vector/text-to-vector"), ("vectorize", "ideogram/vector/image-to-vector")], badges=["new"],
@@ -782,7 +793,9 @@ model("ideogram-vector", "Ideogram Vector", "Ideogram", "ideogram", "image", "Ed
# Its negative_prompt is refused, not ignored: never sent.
model("bria-expand", "Bria Expand", "Bria", "bria", "image", "Extend a picture to a new aspect ratio, edges filled to match",
# Words for the new area are optional ("Omit it and the model is asked only to extend the image").
- [("outpaint", "bria/fibo-edit-1.5/expand", "fal", {"drop": ["negativePrompt"]})], badges=["new"], options={"promptOptional": True})
+ # It needs a target shape (aspect_ratio or canvas_size): a run without one widens to 16:9.
+ [("outpaint", "bria/fibo-edit-1.5/expand", "fal", {"drop": ["negativePrompt"]})], badges=["new"], options={"promptOptional": True},
+ defaults={"aspectRatio": "16:9"})
# ----- New speech models
model("heygen-voice-turbo", "HeyGen Voice Turbo", "HeyGen", "heygen", "audio", "24 voices or an instant clone of yours, in 39 languages, for almost nothing",
@@ -911,7 +924,7 @@ def map_fields(fmap):
for k, v in fmap.items():
if k in ("fixed", "defaults"):
out += list(v)
- elif k in ("seedRange", "maskFormat"):
+ elif k in ("seedRange", "maskFormat", "ranges", "ignore", "maxImages", "omitEmptyPrompt"):
continue
elif isinstance(v, str):
out.append(v)
@@ -931,6 +944,11 @@ def enum_of(inputs, key):
return [v for v in ((inputs.get(key) or {}).get("values") or [])]
+# Operations research part 4 added (their numeric fields get FieldMap.ranges).
+ROUND4_OPS = ("remove-object", "video-swap", "video-insert", "keyframes", "sdr-to-hdr", "export-video", "ocr", "still-motion", "audio-loop",
+ "audio-join", "scene-3d", "splat", "text-to-3d", "rig-3d", "extract-frames", "images-to-video", "overlay")
+
+
def part4_slots(op, kf, inputs, m, opts, fmap):
"""Research part 4 slots, each read only for the operations it belongs to (parts 2-3 use some of the same
names: Qwen angles' "zoom", Luma's and Runway's "keyframes")."""
@@ -1013,6 +1031,38 @@ def part4_slots(op, kf, inputs, m, opts, fmap):
if "animation" in kf:
flag = next((k for k, v in inputs.items() if k.startswith("enable_") and "animation" in k and (v or {}).get("type") == "boolean"), None)
fmap["animation"] = {"key": kf["animation"], **({"flag": flag} if flag else {})}
+ # Routes that render only as many frames as asked (LTX 2.3 clean plate / HDR: "Output duration is num_frames /
+ # frames_per_second"; VOID's window): the frame count follows the clip's length. VACE matches the input itself.
+ if "numFrames" in kf and op in ("remove-object", "sdr-to-hdr", "video-swap", "video-insert") and "match_input_num_frames" not in inputs:
+ spec = inputs.get(kf["numFrames"]) or {}
+ fps_spec = inputs.get(kf.get("fps", "")) or {}
+ # VOID has no frame-rate field: its frame budget is read at 24 fps ("about 8 s at 24 fps", research part 4).
+ fps = num(fps_spec.get("default")) or 24
+ fmap["numFrames"] = {"key": kf["numFrames"], "fps": fps,
+ **{k: num(spec[f]) for k, f in (("min", "minimum"), ("max", "maximum")) if num(spec.get(f)) is not None}}
+
+
+def part4_ranges(op, inputs, fmap):
+ """The API's limits on the numbers Fuobe fills for the round-4 tools (FieldMap.ranges): rounded and kept inside them."""
+ fields = [fmap.get(k) for k in ("targetFps", "slowdown", "frameInterval", "crossfade")]
+ fields += [(fmap.get(k) or {}).get(f) for k, f in (("scale", "key"), ("position", "x"), ("position", "y"), ("zoom", "x"), ("zoom", "y"), ("animation", "key"))]
+ if op in ROUND4_OPS:
+ fields += [fmap.get("fps"), (fmap.get("duration") or {}).get("key")]
+ ranges = {}
+ for f in fields:
+ spec = inputs.get(f) if isinstance(f, str) else None
+ if not spec or spec.get("type") not in ("integer", "number"):
+ continue
+ lo, hi = num(spec.get("minimum")), num(spec.get("maximum"))
+ # Meshy states its preset range in words: "it must be in [0, 696]".
+ stated = re.search(r"\[(\d+),\s*(\d+)\]", spec.get("desc") or "")
+ if lo is None and hi is None and stated:
+ lo, hi = num(stated[1]), num(stated[2])
+ r = {**({"min": lo} if lo is not None else {}), **({"max": hi} if hi is not None else {}), **({"integer": True} if spec["type"] == "integer" else {})}
+ if r:
+ ranges[f] = r
+ if ranges:
+ fmap["ranges"] = ranges
def build_route(op, ep, provider, m, opts, ropts=None):
@@ -1073,6 +1123,12 @@ def build_route(op, ep, provider, m, opts, ropts=None):
# Swaps whose references say what goes in may also take words (P-Video Replace's instruction): optional.
elif op in ("video-swap", "video-insert") and "prompt" in kf and not (inputs.get(kf["prompt"]) or {}).get("required"):
opts["promptOptional"] = True
+ # A model that runs without words leaves an empty prompt out where the API's prompt is optional
+ # (Bria Expand: "Omit it and the model is asked only to extend the image").
+ pkey = fmap.get("prompt", "prompt" if "prompt" in kf else None)
+ if pkey and (m["options"].get("promptOptional") or (op in ("video-swap", "video-insert") and opts.get("promptOptional"))) \
+ and not (inputs.get(pkey.split(".")[0]) or {}).get("required"):
+ fmap["omitEmptyPrompt"] = True
# Zero-shot TTS takes its reference voice in the "audio" field; voice conversion names it separately.
if op == "tts" and "audio" in kf:
kf["referenceVoice"] = kf.pop("audio")
@@ -1206,6 +1262,8 @@ def build_route(op, ep, provider, m, opts, ropts=None):
ratios = [v for v in enum if RATIO.match(str(v)) or v == "auto"]
if not ratios and spec.get("type") == "string":
ratios = ["16:9", "9:16", "1:1"] if m["kind"] == "video" else IMG_AR
+ elif m.get("fit_values") and ratios:
+ fmap["aspectRatio"] = {"key": key, "accepts": ratios}
opts["aspectRatios"] = union(opts.get("aspectRatios", []), ratios)
# Resolution
if "resolution" in kf:
@@ -1215,6 +1273,8 @@ def build_route(op, ep, provider, m, opts, ropts=None):
if enum and (inputs.get(key) or {}).get("valueType") in ("integer", "number"):
# Numeric tiers (TRELLIS 512/1024/1536) are picked as strings and sent as numbers.
fmap["resolution"] = {"key": key, "values": {str(v): v for v in enum}}
+ elif enum and m.get("fit_values"):
+ fmap["resolution"] = {"key": key, "accepts": [str(v) for v in enum]}
opts["resolutions"] = union(opts.get("resolutions", []), [str(v) for v in enum])
# Duration
if "duration" in kf:
@@ -1243,6 +1303,7 @@ def build_route(op, ep, provider, m, opts, ropts=None):
opts["durations"] = union(opts.get("durations", []), [v for v in NICE_DURATIONS if lo <= v <= hi] or [lo])
if key.endswith("_ms"):
fmap["duration"]["multiplier"] = 1000
+ part4_ranges(op, inputs, fmap)
# Text-to-speech etc. carry the prompt in "text".
if ropts.get("fixed"):
m = {**m, "fixed": {**m["fixed"], **ropts["fixed"]}}
@@ -1279,6 +1340,9 @@ def build_route(op, ep, provider, m, opts, ropts=None):
if "images" in fmap:
mx = num((inputs.get(fmap["images"]) or {}).get("maxItems")) or None
opts["maxImages"] = max(opts.get("maxImages", 1), mx or (10 if op == "edit" else 4))
+ # A route that takes fewer than the model's other routes (stated in its docs, not its schema).
+ if ropts.get("max_images"):
+ fmap["maxImages"] = ropts["max_images"]
elif "image" in fmap:
opts["maxImages"] = max(opts.get("maxImages", 0), 2 if "image2" in fmap else 1)
# Inpaint routes say what the mask's paint means (edit routes get theirs when the inpaint route is derived).
@@ -1340,6 +1404,14 @@ for m in M:
if all(r["map"].get("prompt") is False for r in routes):
opts["promptless"] = True
opts.update(m["options"])
+ # A model-wide control or slider goes only to the routes whose schema has its field (Ideogram Vector's
+ # quality is a text-to-vector setting; image-to-vector has none).
+ offered = [c["param"] for c in opts.get("controls", [])] + [x["param"] for x in opts.get("sliders", [])]
+ for route in routes:
+ inputs = (EPS.get((route["provider"], route["endpoint"])) or {}).get("inputs") or {}
+ missing = [x for x in offered if x.split(".")[0] not in inputs]
+ if missing:
+ route["map"] = {**route["map"], "ignore": missing}
pricing = None
if m["pricing"]:
u, usd, *rest = m["pricing"]
diff --git a/scripts/gen-higgsfield-models.py b/scripts/gen-higgsfield-models.py
index 882a5fa8..f0939fa8 100644
--- a/scripts/gen-higgsfield-models.py
+++ b/scripts/gen-higgsfield-models.py
@@ -49,8 +49,9 @@ def field_map(op, ep, inputs, opts):
if "prompt" not in inputs:
fm["prompt"] = False
elif op in ("video-swap", "video-insert") and not inputs["prompt"].get("required"):
- # The references say what goes in; words are optional (Genjutsu object swap).
+ # The references say what goes in; words are optional (Genjutsu object swap), and an empty prompt is left out.
opts["promptOptional"] = True
+ fm["omitEmptyPrompt"] = True
pick = lambda *names: next((n for n in names if n in inputs), None) # noqa: E731
img = pick("image_url", "first_frame_url")
imgs = "image_urls" if "image_urls" in inputs else None
@@ -165,17 +166,32 @@ def price(ep, default_res=None):
return {"unit": p["unit"], "usd": usd, "note": "Higgsfield list price"} if usd else None
-def routes_for(spec, opts):
+def routes_for(spec, opts, fit=False):
+ """spec: (op, endpoint) or (op, endpoint, {drop: [canonical keys], accepts: {aspectRatio | resolution: [values]}}).
+ fit: the model's aspect ratios and resolutions come from its fal routes, so each route lists the ones it
+ takes (EnumField.accepts) and gets the closest of them."""
out = []
for r in spec:
op, ep = r[0], r[1]
+ ro = r[2] if len(r) > 2 else {}
if ep not in EPS:
warn(f"{ep} not in research")
continue
e = EPS[ep]
if not e.get("verified"):
warn(f"{ep} not verified")
- fm = field_map(op, ep, e.get("inputs") or {}, opts)
+ inputs = e.get("inputs") or {}
+ fm = field_map(op, ep, inputs, opts)
+ for k in ro.get("drop") or []:
+ fm.pop(k, None)
+ if fit:
+ for canon, field in (("aspectRatio", "aspect_ratio"), ("resolution", "resolution")):
+ if fm.get(canon) != field:
+ continue
+ vals = (ro.get("accepts") or {}).get(canon) or [
+ str(v) for v in inputs[field].get("enum", []) if canon == "resolution" or RATIO.match(str(v)) or v == "auto"]
+ if vals:
+ fm[canon] = {"key": field, "accepts": vals}
out.append({"op": op, "provider": "higgsfield", "endpoint": ep, "map": fm})
if op == "i2v" and "endImage" in fm:
out.append({"op": "flf2v", "provider": "higgsfield", "endpoint": ep, "map": fm})
@@ -265,12 +281,19 @@ EXTRA = {
"z-image-turbo-cloud": [("t2i", "z-image/turbo")],
"recraft-4-1": [("t2i", "recraft/v4.1/text-to-image")],
"recraft-4-1-pro": [("t2i", "recraft/v4.1/pro/text-to-image")],
- # Grok Imagine on fal since round 4 (gen-cloud-models.py); Higgsfield is the second route.
- "grok-imagine-video-1-5": [("t2v", "xai/grok-imagine-video/v1.5/reference-to-video"), ("i2v", "xai/grok-imagine-video/v1.5/reference-to-video"),
- ("ref2v", "xai/grok-imagine-video/v1.5/reference-to-video")],
+ # Grok Imagine on fal since round 4 (gen-cloud-models.py); Higgsfield is the second route. "Choose either image_url
+ # or reference media (image_urls/audio_url); do not combine these modes", and "when image_urls or audio_url is
+ # provided, resolution must be 480p or 720p" (the shared schema lists 1080p).
+ "grok-imagine-video-1-5": [("t2v", "xai/grok-imagine-video/v1.5/reference-to-video"),
+ ("i2v", "xai/grok-imagine-video/v1.5/reference-to-video", {"drop": ["images"]}),
+ ("ref2v", "xai/grok-imagine-video/v1.5/reference-to-video",
+ {"drop": ["image"], "accepts": {"resolution": ["480p", "720p"]}})],
"grok-imagine-image-2": [("t2i", "xai/grok-imagine-image-2.0"), ("edit", "xai/grok-imagine-image-2.0")],
}
+# Models whose fal and Higgsfield routes take different aspect ratios or resolutions (see routes_for's fit).
+FIT = {"grok-imagine-video-1-5", "grok-imagine-image-2"}
+
models = []
for m in EXCLUSIVE:
opts = {}
@@ -294,7 +317,7 @@ extra = {}
for mid, spec in EXTRA.items():
opts = {}
# The model keeps its own enums and controls: Higgsfield-only fields would break its fal routes.
- extra[mid] = routes_for(spec, opts)
+ extra[mid] = routes_for(spec, opts, fit=mid in FIT)
out = ROOT / "src/lib/catalog/higgsfield-models.generated.ts"
out.write_text(
diff --git a/src/lib/catalog/cloud-models.generated.ts b/src/lib/catalog/cloud-models.generated.ts
index 369767f8..ff6affab 100644
--- a/src/lib/catalog/cloud-models.generated.ts
+++ b/src/lib/catalog/cloud-models.generated.ts
@@ -2072,7 +2072,10 @@ export const CLOUD_MODELS: ModelDef[] = [
"5:4": "landscape_4_3",
"4:5": "portrait_4_3"
}
- }
+ },
+ "ignore": [
+ "strength"
+ ]
}
},
{
@@ -2102,7 +2105,10 @@ export const CLOUD_MODELS: ModelDef[] = [
"5:4": "landscape_4_3",
"4:5": "portrait_4_3"
}
- }
+ },
+ "ignore": [
+ "style_preset"
+ ]
}
},
{
@@ -2114,7 +2120,11 @@ export const CLOUD_MODELS: ModelDef[] = [
"mask": "mask_url",
"numOutputs": "num_images",
"seed": "seed",
- "maskFormat": "black"
+ "maskFormat": "black",
+ "ignore": [
+ "style",
+ "strength"
+ ]
}
}
],
@@ -12007,7 +12017,7 @@ export const CLOUD_MODELS: ModelDef[] = [
{
"id": "void-video-inpainting",
"name": "VOID Video Eraser",
- "vendor": "fal",
+ "vendor": "Netflix",
"family": "void",
"engine": "cloud",
"kind": "video",
@@ -12022,10 +12032,17 @@ export const CLOUD_MODELS: ModelDef[] = [
"negativePrompt": "negative_prompt",
"video": "video_url",
"seed": "seed",
+ "numFrames": {
+ "key": "num_frames",
+ "fps": 24,
+ "min": 1,
+ "max": 197
+ },
"defaults": {
"prompt": "The same shot with nothing there: the background continues naturally, matching the light, texture and motion around it"
}
- }
+ },
+ "note": "Up to 197 frames (about 8 s at 24 fps): split longer clips"
}
],
"options": {
@@ -12071,8 +12088,21 @@ export const CLOUD_MODELS: ModelDef[] = [
"seed": "seed",
"generateAudio": "generate_audio",
"fps": "frames_per_second",
- "resolution": "resolution"
- }
+ "numFrames": {
+ "key": "num_frames",
+ "fps": 24,
+ "min": 9,
+ "max": 481
+ },
+ "resolution": "resolution",
+ "ranges": {
+ "frames_per_second": {
+ "min": 1,
+ "max": 60
+ }
+ }
+ },
+ "note": "720p up to about 6 s, 480p up to about 15 s"
}
],
"options": {
@@ -12117,6 +12147,13 @@ export const CLOUD_MODELS: ModelDef[] = [
"fps": "frames_per_second",
"aspectRatio": "aspect_ratio",
"resolution": "resolution",
+ "ranges": {
+ "frames_per_second": {
+ "min": 5,
+ "max": 30,
+ "integer": true
+ }
+ },
"defaults": {
"match_input_num_frames": true,
"match_input_frames_per_second": true,
@@ -12137,6 +12174,13 @@ export const CLOUD_MODELS: ModelDef[] = [
"fps": "frames_per_second",
"aspectRatio": "aspect_ratio",
"resolution": "resolution",
+ "ranges": {
+ "frames_per_second": {
+ "min": 5,
+ "max": 30,
+ "integer": true
+ }
+ },
"defaults": {
"match_input_num_frames": true,
"match_input_frames_per_second": true
@@ -12156,6 +12200,13 @@ export const CLOUD_MODELS: ModelDef[] = [
"fps": "frames_per_second",
"aspectRatio": "aspect_ratio",
"resolution": "resolution",
+ "ranges": {
+ "frames_per_second": {
+ "min": 5,
+ "max": 30,
+ "integer": true
+ }
+ },
"defaults": {
"match_input_num_frames": true,
"match_input_frames_per_second": true
@@ -12189,7 +12240,7 @@ export const CLOUD_MODELS: ModelDef[] = [
"pricing": {
"unit": "second",
"usd": 0.1,
- "note": "720p, counted at 16 fps; 580p $0.075, 480p $0.05",
+ "note": "720p, billed as frames \u00f7 16 (a 30 fps clip costs about 1.9\u00d7 its length); 580p $0.075, 480p $0.05",
"byResolution": {
"720p": 0.1,
"580p": 0.075,
@@ -12245,6 +12296,7 @@ export const CLOUD_MODELS: ModelDef[] = [
"endpoint": "prunaai/p-video-replace",
"map": {
"prompt": "instruction_prompt",
+ "omitEmptyPrompt": true,
"images": "images",
"video": "video",
"seed": "seed",
@@ -12295,6 +12347,18 @@ export const CLOUD_MODELS: ModelDef[] = [
"video": "video_url",
"slowdown": "slowdown_factor",
"targetFps": "target_fps",
+ "ranges": {
+ "target_fps": {
+ "min": 16,
+ "max": 120,
+ "integer": true
+ },
+ "slowdown_factor": {
+ "min": 1,
+ "max": 8,
+ "integer": true
+ }
+ },
"defaults": {
"H264_output": true
}
@@ -12328,7 +12392,7 @@ export const CLOUD_MODELS: ModelDef[] = [
{
"id": "rife-video-cloud",
"name": "RIFE (hosted)",
- "vendor": "fal",
+ "vendor": "Open source",
"family": "rife",
"engine": "cloud",
"kind": "video",
@@ -12418,6 +12482,18 @@ export const CLOUD_MODELS: ModelDef[] = [
"seed": "seed",
"generateAudio": "generate_audio",
"fps": "frames_per_second",
+ "numFrames": {
+ "key": "num_frames",
+ "fps": 24,
+ "min": 9,
+ "max": 481
+ },
+ "ranges": {
+ "frames_per_second": {
+ "min": 1,
+ "max": 60
+ }
+ },
"defaults": {
"prompt": "The same shot in high dynamic range: deeper shadows and brighter highlights, every detail and movement unchanged"
}
@@ -12481,6 +12557,25 @@ export const CLOUD_MODELS: ModelDef[] = [
"duration": {
"key": "duration",
"type": "number"
+ },
+ "ranges": {
+ "zoom_x": {
+ "min": 0,
+ "max": 100
+ },
+ "zoom_y": {
+ "min": 0,
+ "max": 100
+ },
+ "frames_per_second": {
+ "min": 24,
+ "max": 60,
+ "integer": true
+ },
+ "duration": {
+ "min": 1,
+ "max": 30
+ }
}
}
}
@@ -12521,6 +12616,20 @@ export const CLOUD_MODELS: ModelDef[] = [
"scale": {
"key": "scale_percent",
"multiplier": 100
+ },
+ "ranges": {
+ "scale_percent": {
+ "min": 25,
+ "max": 200
+ },
+ "x_percent": {
+ "min": 0,
+ "max": 100
+ },
+ "y_percent": {
+ "min": 0,
+ "max": 100
+ }
}
}
}
@@ -12558,6 +12667,13 @@ export const CLOUD_MODELS: ModelDef[] = [
"prompt": false,
"video": "video_url",
"frameInterval": "frame_interval",
+ "ranges": {
+ "frame_interval": {
+ "min": 1,
+ "max": 300,
+ "integer": true
+ }
+ },
"defaults": {
"max_frames": 500
}
@@ -12594,6 +12710,12 @@ export const CLOUD_MODELS: ModelDef[] = [
"key": "images",
"url": "url",
"frames": "frames"
+ },
+ "ranges": {
+ "fps": {
+ "min": 1,
+ "max": 120
+ }
}
}
}
@@ -12873,6 +12995,13 @@ export const CLOUD_MODELS: ModelDef[] = [
"animation": {
"key": "animation_action_id",
"flag": "enable_animation"
+ },
+ "ranges": {
+ "animation_action_id": {
+ "min": 0,
+ "max": 696,
+ "integer": true
+ }
}
}
}
@@ -13168,8 +13297,26 @@ export const CLOUD_MODELS: ModelDef[] = [
"provider": "fal",
"endpoint": "xai/grok-imagine-video/v1.5/text-to-video",
"map": {
- "aspectRatio": "aspect_ratio",
- "resolution": "resolution",
+ "aspectRatio": {
+ "key": "aspect_ratio",
+ "accepts": [
+ "16:9",
+ "4:3",
+ "3:2",
+ "1:1",
+ "2:3",
+ "3:4",
+ "9:16"
+ ]
+ },
+ "resolution": {
+ "key": "resolution",
+ "accepts": [
+ "480p",
+ "720p",
+ "1080p"
+ ]
+ },
"duration": {
"key": "duration",
"type": "number"
@@ -13182,7 +13329,14 @@ export const CLOUD_MODELS: ModelDef[] = [
"endpoint": "xai/grok-imagine-video/v1.5/image-to-video",
"map": {
"image": "image_url",
- "resolution": "resolution",
+ "resolution": {
+ "key": "resolution",
+ "accepts": [
+ "480p",
+ "720p",
+ "1080p"
+ ]
+ },
"duration": {
"key": "duration",
"type": "number"
@@ -13195,8 +13349,25 @@ export const CLOUD_MODELS: ModelDef[] = [
"endpoint": "xai/grok-imagine-video/v1.5/reference-to-video",
"map": {
"images": "reference_image_urls",
- "aspectRatio": "aspect_ratio",
- "resolution": "resolution",
+ "aspectRatio": {
+ "key": "aspect_ratio",
+ "accepts": [
+ "16:9",
+ "4:3",
+ "3:2",
+ "1:1",
+ "2:3",
+ "3:4",
+ "9:16"
+ ]
+ },
+ "resolution": {
+ "key": "resolution",
+ "accepts": [
+ "480p",
+ "720p"
+ ]
+ },
"duration": {
"key": "duration",
"type": "number"
@@ -13609,6 +13780,7 @@ export const CLOUD_MODELS: ModelDef[] = [
"provider": "fal",
"endpoint": "pixelcut/looping-video",
"map": {
+ "omitEmptyPrompt": true,
"image": "image_url",
"generateAudio": "include_audio",
"resolution": "resolution",
@@ -13899,8 +14071,31 @@ export const CLOUD_MODELS: ModelDef[] = [
"endpoint": "xai/grok-imagine-image/v2.0/text-to-image",
"map": {
"numOutputs": "num_images",
- "aspectRatio": "aspect_ratio",
- "resolution": "resolution"
+ "aspectRatio": {
+ "key": "aspect_ratio",
+ "accepts": [
+ "2:1",
+ "20:9",
+ "19.5:9",
+ "16:9",
+ "4:3",
+ "3:2",
+ "1:1",
+ "2:3",
+ "3:4",
+ "9:16",
+ "9:19.5",
+ "9:20",
+ "1:2"
+ ]
+ },
+ "resolution": {
+ "key": "resolution",
+ "accepts": [
+ "1k",
+ "2k"
+ ]
+ }
}
},
{
@@ -13910,8 +14105,33 @@ export const CLOUD_MODELS: ModelDef[] = [
"map": {
"images": "image_urls",
"numOutputs": "num_images",
- "aspectRatio": "aspect_ratio",
- "resolution": "resolution"
+ "aspectRatio": {
+ "key": "aspect_ratio",
+ "accepts": [
+ "auto",
+ "2:1",
+ "20:9",
+ "19.5:9",
+ "16:9",
+ "4:3",
+ "3:2",
+ "1:1",
+ "2:3",
+ "3:4",
+ "9:16",
+ "9:19.5",
+ "9:20",
+ "1:2"
+ ]
+ },
+ "resolution": {
+ "key": "resolution",
+ "accepts": [
+ "1k",
+ "2k"
+ ]
+ },
+ "maxImages": 5
}
}
],
@@ -13948,7 +14168,7 @@ export const CLOUD_MODELS: ModelDef[] = [
"2k"
],
"maxOutputs": 4,
- "maxImages": 5
+ "maxImages": 10
},
"defaults": {
"aspectRatio": "1:1",
@@ -13957,7 +14177,7 @@ export const CLOUD_MODELS: ModelDef[] = [
"pricing": {
"unit": "image",
"usd": 0.06,
- "note": "1K medium; low $0.04; 2K $0.06\u20130.08; +$0.01 per input image",
+ "note": "1K medium on fal; low $0.04; 2K $0.06\u20130.08; +$0.01 per input image; Higgsfield $0.04 (1K) / $0.08 (2K)",
"byResolution": {
"1k": 0.06,
"2k": 0.08
@@ -13971,7 +14191,7 @@ export const CLOUD_MODELS: ModelDef[] = [
"family": "bria",
"engine": "cloud",
"kind": "image",
- "tagline": "Trained on licensed data only \u2014 safe for commercial work, with structured prompts",
+ "tagline": "Structured prompts; Bria says it is trained on licensed data only",
"routes": [
{
"op": "t2i",
@@ -14071,7 +14291,10 @@ export const CLOUD_MODELS: ModelDef[] = [
"endpoint": "ideogram/vector/image-to-vector",
"map": {
"prompt": false,
- "image": "image_url"
+ "image": "image_url",
+ "ignore": [
+ "quality"
+ ]
}
}
],
@@ -14138,6 +14361,7 @@ export const CLOUD_MODELS: ModelDef[] = [
"provider": "fal",
"endpoint": "bria/fibo-edit-1.5/expand",
"map": {
+ "omitEmptyPrompt": true,
"image": "image_url",
"seed": "seed",
"aspectRatio": "aspect_ratio"
@@ -14163,6 +14387,9 @@ export const CLOUD_MODELS: ModelDef[] = [
"badges": [
"new"
],
+ "defaults": {
+ "aspectRatio": "16:9"
+ },
"pricing": {
"unit": "image",
"usd": 0.04
diff --git a/src/lib/catalog/higgsfield-models.generated.ts b/src/lib/catalog/higgsfield-models.generated.ts
index 861ee287..c6bf58ec 100644
--- a/src/lib/catalog/higgsfield-models.generated.ts
+++ b/src/lib/catalog/higgsfield-models.generated.ts
@@ -651,6 +651,7 @@ export const HIGGSFIELD_MODELS: ModelDef[] = [
"provider": "higgsfield",
"endpoint": "higgsfield/genjutsu/object-swap/v1.0",
"map": {
+ "omitEmptyPrompt": true,
"images": "image_urls",
"video": "video_url",
"resolution": "resolution"
@@ -731,6 +732,7 @@ export const HIGGSFIELD_MODELS: ModelDef[] = [
"provider": "higgsfield",
"endpoint": "higgsfield/genjutsu-light/object-swap/v1.0",
"map": {
+ "omitEmptyPrompt": true,
"images": "image_urls",
"video": "video_url",
"resolution": "resolution"
@@ -1940,8 +1942,27 @@ export const HIGGSFIELD_ROUTES: Record<string, ModelRoute[]> = {
"provider": "higgsfield",
"endpoint": "xai/grok-imagine-video/v1.5/reference-to-video",
"map": {
- "aspectRatio": "aspect_ratio",
- "resolution": "resolution",
+ "aspectRatio": {
+ "key": "aspect_ratio",
+ "accepts": [
+ "auto",
+ "1:1",
+ "16:9",
+ "9:16",
+ "4:3",
+ "3:4",
+ "3:2",
+ "2:3"
+ ]
+ },
+ "resolution": {
+ "key": "resolution",
+ "accepts": [
+ "480p",
+ "720p",
+ "1080p"
+ ]
+ },
"duration": {
"key": "duration",
"type": "number"
@@ -1954,9 +1975,27 @@ export const HIGGSFIELD_ROUTES: Record<string, ModelRoute[]> = {
"endpoint": "xai/grok-imagine-video/v1.5/reference-to-video",
"map": {
"image": "image_url",
- "images": "image_urls",
- "aspectRatio": "aspect_ratio",
- "resolution": "resolution",
+ "aspectRatio": {
+ "key": "aspect_ratio",
+ "accepts": [
+ "auto",
+ "1:1",
+ "16:9",
+ "9:16",
+ "4:3",
+ "3:4",
+ "3:2",
+ "2:3"
+ ]
+ },
+ "resolution": {
+ "key": "resolution",
+ "accepts": [
+ "480p",
+ "720p",
+ "1080p"
+ ]
+ },
"duration": {
"key": "duration",
"type": "number"
@@ -1968,10 +2007,27 @@ export const HIGGSFIELD_ROUTES: Record<string, ModelRoute[]> = {
"provider": "higgsfield",
"endpoint": "xai/grok-imagine-video/v1.5/reference-to-video",
"map": {
- "image": "image_url",
"images": "image_urls",
- "aspectRatio": "aspect_ratio",
- "resolution": "resolution",
+ "aspectRatio": {
+ "key": "aspect_ratio",
+ "accepts": [
+ "auto",
+ "1:1",
+ "16:9",
+ "9:16",
+ "4:3",
+ "3:4",
+ "3:2",
+ "2:3"
+ ]
+ },
+ "resolution": {
+ "key": "resolution",
+ "accepts": [
+ "480p",
+ "720p"
+ ]
+ },
"duration": {
"key": "duration",
"type": "number"
@@ -1985,8 +2041,28 @@ export const HIGGSFIELD_ROUTES: Record<string, ModelRoute[]> = {
"provider": "higgsfield",
"endpoint": "xai/grok-imagine-image-2.0",
"map": {
- "aspectRatio": "aspect_ratio",
- "resolution": "resolution"
+ "aspectRatio": {
+ "key": "aspect_ratio",
+ "accepts": [
+ "auto",
+ "1:1",
+ "1:2",
+ "2:1",
+ "3:2",
+ "2:3",
+ "4:3",
+ "3:4",
+ "16:9",
+ "9:16"
+ ]
+ },
+ "resolution": {
+ "key": "resolution",
+ "accepts": [
+ "1k",
+ "2k"
+ ]
+ }
}
},
{
@@ -1995,8 +2071,28 @@ export const HIGGSFIELD_ROUTES: Record<string, ModelRoute[]> = {
"endpoint": "xai/grok-imagine-image-2.0",
"map": {
"images": "image_urls",
- "aspectRatio": "aspect_ratio",
- "resolution": "resolution"
+ "aspectRatio": {
+ "key": "aspect_ratio",
+ "accepts": [
+ "auto",
+ "1:1",
+ "1:2",
+ "2:1",
+ "3:2",
+ "2:3",
+ "4:3",
+ "3:4",
+ "16:9",
+ "9:16"
+ ]
+ },
+ "resolution": {
+ "key": "resolution",
+ "accepts": [
+ "1k",
+ "2k"
+ ]
+ }
}
}
]
diff --git a/src/lib/catalog/payload.ts b/src/lib/catalog/payload.ts
index 0e1e5492..01072ec7 100644
--- a/src/lib/catalog/payload.ts
+++ b/src/lib/catalog/payload.ts
@@ -6,6 +6,67 @@ function enumValue(field: string | EnumField, value: string): [string, unknown]
return [field.key, field.values && value in field.values ? field.values[value] : value];
}
+/** "16:9" → 16/9; undefined for "auto" and other names. */
+function ratioOf(v: string): number | undefined {
+ const m = /^(\d+(?:\.\d+)?):(\d+(?:\.\d+)?)$/.exec(v.trim());
+ return m && Number(m[2]) > 0 ? Number(m[1]) / Number(m[2]) : undefined;
+}
+
+/** "720p" → 720, "2k" / "4K" → 2000 / 4000: a size to order resolution tiers by. */
+function tierOf(v: string): number | undefined {
+ const m = /^(\d+(?:\.\d+)?)\s*([pk])$/i.exec(v.trim());
+ return m ? Number(m[1]) * (m[2].toLowerCase() === "k" ? 1000 : 1) : undefined;
+}
+
+/**
+ * The value a route takes for `value` (EnumField.accepts): the value itself (in any case), else the
+ * closest one it takes: the nearest shape for an aspect ratio, the largest tier not above it for a
+ * resolution (the smallest when all are above). Undefined (leave the field out) for "auto" and other
+ * names it doesn't take.
+ */
+export function fitValue(accepts: readonly string[], value: string, kind: "ratio" | "tier"): string | undefined {
+ const same = accepts.find((a) => a.toLowerCase() === value.trim().toLowerCase());
+ if (same !== undefined) return same;
+ const size = kind === "ratio" ? ratioOf : tierOf;
+ const want = size(value);
+ if (want === undefined) return undefined;
+ const sized = accepts.flatMap((a) => {
+ const n = size(a);
+ return n === undefined ? [] : [{ a, n }];
+ });
+ if (!sized.length) return undefined;
+ if (kind === "ratio") return sized.reduce((best, c) => (Math.abs(Math.log(c.n / want)) < Math.abs(Math.log(best.n / want)) ? c : best)).a;
+ const below = sized.filter((c) => c.n <= want);
+ if (below.length) return below.reduce((best, c) => (c.n > best.n ? c : best)).a;
+ return sized.reduce((best, c) => (c.n < best.n ? c : best)).a;
+}
+
+/** Write an enum setting (aspect ratio, resolution) fitted to what the route takes; nothing when it takes nothing close. */
+function putEnum(out: Record<string, unknown>, field: string | EnumField, value: string, kind: "ratio" | "tier") {
+ const v = typeof field !== "string" && field.accepts ? fitValue(field.accepts, value, kind) : value;
+ if (v === undefined) return;
+ const [k, sent] = enumValue(field, v);
+ out[k] = sent;
+}
+
+type Range = NonNullable<FieldMap["ranges"]>[string];
+
+/** A number inside an API's limits: rounded for whole-number fields, then clamped. */
+function inRange(n: number, r: Range): number {
+ let v = r.integer ? Math.round(n) : n;
+ if (r.min !== undefined) v = Math.max(r.min, v);
+ if (r.max !== undefined) v = Math.min(r.max, v);
+ return v;
+}
+
+/** How many frames a frame-count route renders for the clip (FieldMap.numFrames), or undefined when its length is unknown. */
+export function numFramesValue(f: NonNullable<FieldMap["numFrames"]>, input: Pick<GenInput, "sourceDuration" | "duration" | "fps">): number | undefined {
+ const seconds = input.sourceDuration ?? input.duration;
+ if (seconds === undefined || !Number.isFinite(seconds) || seconds <= 0) return undefined;
+ const fps = input.fps !== undefined && input.fps > 0 ? input.fps : f.fps;
+ return inRange(seconds * fps, { min: f.min, max: f.max, integer: true });
+}
+
/** Path segments that would reach Object.prototype (or a constructor) instead of the payload. */
const UNSAFE_KEYS = new Set(["__proto__", "constructor", "prototype"]);
@@ -120,13 +181,17 @@ export function keyframesValue(k: NonNullable<FieldMap["keyframes"]>, images: st
f = Math.max(0, last !== undefined ? Math.min(f, last) : f);
frames.push(i > 0 ? Math.max(f, frames[i - 1] + 1) : f);
});
+ // Keyframes nudged apart at the very end (4.99 s and 5 s in a 5 s clip) step back so the last stays on the
+ // clip's final frame: each one frame before the next.
+ if (last !== undefined) for (let i = frames.length - 1; i >= 0; i--) frames[i] = Math.max(0, Math.min(frames[i], i === frames.length - 1 ? last : frames[i + 1] - 1));
return images.map((url, i) => ({ [k.image]: url, [k.frame]: frames[i] }));
}
/**
* A Ken Burns move as one zoom (fal's zoompan zooms from the whole picture toward a focal point, or back
- * out): the factor is the larger zoom over the smaller, the focal point is the pan point at the zoomed-in
- * end. Nothing is sent when the request says nothing about the move (the API's defaults apply).
+ * out to it): the factor is the zoomed-in end (the larger of zoomFrom / zoomTo), so that framing is
+ * exact and the other end is the whole picture; the focal point is the pan point at the zoomed-in end.
+ * Nothing is sent when the request says nothing about the move (the API's defaults apply).
*/
function zoomValue(z: NonNullable<FieldMap["zoom"]>, input: GenInput): Record<string, unknown> {
const out: Record<string, unknown> = {};
@@ -135,7 +200,7 @@ function zoomValue(z: NonNullable<FieldMap["zoom"]>, input: GenInput): Record<st
const from = input.zoomFrom ?? 1;
const to = input.zoomTo ?? from;
const zoomIn = to >= from;
- const factor = Math.max(from, to) / Math.max(0.01, Math.min(from, to));
+ const factor = Math.max(1, from, to);
out[z.factor] = round3(z.max ? Math.min(z.max, factor) : factor);
if (z.direction) out[z.direction.key] = zoomIn ? z.direction.in : z.direction.out;
const focus = zoomIn ? (input.panTo ?? input.panFrom) : (input.panFrom ?? input.panTo);
@@ -155,7 +220,7 @@ export function buildPayload(map: FieldMap, input: GenInput): Record<string, unk
const out: Record<string, unknown> = {};
// Fallbacks first: every canonical field and params.extra below overrides them.
for (const [k, v] of Object.entries(map.defaults ?? {})) setPath(out, k, v);
- if (map.prompt !== false && input.prompt !== undefined) setPath(out, map.prompt ?? "prompt", input.prompt);
+ if (map.prompt !== false && input.prompt !== undefined && !(map.omitEmptyPrompt && !input.prompt.trim())) setPath(out, map.prompt ?? "prompt", input.prompt);
if (map.negativePrompt && input.negativePrompt) out[map.negativePrompt] = input.negativePrompt;
const images = input.images ?? [];
@@ -183,14 +248,8 @@ export function buildPayload(map: FieldMap, input: GenInput): Record<string, unk
out[map.timeline] = timelineTracks(spec, visual, input.audios ?? []);
}
- if (map.aspectRatio && input.aspectRatio) {
- const [k, v] = enumValue(map.aspectRatio, input.aspectRatio);
- out[k] = v;
- }
- if (map.resolution && input.resolution) {
- const [k, v] = enumValue(map.resolution, input.resolution);
- out[k] = v;
- }
+ if (map.aspectRatio && input.aspectRatio) putEnum(out, map.aspectRatio, input.aspectRatio, "ratio");
+ if (map.resolution && input.resolution) putEnum(out, map.resolution, input.resolution, "tier");
if (map.duration && input.duration !== undefined) out[map.duration.key] = timeValue(map.duration, input.duration);
if (map.numOutputs && input.numOutputs !== undefined) out[map.numOutputs] = input.numOutputs;
if (map.seed && input.seed !== undefined && input.seed >= 0) {
@@ -274,11 +333,22 @@ export function buildPayload(map: FieldMap, input: GenInput): Record<string, unk
if (map.model3d && input.model3d) out[map.model3d] = input.model3d;
if (map.animation && input.animation !== undefined && input.animation !== "") {
const n = typeof input.animation === "number" ? input.animation : Number(input.animation);
- out[map.animation.key] = Number.isFinite(n) && String(input.animation).trim() !== "" ? n : input.animation;
+ const numeric = Number.isFinite(n) && String(input.animation).trim() !== "";
+ const r = map.ranges?.[map.animation.key];
+ // Meshy's presets are numbered: a name can't be sent.
+ if (r?.integer && !numeric) throw new Error(`Pick the animation by its preset number${r.min !== undefined && r.max !== undefined ? ` (${r.min}–${r.max})` : ""}`);
+ out[map.animation.key] = numeric ? n : input.animation;
if (map.animation.flag) out[map.animation.flag] = true;
}
+ if (map.numFrames) {
+ const n = numFramesValue(map.numFrames, input);
+ if (n !== undefined) out[map.numFrames.key] = n;
+ }
+ // The API's limits on what Fuobe filled in (params.extra below is sent as given).
+ for (const [k, r] of Object.entries(map.ranges ?? {})) if (typeof out[k] === "number") out[k] = inRange(out[k] as number, r);
- for (const [k, v] of Object.entries({ ...map.fixed, ...input.extra })) if (!(map.timeline && k === "timeline")) setPath(out, k, v);
+ const ignore = new Set(map.ignore ?? []);
+ for (const [k, v] of Object.entries({ ...map.fixed, ...input.extra })) if (!(map.timeline && k === "timeline") && !ignore.has(k)) setPath(out, k, v);
// A background colour given as hex goes out in the palette's shape (Recraft wants {r,g,b}).
const bg = map.palette?.background;
if (bg && typeof out[bg] === "string") {
diff --git a/src/lib/catalog/plan.ts b/src/lib/catalog/plan.ts
index 8aa20adc..c31d731c 100644
--- a/src/lib/catalog/plan.ts
+++ b/src/lib/catalog/plan.ts
@@ -230,6 +230,9 @@ export function planGeneration(
}
if (op === "dub" && !req.inputs?.video && !req.inputs?.audio) throw new Error("Add the video to translate");
if (op === "keyframes") checkKeyframes(model, req.inputs?.images?.length ?? 0, params);
+ // A join takes as many clips as the API's list does (fal merge-audios: 5); longer joins run in steps.
+ const maxAudios = model.options.maxAudios;
+ if (op === "audio-join" && maxAudios && (req.inputs?.audios?.length ?? 0) > maxAudios) throw new Error(`${model.name} joins up to ${maxAudios} clips at a time — join the rest in a second step`);
const requires = model.options.requires;
if (requires?.images && (req.inputs?.images?.length ?? 0) < requires.images) throw new Error(requires.msg);
if (requires?.prompt && !prompt) throw new Error(requires.msg);
diff --git a/src/lib/catalog/types.ts b/src/lib/catalog/types.ts
index 3be61032..b63b8a82 100644
--- a/src/lib/catalog/types.ts
+++ b/src/lib/catalog/types.ts
@@ -251,6 +251,13 @@ export interface EnumField {
key: string;
/** Map our canonical value → provider value. Unlisted values pass through. */
values?: Record<string, string | number | boolean>;
+ /**
+ * The canonical values this route takes, when they differ from the model's own list (a model on two
+ * APIs, e.g. Grok Imagine on fal and Higgsfield). Any other value is sent as the closest one it takes
+ * (aspect ratios by shape, resolutions by size) and left out when none is close ("auto" on an API
+ * without it), so the API's default applies.
+ */
+ accepts?: string[];
}
/**
@@ -356,9 +363,10 @@ export interface FieldMap {
/** Seconds of crossfade at each join or loop seam (params.crossfade). */
crossfade?: string;
/**
- * A Ken Burns move sent as one zoom toward a focal point (fal's zoompan): `factor` = the larger of
- * params.zoomFrom / zoomTo over the smaller (at most `max`), `direction` in or out, the focal point = the pan point at
- * the zoomed-in end (0–1, or percent), `easing` from params.easing.
+ * A Ken Burns move sent as one zoom toward a focal point (fal's zoompan, which always starts or ends on
+ * the whole picture): `factor` = the zoomed-in end, the larger of params.zoomFrom / zoomTo (at most
+ * `max`), `direction` in or out, the focal point = the pan point at the zoomed-in end (0–1, or percent),
+ * `easing` from params.easing. The other end is the whole picture, whatever params says.
*/
zoom?: { factor: string; max?: number; direction?: { key: string; in: string; out: string }; x?: string; y?: string; easing?: EnumField; percent?: boolean };
/** Where an overlay's centre goes (params.position, 0–1 of the background; or percent). */
@@ -383,6 +391,24 @@ export interface FieldMap {
model3d?: string;
/** An animation preset (params.animation); `flag` is the API's switch that turns animation on. */
animation?: { key: string; flag?: string };
+ /**
+ * A frame count for routes that render only as many frames as asked (LTX 2.3 clean plate and HDR, VOID):
+ * the clip's length (params.sourceDuration, else params.duration) × the frame rate (params.fps, else
+ * `fps`), kept within min–max. Nothing is sent when the length is unknown (the API's default applies).
+ */
+ numFrames?: { key: string; fps: number; min?: number; max?: number };
+ /**
+ * Limits the API checks on numeric fields Fuobe fills (round 4: target fps, slow motion, frame interval,
+ * overlay position and scale, Ken Burns length…): a value is rounded when the field takes whole numbers
+ * and kept inside min–max before it is sent. params.extra is sent as given.
+ */
+ ranges?: Record<string, { min?: number; max?: number; integer?: boolean }>;
+ /** The most images this route's image list takes, when fewer than the model's options.maxImages (another route takes more). */
+ maxImages?: number;
+ /** An empty prompt is left out rather than sent as "" (APIs that read a missing prompt as "no words": Bria Expand). */
+ omitEmptyPrompt?: boolean;
+ /** params.extra keys this route has no field for (a model-wide control only its other routes read): left out. */
+ ignore?: string[];
}
export interface ModelRoute {
@@ -537,7 +563,10 @@ export interface GenParams {
easing?: "linear" | "ease-in-out";
/** Seconds of crossfade at each seam (audio-loop, audio-join). */
crossfade?: number;
- /** The input clip's length in seconds, when the caller knows it (how many plays a cloud loop needs). */
+ /**
+ * The input clip's length in seconds, when the caller knows it: how many plays a cloud loop needs, and how
+ * many frames a frame-count route renders (LTX 2.3 clean plate / HDR, VOID; FieldMap.numFrames).
+ */
sourceDuration?: number;
/** Extract every Nth frame. */
frameInterval?: number;
diff --git a/src/server/generations.ts b/src/server/generations.ts
index 0d9f673a..39c7cc60 100644
--- a/src/server/generations.ts
+++ b/src/server/generations.ts
@@ -259,15 +259,25 @@ export function deleteGeneration(id: string): void {
// ---------------------------------------------------------------------------
// Routing
-/** Pick the provider for a run: a configured real provider, else the demo provider (unless demo is off). */
-export function chooseRoute(candidates: ModelRoute[]): { route: ModelRoute; demo: boolean } {
+/**
+ * Pick the provider for a run: a configured real provider, else the demo provider (unless demo is off).
+ * `images` is how many images the run sends: a route whose list takes fewer (FieldMap.maxImages: Grok
+ * Imagine Image takes 5 on fal, 10 on Higgsfield) gives way to one that takes them all, or says so.
+ */
+export function chooseRoute(candidates: ModelRoute[], images = 0): { route: ModelRoute; demo: boolean } {
// Honour the preferred cloud aggregator (Settings → API configuration) when a model is on several.
const preferred = getSetting("cloudProvider");
const routes = preferred === "auto" ? candidates : [...candidates].sort((a, b) => Number(b.provider === preferred) - Number(a.provider === preferred));
const demo = getSetting("demoMode");
if (demo === "on") return { route: routes[0], demo: true };
- const real = routes.find(routeReady);
+ const takes = (r: ModelRoute) => !r.map?.maxImages || images <= r.map.maxImages;
+ const real = routes.find((r) => routeReady(r) && takes(r));
if (real) return { route: real, demo: false };
+ const short = routes.find(routeReady);
+ if (short) {
+ const others = [...new Set(routes.filter((r) => takes(r) && r.provider !== short.provider).map((r) => provider(r.provider).label))];
+ throw new Error(`This model takes up to ${short.map!.maxImages} images on ${provider(short.provider).label} — remove some${others.length ? `, or connect ${others.join(" or ")} for more` : ""}`);
+ }
if (demo === "off") {
if (routes.every((r) => r.provider === "llm")) throw new Error(llmMissing(routes[0]));
const names = [...new Set(routes.map((r) => provider(r.provider).label))].join(" or ");
@@ -305,7 +315,7 @@ function prepare(original: GenerationRequest) {
const worded = withSignatureWords(original);
const model = getModel(worded.modelId);
const req = model ? stripMotionPaths(applySketch(applyMentions(worded, model, listElements()).request, model).request, model) : worded;
- const plan = planGeneration(req, getModel, getPreset);
+ let plan = planGeneration(req, getModel, getPreset);
const mode = engineMode();
if (mode !== "both" && plan.model.engine !== mode) {
throw new Error(
@@ -317,7 +327,11 @@ function prepare(original: GenerationRequest) {
// Checks planGeneration can't make without knowing the model's kind or the text ops' needs.
if (plan.op === "color-match" && plan.model.kind === "video" && !req.inputs?.video) throw new Error("Add the video and a reference image");
if (plan.op === "translate" && !plan.params.targetLanguage) throw new Error("Pick a language to translate into");
- const { route, demo } = chooseRoute(routesFor(plan.model, plan.op));
+ const { route, demo } = chooseRoute(routesFor(plan.model, plan.op), req.inputs?.images?.length ?? 0);
+ // A route that can't batch (Higgsfield's Grok Imagine Image beside fal's num_images) runs one job per output.
+ if (!demo && route.map && !route.map.numOutputs && plan.perJobOutputs > 1) {
+ plan = { ...plan, jobs: plan.jobs * plan.perJobOutputs, perJobOutputs: 1, params: { ...plan.params, numOutputs: 1 } };
+ }
const providerId: ProviderId = demo ? "mock" : route.provider;
// A text step that runs on Ollama is free; only Claude costs money.
const free = demo || (route.provider === "llm" && !llmUsesClaude(route));
diff --git a/tests/cloud-catalog-4.test.ts b/tests/cloud-catalog-4.test.ts
index d50c5781..f9635bf8 100644
--- a/tests/cloud-catalog-4.test.ts
+++ b/tests/cloud-catalog-4.test.ts
@@ -2,13 +2,19 @@ import fs from "node:fs";
import { describe, expect, it } from "vitest";
import { getModel, getPreset, MODELS, modelsFor } from "@/lib/catalog";
import { CLOUD_MODELS } from "@/lib/catalog/cloud-models.generated";
-import { buildPayload, keyframesValue, pointsValue } from "@/lib/catalog/payload";
+import { buildPayload, fitValue, keyframesValue, pointsValue } from "@/lib/catalog/payload";
import { estimateCost, inferOperation, planGeneration, pricingAt, promptOptional } from "@/lib/catalog/plan";
import { OPERATION_LABELS, OPERATION_OUTPUT, type GenerationRequest, type ModelRoute, type Operation } from "@/lib/catalog/types";
-type Endpoint = { provider: string; endpoint: string; status?: string; verified?: boolean };
+type Endpoint = { provider: string; endpoint: string; status?: string; verified?: boolean; inputs?: Record<string, { values?: unknown[] }> };
const research4 = (JSON.parse(fs.readFileSync("docs/research/paid-model-apis-4.json", "utf8")) as { endpoints: Endpoint[] }).endpoints;
const byId = new Map(research4.map((e) => [`${e.provider}:${e.endpoint}`, e]));
+type HiggsfieldEndpoint = { path: string; method: string; inputs?: Record<string, { enum?: unknown[] }> };
+const higgsfield = new Map(
+ (JSON.parse(fs.readFileSync("docs/research/higgsfield-api.json", "utf8")) as { endpoints: HiggsfieldEndpoint[] }).endpoints
+ .filter((e) => e.method === "POST")
+ .map((e) => [e.path.replace(/^\//, ""), e]),
+);
/** The models round 4 added (research part 4), with the operation each is for. */
const ROUND4: Record<string, Operation> = {
@@ -167,7 +173,12 @@ describe("round-4 cloud models", () => {
expect(MODELS.filter((m) => m.id === "grok-imagine-video-1-5")).toHaveLength(1);
const lite = getModel("genjutsu-lite-object-swap")!;
expect(lite.routes).toEqual([
- { op: "video-swap", provider: "higgsfield", endpoint: "higgsfield/genjutsu-light/object-swap/v1.0", map: { images: "image_urls", video: "video_url", resolution: "resolution" } },
+ {
+ op: "video-swap",
+ provider: "higgsfield",
+ endpoint: "higgsfield/genjutsu-light/object-swap/v1.0",
+ map: { omitEmptyPrompt: true, images: "image_urls", video: "video_url", resolution: "resolution" },
+ },
]);
// Duration is read-only on Genjutsu Light (taken from the source): never sent, never offered.
expect(lite.options.durations).toBeUndefined();
@@ -257,6 +268,9 @@ describe("round-4 payloads", () => {
expect(keyframesValue(kf, ["a", "b", "c"], undefined, 10).map((k) => k.frame_index)).toEqual([0, 120, 240]);
// Times past the end are held at the end; equal frames are nudged apart (the API wants them unique).
expect(keyframesValue(kf, ["a", "b", "c"], [0, 0.01, 9], 5).map((k) => k.frame_index)).toEqual([0, 1, 120]);
+ // Nudged apart at the very end, they step back: the last stays on the final frame (at most duration × 24).
+ expect(keyframesValue(kf, ["a", "b"], [4.99, 5], 5).map((k) => k.frame_index)).toEqual([119, 120]);
+ expect(keyframesValue(kf, ["a", "b", "c"], [4.9, 4.95, 5], 5).map((k) => k.frame_index)).toEqual([118, 119, 120]);
expect(keyframesValue(kf, ["a"], undefined, 5)).toEqual([{ image_url: "a", frame_index: 0 }]);
// The keyframes route takes no start or end image fields.
expect(map("flux-3-max", "keyframes").image).toBeUndefined();
@@ -291,15 +305,19 @@ describe("round-4 payloads", () => {
zoom_y: 45,
easing: "ease_in_out",
});
- // Zooming out looks from the start point; the factor is the larger zoom over the smaller, at most 2x.
+ // Zooming out looks from the start point. fal's zoompan always starts or ends on the whole picture: the
+ // zoomed-in end is exact (at most 2x) and the other end is the whole still.
expect(buildPayload(m, { images: ["s.png"], zoomFrom: 1.5, zoomTo: 1.2, panFrom: { x: 0.1, y: 0.9 }, panTo: { x: 0.5, y: 0.5 }, easing: "linear" })).toEqual({
image_url: "s.png",
- zoom_factor: 1.25,
+ zoom_factor: 1.5,
zoom_direction: "out",
zoom_x: 10,
zoom_y: 90,
easing: "linear",
});
+ expect(buildPayload(m, { images: ["s.png"], zoomFrom: 1.2, zoomTo: 1.5 })).toMatchObject({ zoom_factor: 1.5, zoom_direction: "in" });
+ // A hold tighter than the whole picture ends on that framing (the cloud move can't start there).
+ expect(buildPayload(m, { images: ["s.png"], zoomFrom: 1.5, zoomTo: 1.5 })).toMatchObject({ zoom_factor: 1.5 });
expect(buildPayload(m, { images: ["s.png"], zoomTo: 3 }).zoom_factor).toBe(2);
// A static hold for an end card, and nothing said about the move: the API's own defaults.
expect(buildPayload(m, { images: ["s.png"], zoomFrom: 1, zoomTo: 1 })).toMatchObject({ zoom_factor: 1, zoom_direction: "in" });
@@ -356,7 +374,9 @@ describe("round-4 payloads", () => {
ref_image_urls: ["car.png"],
});
expect(buildPayload(map("bria-video-erase-mask", "remove-object", "replicate"), { video: "v.mp4", mask: "mask.mp4" })).toEqual({ video_url: "v.mp4", mask_url: "mask.mp4", auto_trim: true });
- expect(buildPayload(map("p-video-replace", "video-swap", "replicate"), { prompt: "", video: "v.mp4", images: ["me.png"] })).toEqual({ instruction_prompt: "", video: "v.mp4", images: ["me.png"] });
+ // Its instruction is optional: an empty one is left out, not sent as "".
+ expect(buildPayload(map("p-video-replace", "video-swap", "replicate"), { prompt: "", video: "v.mp4", images: ["me.png"] })).toEqual({ video: "v.mp4", images: ["me.png"] });
+ expect(buildPayload(map("p-video-replace", "video-swap", "replicate"), { prompt: "Swap the man", video: "v.mp4", images: ["me.png"] })).toMatchObject({ instruction_prompt: "Swap the man" });
});
});
@@ -444,6 +464,7 @@ describe("round-4 planning", () => {
expect(promptOptional(getModel("genjutsu-object-swap")!, "video-swap")).toBe(true);
expect(getModel("p-video-replace")!.options.promptless).toBeFalsy();
expect(plan({ modelId: "genjutsu-lite-object-swap", inputs: { video, images: ["/r.png"] } }).op).toBe("video-swap");
+ expect(buildPayload(map("genjutsu-lite-object-swap", "video-swap", "higgsfield"), { prompt: "", video: "v.mp4", images: ["r.png"] })).toEqual({ image_urls: ["r.png"], video_url: "v.mp4" });
expect(fails({ modelId: "kling-o3", op: "video-swap", inputs: { video, images: ["/r.png"] } })).toBe("Write a prompt first");
expect(fails({ modelId: "sam-3d-objects", inputs: { images: ["/room.png"] } })).toBe("Name the objects to rebuild, e.g. “chair, lamp”");
expect(plan({ modelId: "pixelcut-looping-video", inputs: { images: ["/bottle.png"] } }).op).toBe("i2v");
@@ -461,3 +482,102 @@ describe("round-4 planning", () => {
expect(fails({ modelId: "flux-3-max", op: "keyframes", prompt: "p", inputs: { images: eleven } })).toBe("FLUX 3 Max takes up to 10 keyframes");
});
});
+
+describe("round-4 review fixes", () => {
+ it("fits aspect ratios and resolutions to what each route takes", () => {
+ expect(fitValue(["480p", "720p"], "1080p", "tier")).toBe("720p");
+ expect(fitValue(["720p", "1080p"], "480p", "tier")).toBe("720p");
+ expect(fitValue(["1k", "2k"], "2K", "tier")).toBe("2k");
+ expect(fitValue(["1:1", "2:1", "16:9"], "20:9", "ratio")).toBe("2:1");
+ expect(fitValue(["1:1", "16:9"], "auto", "ratio")).toBeUndefined();
+ expect(fitValue(["auto", "16:9"], "auto", "ratio")).toBe("auto");
+ expect(fitValue(["480p"], "very_low", "tier")).toBeUndefined();
+ });
+
+ it("sends Grok Imagine on fal and Higgsfield only values each route's API lists", () => {
+ const bad: string[] = [];
+ for (const id of ["grok-imagine-video-1-5", "grok-imagine-image-2"]) {
+ const m = getModel(id)!;
+ for (const r of m.routes) {
+ const enumOf = (field: string): unknown[] | undefined =>
+ r.provider === "higgsfield" ? higgsfield.get(r.endpoint)?.inputs?.[field]?.enum : byId.get(`${r.provider}:${r.endpoint}`)?.inputs?.[field]?.values;
+ const images = r.op === "ref2v" || r.op === "edit" ? ["a.png", "b.png"] : r.op === "i2v" ? ["a.png"] : [];
+ for (const aspectRatio of m.options.aspectRatios ?? []) {
+ const sent = buildPayload(r.map!, { prompt: "p", images, aspectRatio }).aspect_ratio;
+ if (sent !== undefined && !enumOf("aspect_ratio")?.includes(sent)) bad.push(`${id} ${r.provider} ${r.op} aspect ${aspectRatio} → ${String(sent)}`);
+ }
+ for (const resolution of m.options.resolutions ?? []) {
+ const sent = buildPayload(r.map!, { prompt: "p", images, resolution }).resolution;
+ if (sent !== undefined && !enumOf("resolution")?.includes(sent)) bad.push(`${id} ${r.provider} ${r.op} resolution ${resolution} → ${String(sent)}`);
+ }
+ }
+ }
+ expect(bad).toEqual([]);
+ // fal's reference-to-video stops at 720p; text-to-video makes 1080p.
+ expect(buildPayload(map("grok-imagine-video-1-5", "ref2v"), { prompt: "p", images: ["a.png", "b.png"], resolution: "1080p" })).toMatchObject({ reference_image_urls: ["a.png", "b.png"], resolution: "720p" });
+ expect(buildPayload(map("grok-imagine-video-1-5", "t2v"), { prompt: "p", resolution: "1080p" }).resolution).toBe("1080p");
+ // Higgsfield: a start frame or references, never both; references up to 720p.
+ expect(buildPayload(map("grok-imagine-video-1-5", "i2v", "higgsfield"), { prompt: "p", images: ["a.png"], resolution: "1080p" })).toEqual({ prompt: "p", image_url: "a.png", resolution: "1080p" });
+ expect(buildPayload(map("grok-imagine-video-1-5", "ref2v", "higgsfield"), { prompt: "p", images: ["a.png", "b.png"], resolution: "1080p" })).toEqual({ prompt: "p", image_urls: ["a.png", "b.png"], resolution: "720p" });
+ // fal's text-to-image has no "auto" (its edit does); Higgsfield takes the nearest of its shapes.
+ expect(buildPayload(map("grok-imagine-image-2", "t2i"), { prompt: "p", aspectRatio: "auto" })).toEqual({ prompt: "p" });
+ expect(buildPayload(map("grok-imagine-image-2", "edit"), { prompt: "p", images: ["a.png"], aspectRatio: "auto" }).aspect_ratio).toBe("auto");
+ for (const [want, sent] of [["20:9", "2:1"], ["19.5:9", "2:1"], ["9:19.5", "1:2"], ["9:20", "1:2"], ["16:9", "16:9"], ["auto", "auto"]]) {
+ expect(buildPayload(map("grok-imagine-image-2", "t2i", "higgsfield"), { prompt: "p", aspectRatio: want }).aspect_ratio, want).toBe(sent);
+ }
+ // Up to 10 references (Higgsfield); fal's edit route says it takes 5, so a run with more goes to Higgsfield.
+ expect(getModel("grok-imagine-image-2")!.options.maxImages).toBe(10);
+ expect(map("grok-imagine-image-2", "edit").maxImages).toBe(5);
+ expect(map("grok-imagine-image-2", "edit", "higgsfield").maxImages).toBeUndefined();
+ });
+
+ it("asks frame-count routes for as many frames as the clip has", () => {
+ expect(buildPayload(map("ltx-2-3-clean-plate"), { video: "v.mp4", sourceDuration: 10, resolution: "480p" })).toMatchObject({ num_frames: 240, resolution: "480p" });
+ expect(buildPayload(map("ltx-2-3-hdr"), { video: "v.mp4", duration: 4, fps: 30 })).toMatchObject({ num_frames: 120, frames_per_second: 30 });
+ // VOID's window tops out at 197 frames (about 8 s): longer clips are split by the caller.
+ expect(buildPayload(map("void-video-inpainting"), { prompt: "the cup", video: "v.mp4", sourceDuration: 12 }).num_frames).toBe(197);
+ expect(buildPayload(map("void-video-inpainting"), { prompt: "the cup", video: "v.mp4", sourceDuration: 5 }).num_frames).toBe(120);
+ // Unknown length: the API's own default.
+ expect(buildPayload(map("ltx-2-3-clean-plate"), { video: "v.mp4" }).num_frames).toBeUndefined();
+ // VACE matches the input's frame count itself.
+ expect(map("wan-22-vace-inpaint", "remove-object").numFrames).toBeUndefined();
+ expect(route("ltx-2-3-clean-plate").note).toMatch(/480p up to about 15 s/);
+ });
+
+ it("keeps the numbers it fills inside each API's limits", () => {
+ expect(buildPayload(map("topaz-fps-boost"), { video: "v.mp4", targetFps: 200, slowdown: 2.5 })).toMatchObject({ target_fps: 120, slowdown_factor: 3 });
+ expect(buildPayload(map("topaz-fps-boost"), { video: "v.mp4", targetFps: 8 }).target_fps).toBe(16);
+ expect(buildPayload(map("overlay-image"), { images: ["card.png", "logo.png"], scale: 0.1, position: { x: 1.2, y: -0.1 } })).toMatchObject({ scale_percent: 25, x_percent: 100, y_percent: 0 });
+ expect(buildPayload(map("extract-frames"), { video: "v.mp4", frameInterval: 10_000 }).frame_interval).toBe(300);
+ expect(buildPayload(map("ken-burns"), { images: ["s.png"], duration: 45, fps: 12 })).toMatchObject({ duration: 30, frames_per_second: 24 });
+ expect(buildPayload(map("meshy-rigging"), { model3d: "char.glb", animation: 900 }).animation_action_id).toBe(696);
+ expect(() => buildPayload(map("meshy-rigging"), { model3d: "char.glb", animation: "walk" })).toThrow("Pick the animation by its preset number (0–696)");
+ // params.extra is sent as given.
+ expect(buildPayload(map("topaz-fps-boost"), { video: "v.mp4", extra: { target_fps: 200 } }).target_fps).toBe(200);
+ });
+
+ it("joins at most as many audio clips as the API takes", () => {
+ const six = Array.from({ length: 6 }, (_, i) => `/${i}.wav`);
+ expect(fails({ modelId: "join-audio", op: "audio-join", inputs: { audios: six } })).toBe("Join audio joins up to 5 clips at a time — join the rest in a second step");
+ expect(fails({ modelId: "join-audio", op: "audio-join", inputs: { audios: six.slice(0, 5) } })).toBeNull();
+ });
+
+ it("gives Bria Expand a target shape and leaves an empty prompt out", () => {
+ const p = plan({ modelId: "bria-expand", inputs: { images: ["/a.png"] } });
+ expect(p).toMatchObject({ op: "outpaint", params: { aspectRatio: "16:9" } });
+ expect(buildPayload(map("bria-expand"), { prompt: "", images: ["a.png"], aspectRatio: p.params.aspectRatio })).toEqual({ image_url: "a.png", aspect_ratio: "16:9" });
+ expect(buildPayload(map("bria-expand"), { prompt: "more beach", images: ["a.png"], aspectRatio: "9:16" })).toEqual({ prompt: "more beach", image_url: "a.png", aspect_ratio: "9:16" });
+ });
+
+ it("sends a model-wide control only to the routes that have its field", () => {
+ expect(buildPayload(map("ideogram-vector", "vectorize"), { images: ["a.png"], extra: { quality: "high", mode: "simple" } })).toEqual({ image_url: "a.png", mode: "simple" });
+ expect(buildPayload(map("ideogram-vector", "t2i"), { prompt: "a fox", extra: { quality: "high" } })).toMatchObject({ quality: "high" });
+ });
+
+ it("credits the makers, not the host", () => {
+ expect(getModel("void-video-inpainting")!.vendor).toBe("Netflix");
+ expect(getModel("rife-video-cloud")!.vendor).toBe("Open source");
+ expect(getModel("bria-fibo-2")!.tagline).toMatch(/^Structured prompts; Bria says/);
+ expect(getModel("wan-22-vace-inpaint")!.pricing!.note).toMatch(/frames ÷ 16/);
+ });
+});
diff --git a/tests/engine-mode.test.ts b/tests/engine-mode.test.ts
index 760e3f8a..561b4037 100644
--- a/tests/engine-mode.test.ts
+++ b/tests/engine-mode.test.ts
@@ -9,7 +9,7 @@ process.env.FUOBE_DATA_DIR = dir;
process.env.COMFYUI_URL = "http://127.0.0.1:9"; // nothing listens here → open models fall back to demo
const { setSetting, getSetting, validateSetting } = await import("@/server/settings");
-const { chooseRoute, createGenerations } = await import("@/server/generations");
+const { chooseRoute, createGenerations, previewGeneration } = await import("@/server/generations");
const { getModel } = await import("@/lib/catalog");
beforeAll(() => setSetting("demoMode", "auto"));
@@ -51,3 +51,28 @@ describe("preferred cloud provider", () => {
expect(chooseRoute(routes)).toMatchObject({ demo: true });
});
});
+
+describe("routes that take fewer images or can't batch", () => {
+ const edit = () => getModel("grok-imagine-image-2")!.routes.filter((r) => r.op === "edit");
+
+ it("sends more images than fal's Grok edit takes to Higgsfield, or says why it can't", () => {
+ setSetting("falKey", "fal_test_key_123456");
+ expect(chooseRoute(edit(), 3).route.provider).toBe("fal");
+ expect(() => chooseRoute(edit(), 8)).toThrow("This model takes up to 5 images on fal.ai — remove some, or connect Higgsfield for more");
+ setSetting("higgsfieldKey", "key_id:key_secret");
+ expect(chooseRoute(edit(), 8).route.provider).toBe("higgsfield");
+ expect(chooseRoute(edit(), 3).route.provider).toBe("fal");
+ setSetting("falKey", "");
+ setSetting("higgsfieldKey", "");
+ });
+
+ it("runs one job per take on a route without a batch count", () => {
+ setSetting("higgsfieldKey", "key_id:key_secret");
+ const req = { feature: "image", modelId: "grok-imagine-image-2", prompt: "a fox", params: { numOutputs: 4 } };
+ expect(previewGeneration(req)).toMatchObject({ providerId: "higgsfield", jobs: 4, outputs: 4 });
+ setSetting("falKey", "fal_test_key_123456");
+ expect(previewGeneration(req)).toMatchObject({ providerId: "fal", jobs: 1, outputs: 4 });
+ setSetting("falKey", "");
+ setSetting("higgsfieldKey", "");
+ });
+});