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.

MOSS N7-1: MOSS-Image in the catalog on both engines, priced per megapixel

Claude2d2b0d29a7dd
diff --git a/scripts/gen-cloud-models.py b/scripts/gen-cloud-models.py
index 04f03aaa..e1c436e8 100644
--- a/scripts/gen-cloud-models.py
+++ b/scripts/gen-cloud-models.py
@@ -1,7 +1,8 @@
#!/usr/bin/env python3
"""
Generate src/lib/catalog/cloud-models.generated.ts from docs/research/paid-model-apis.json
-(merged with parts 2, 3 and 4: paid-model-apis-2.json, paid-model-apis-3.json, paid-model-apis-4.json).
+(merged with parts 2, 3 and 4: paid-model-apis-2.json, paid-model-apis-3.json, paid-model-apis-4.json, and the
+endpointRecords of research #7, new-models-7.json).
The research file holds verified fal/Replicate input schemas (field names, enums, defaults,
prices). This script turns a curated list of models (MODELS below) into ModelDef objects with
@@ -37,6 +38,13 @@ for e in RESEARCH_4["endpoints"]:
prev = EPS.get((e["provider"], e["endpoint"]))
EPS[(e["provider"], e["endpoint"])] = {**e, "keyFields": {**((prev or {}).get("keyFields") or {}), **(e.get("keyFields") or {})}}
+# Research #7 (docs/research/new-models-7.json, endpointRecords in the shape of part 4's endpoints): fal's MOSS-Image and
+# its /lora twin (package N7-1). Same merge.
+NEW_MODELS_7 = json.loads((ROOT / "docs/research/new-models-7.json").read_text(encoding="utf-8"))
+for e in NEW_MODELS_7.get("endpointRecords") or []:
+ prev = EPS.get((e["provider"], e["endpoint"]))
+ EPS[(e["provider"], e["endpoint"])] = {**e, "keyFields": {**((prev or {}).get("keyFields") or {}), **(e.get("keyFields") or {})}}
+
# Originals (docs/research/fuobe-originals-recipes-5.json): the hosted open-weight endpoints that take LoRAs
# (hostedLoraEndpoints: the LoRA field's shape, maximum and whether it's required, plus the full inputs where
# scripts/fetch-hosted-schemas.py read them) and the plain endpoints of the same models (hostedBaseEndpoints).
@@ -72,7 +80,8 @@ 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, fit_values=False, fps_targets=None, upscale_tiers=None,
- frame_step=None, original=False, sizes=None, keep_shape=False, licence=None, frame_fps=None, frame_multiple=None):
+ frame_step=None, original=False, sizes=None, keep_shape=False, licence=None, frame_fps=None, frame_multiple=None,
+ exact_size=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).
@@ -95,6 +104,9 @@ def model(id, name, vendor, family, kind, tagline, routes, badges=None, pricing=
and the API follows the input image; a route whose own default matches the input (Replicate's match_input_image)
leaves it out the same way.
licence: the open weights' licence (ModelLicence) when no hosted LoRA endpoint the model runs on records it.
+ exact_size: the API takes its size as one {width, height} object and rounds it itself ("rounded to multiples of 16
+ between 512 and 2048 pixels": fal's MOSS-Image): FieldMap.size from the aspect ratio with the grid and limits the field's
+ description states, so a layout drawn on that canvas is the picture the API makes.
A route's options dict may also set max_images (FieldMap.maxImages), note, loraEndpoint (the same model with LoRAs:
FieldMap.loras comes from its research record) and pin (a Replicate model run by version: the research's version)."""
M.append(dict(id=id, name=name, vendor=vendor, family=family, kind=kind, tagline=tagline, routes=routes,
@@ -102,7 +114,7 @@ def model(id, name, vendor, family, kind, tagline, routes, badges=None, pricing=
sliders=sliders or [], controls=controls or [], api_defaults=api_defaults or {}, formats=formats or {},
ranged_durations=ranged_durations, fit_values=fit_values, fps_targets=fps_targets or [], upscale_tiers=upscale_tiers or [],
frame_step=frame_step, original=original, sizes=sizes, keep_shape=keep_shape, licence=licence, frame_fps=frame_fps,
- frame_multiple=frame_multiple))
+ frame_multiple=frame_multiple, exact_size=exact_size))
# ----- Image
@@ -156,10 +168,11 @@ model("gpt-image-1-5", "GPT Image 1.5", "OpenAI", "gpt-image", "image",
"Strong prompt following, text and layout",
[("t2i", "fal-ai/gpt-image-1.5"), ("edit", "fal-ai/gpt-image-1.5/edit")],
pricing=("image", 0.13, "high quality"), fixed={"quality": "high"}, defaults={"aspectRatio": "1:1"})
+# FLUX.3, Ideogram 4.5 and Bria FIBO 2 read a Fuobe layout in their own form (src/lib/layout-prompt.ts; research #7 §4.3).
model("flux-3", "FLUX.3", "Black Forest Labs", "flux", "image",
"BFL's newest image model with unified generation and editing",
[("t2i", "blackforestlabs/flux-3/text-to-image"), ("edit", "blackforestlabs/flux-3/edit-image")],
- badges=["new"], defaults={"aspectRatio": "1:1"})
+ badges=["new"], defaults={"aspectRatio": "1:1"}, options={"layout": "flux3"})
model("flux-2-pro", "FLUX.2 [pro]", "Black Forest Labs", "flux", "image",
"Production-grade photorealism with multi-reference editing",
[("t2i", "fal-ai/flux-2-pro"), ("edit", "fal-ai/flux-2-pro/edit")],
@@ -170,7 +183,7 @@ model("flux-kontext-max", "FLUX.1 Kontext [max]", "Black Forest Labs", "flux", "
pricing=("image", 0.08), defaults={"aspectRatio": "1:1"})
model("ideogram-4-5", "Ideogram 4.5", "Ideogram", "ideogram", "image",
"Best-in-class typography, posters and graphic design",
- [("t2i", "ideogram/v4.5"), ("edit", "ideogram/v4.5/edit")], defaults={"aspectRatio": "1:1"})
+ [("t2i", "ideogram/v4.5"), ("edit", "ideogram/v4.5/edit")], defaults={"aspectRatio": "1:1"}, options={"layout": "ideogram"})
model("flux-fill-pro", "FLUX.1 Fill [pro]", "Black Forest Labs", "flux", "image", "Precise inpainting and object replacement with a mask",
[("inpaint", "fal-ai/flux-pro/v1/fill")], pricing=("megapixel", 0.05), hidden=False)
model("z-image-inpaint", "Z-Image Turbo Inpaint (hosted)", "Alibaba Tongyi", "z-image", "image", "Cheapest, fastest masked inpainting",
@@ -181,6 +194,18 @@ model("recraft-4-1", "Recraft V4.1", "Recraft", "recraft", "image",
model("qwen-image-3", "Qwen Image 3", "Alibaba Qwen", "qwen-image", "image",
"Hosted Qwen with superb bilingual text rendering",
[("t2i", "alibaba/qwen-image-3/text-to-image"), ("edit", "alibaba/qwen-image-3/edit")], defaults={"aspectRatio": "1:1"})
+# MOSS-Image (research #7 §4.7): OpenMOSS's Apache-2.0 model hosted on fal, $0.05 per megapixel; a run with LoRAs goes to
+# its /lora twin (up to 3, unpublished price). The size goes as image_size {width, height} on fal's 16-pixel grid within
+# 512-2048, so a layout is compiled for the picture fal makes; prompt expansion is off for a layout. PNG, so the words stay sharp.
+MOSS_FAL = next(e for e in NEW_MODELS_7["endpointRecords"] if e["endpoint"] == "fal-ai/moss-image")
+model("moss-image", "MOSS-Image", "OpenMOSS", "moss", "image",
+ "Clean Chinese and English text, and it follows layout boxes",
+ [("t2i", "fal-ai/moss-image", "fal", {"loraEndpoint": "fal-ai/moss-image/lora"})],
+ badges=["new"], defaults={"aspectRatio": "1:1"}, fixed={"output_format": "png"}, exact_size=True, options={"layout": "moss"},
+ sliders=[("num_inference_steps", "Steps"), ("guidance_scale", "Guidance")],
+ licence={"licence": re.match(r"[\w.-]+", MOSS_FAL["license"]).group(0), "commercial": True,
+ "note": f"{MOSS_FAL['license']}. fal's safety checker returns a black image when it flags an output",
+ "checked": MOSS_FAL["fetched"]})
model("wan-2-7-image", "Wan 2.7 Image", "Alibaba Wan", "wan", "image",
"Wan's image model — cinematic stills that animate well",
[("t2i", "fal-ai/wan/v2.7/pro/text-to-image"), ("edit", "fal-ai/wan/v2.7/pro/edit")], defaults={"aspectRatio": "16:9"})
@@ -1204,7 +1229,7 @@ model("grok-imagine-image-2", "Grok Imagine Image 2.0", "xAI", "grok", "image",
{"byResolution": {"1k": 0.06, "2k": 0.08}}),
controls=[("quality", "Quality")], options={"maxImages": 5})
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"})
+ [("t2i", "bria/fibo-2/generate"), ("edit", "bria/fibo-2/edit")], badges=["new"], defaults={"aspectRatio": "1:1"}, options={"layout": "vgl"})
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"],
defaults={"aspectRatio": "1:1"}, pricing=("image", 0.16, "per SVG at medium quality (low $0.13, high $0.20); image to SVG $0.10"),
@@ -1405,7 +1430,7 @@ def lora_field(provider, ep):
return None
item = spec.get("itemSchema") or {}
f = {"shape": "items", "key": key}
- mx = summary.get("maxCount") if isinstance(summary.get("maxCount"), int) else num((re.search(r"maximum (\d+)", spec.get("desc") or "") or [None, None])[1])
+ mx = summary.get("maxCount") if isinstance(summary.get("maxCount"), int) else num((re.search(r"maximum (\d+)", spec.get("desc") or "") or [None, None])[1]) or num(spec.get("maxItems"))
if mx:
f["max"] = mx
if spec.get("required") or summary.get("required"):
@@ -1754,6 +1779,19 @@ def build_route(op, ep, provider, m, opts, ropts=None):
elif ropts.get("keepSize"):
# The result keeps the input picture's shape (image_size "auto", the API's default).
kf.pop("aspectRatio", None)
+ elif m.get("exact_size"):
+ # One {width, height} object the API rounds and clamps itself: the aspect ratio's size within the grid and limits
+ # its description states (FieldMap.size.min / max), the same size a layout is compiled for.
+ key = kf.get("aspectRatio") or "image_size"
+ spec = inputs.get(key) or {}
+ takes_object = spec.get("type") == "union" and any(isinstance(v, dict) and v.get("type") == "object" for v in spec.get("variants") or [])
+ lim = re.search(r"multiples? of (\d+) between (\d+) and (\d+)", spec.get("desc") or "")
+ if takes_object and lim:
+ fmap["size"] = {"key": key, "multiple": int(lim.group(1)), "min": int(lim.group(2)), "max": int(lim.group(3))}
+ kf.pop("aspectRatio", None)
+ opts["aspectRatios"] = union(opts.get("aspectRatios", []), IMG_AR)
+ else:
+ warn(f"{m['id']}: {ep} states no size grid and limits for its {key} object")
part4_slots(op, kf, inputs, m, opts, fmap)
# Frame rates an upscaler (or FPS Boost) can reach: params.targetFps -> its target_fps field.
if m.get("fps_targets") and op in ("interpolate", "upscale-video"):
@@ -1889,6 +1927,12 @@ def build_route(op, ep, provider, m, opts, ropts=None):
warn(f"{m['id']}: default fields {missing} not in {ep} inputs")
if not fmap["defaults"]:
del fmap["defaults"]
+ # A model that reads layouts (ModelOptions.layout) turns the API's own prompt expansion off for a layout request
+ # (FieldMap.promptExpansion), which would rewrite the boxes; a plain prompt keeps the API's default.
+ if (m["options"] or {}).get("layout"):
+ pe = kf.get("enhancePrompt") or ("enable_prompt_expansion" if "enable_prompt_expansion" in inputs else None)
+ if pe and (inputs.get(pe) or {}).get("type") == "boolean":
+ fmap["promptExpansion"] = pe
# LoRAs (O1): the field the route's LoRA endpoint (or the endpoint itself) takes them in, from the research.
# Read before the required-inputs check below: an endpoint whose LoRAs are required (MiniMax H3's /lora) fills them here.
lora_ep = ropts.get("loraEndpoint")
@@ -2008,9 +2052,14 @@ for m in M:
# What a run costs on the route's LoRA endpoint, when its price is in the same unit (fal's /lora variants cost more).
lora_eps = [r["loraEndpoint"] for r in routes if r.get("loraEndpoint")]
if pricing and lora_eps and "withLoras" not in pricing:
- lp = parse_price(EPS.get((routes[0]["provider"], lora_eps[0])) or {})
+ le = EPS.get((routes[0]["provider"], lora_eps[0])) or {}
+ lp = parse_price(le)
if lp and lp["unit"] == pricing["unit"]:
pricing["withLoras"] = lp["usd"]
+ elif (le.get("pricing") or {}).get("unit") == "unknown":
+ # No published price (fal's MOSS-Image /lora shows "$0 per compute second"): a run with LoRAs is priced as
+ # unknown, never as free.
+ pricing["lorasUnknown"] = True
d = {
"id": m["id"], "name": m["name"], "vendor": m["vendor"], "family": m["family"], "engine": "cloud",
"kind": m["kind"], "tagline": m["tagline"], "routes": routes, "options": opts,
diff --git a/src/components/studio/composer.tsx b/src/components/studio/composer.tsx
index 05b71587..611ec13c 100644
--- a/src/components/studio/composer.tsx
+++ b/src/components/studio/composer.tsx
@@ -413,6 +413,8 @@ export function Composer({ docked }: { docked: boolean }) {
(lockedModel && preset && !(engine === "open" ? preset.open : preset.cloud) ? `${preset.name} has no ${engine === "open" ? "open-source" : "cloud"} version yet` : null) ?? accessError ?? comfyBlock;
let op: Operation | undefined;
let cost: number | null = null;
+ // The run goes to a LoRA endpoint whose price isn't published (fal's MOSS-Image /lora).
+ let loraPriceUnknown = false;
let planError: string | null = null;
if (model && !engineError && !presetLoading) {
try {
@@ -432,7 +434,9 @@ export function Composer({ docked }: { docked: boolean }) {
const plan = planGeneration({ ...planned, prompt: planned.prompt || (config.promptOptional ? " " : "") }, catalog.getModel, catalog.getPreset);
op = plan.op;
// A run with LoRAs (a Soul look) goes to the route's LoRA endpoint, which has its own price.
- cost = estimateCost(plan.model, plan.params, plan.jobs, plan.op, plan.loras.length > 0 && routesFor(plan.model, plan.op).some((r) => !!r.loraEndpoint));
+ const withLoras = plan.loras.length > 0 && routesFor(plan.model, plan.op).some((r) => !!r.loraEndpoint);
+ cost = estimateCost(plan.model, plan.params, plan.jobs, plan.op, withLoras);
+ loraPriceUnknown = withLoras && !!plan.model.pricing?.lorasUnknown;
// A relight effect relights the start frame first (free on the GPU, about $0.04 in the cloud).
if (cost !== null) cost += prestepCost(preset, plan.model.id, engine);
// PixeletedFace pixelates each picture's faces afterwards ($0.01 a picture in the cloud, free on the GPU).
@@ -544,7 +548,7 @@ export function Composer({ docked }: { docked: boolean }) {
const alternative = config.comfyOnly?.alternative;
const alternativeHref = alternative && `${alternative.href}${video?.startsWith("/api/files/") ? `&video=${encodeURIComponent(video)}` : ""}`;
const demo = !!(model && status && status.demoMode !== "off" && !model.routes.some((r) => status.providers[r.provider]?.configured));
- const costText = costLabel({ demo, cost }, formatCost);
+ const costText = costLabel({ demo, cost, unknown: loraPriceUnknown }, formatCost);
// Attachments: only when something is attached, a required slot is still empty, or none of a "one of these" group is filled (U8).
const kinds = [...attach.kinds];
@@ -1016,12 +1020,18 @@ export function Composer({ docked }: { docked: boolean }) {
<Tooltip>
<TooltipTrigger asChild>
<span className="shrink-0 text-[12px] font-medium text-muted-foreground tabular-nums">
- <span className="sm:hidden">{costLabel({ demo, cost, compact: true }, formatCost)}</span>
+ <span className="sm:hidden">{costLabel({ demo, cost, compact: true, unknown: loraPriceUnknown }, formatCost)}</span>
<span className="hidden sm:inline">{costText}</span>
</span>
</TooltipTrigger>
<TooltipContent>
- {demo ? "Demo mode: no key connected for this model, so outputs are free placeholders" : cost === 0 ? "Runs on your own GPU" : "Estimated cost, billed by the provider to your key"}
+ {demo
+ ? "Demo mode: no key connected for this model, so outputs are free placeholders"
+ : cost === 0
+ ? "Runs on your own GPU"
+ : cost === null
+ ? "The provider publishes no price for this model with LoRAs yet: it bills your key at its own rate"
+ : "Estimated cost, billed by the provider to your key"}
</TooltipContent>
</Tooltip>
)}
diff --git a/src/lib/catalog/cloud-models.generated.ts b/src/lib/catalog/cloud-models.generated.ts
index 2787884b..89b58de2 100644
--- a/src/lib/catalog/cloud-models.generated.ts
+++ b/src/lib/catalog/cloud-models.generated.ts
@@ -1147,7 +1147,8 @@ export const CLOUD_MODELS: ModelDef[] = [
"endpoint": "blackforestlabs/flux-3/text-to-image",
"map": {
"aspectRatio": "aspect_ratio",
- "resolution": "resolution"
+ "resolution": "resolution",
+ "promptExpansion": "enable_prompt_expansion"
}
},
{
@@ -1157,7 +1158,8 @@ export const CLOUD_MODELS: ModelDef[] = [
"map": {
"images": "image_urls",
"aspectRatio": "aspect_ratio",
- "resolution": "resolution"
+ "resolution": "resolution",
+ "promptExpansion": "enable_prompt_expansion"
}
}
],
@@ -1186,7 +1188,8 @@ export const CLOUD_MODELS: ModelDef[] = [
"2k",
"4k"
],
- "maxImages": 10
+ "maxImages": 10,
+ "layout": "flux3"
},
"badges": [
"new"
@@ -1362,7 +1365,8 @@ export const CLOUD_MODELS: ModelDef[] = [
"4:5": "portrait_4_3"
}
},
- "resolution": "quality"
+ "resolution": "quality",
+ "promptExpansion": "enable_prompt_expansion"
}
},
{
@@ -1443,7 +1447,8 @@ export const CLOUD_MODELS: ModelDef[] = [
"very_low"
],
"maxOutputs": 4,
- "maxImages": 4
+ "maxImages": 4,
+ "layout": "ideogram"
},
"defaults": {
"aspectRatio": "1:1"
@@ -1660,6 +1665,100 @@ export const CLOUD_MODELS: ModelDef[] = [
"aspectRatio": "1:1"
}
},
+ {
+ "id": "moss-image",
+ "name": "MOSS-Image",
+ "vendor": "OpenMOSS",
+ "family": "moss",
+ "engine": "cloud",
+ "kind": "image",
+ "tagline": "Clean Chinese and English text, and it follows layout boxes",
+ "routes": [
+ {
+ "op": "t2i",
+ "provider": "fal",
+ "endpoint": "fal-ai/moss-image",
+ "map": {
+ "negativePrompt": "negative_prompt",
+ "numOutputs": "num_images",
+ "seed": "seed",
+ "size": {
+ "key": "image_size",
+ "multiple": 16,
+ "min": 512,
+ "max": 2048
+ },
+ "fixed": {
+ "output_format": "png"
+ },
+ "promptExpansion": "enable_prompt_expansion",
+ "loras": {
+ "shape": "items",
+ "key": "loras",
+ "max": 3,
+ "range": {
+ "min": 0,
+ "max": 4
+ }
+ }
+ },
+ "loraEndpoint": "fal-ai/moss-image/lora"
+ }
+ ],
+ "options": {
+ "sliders": [
+ {
+ "param": "num_inference_steps",
+ "label": "Steps",
+ "min": 1,
+ "max": 100,
+ "step": 1,
+ "default": 50
+ },
+ {
+ "param": "guidance_scale",
+ "label": "Guidance",
+ "min": 0,
+ "max": 10,
+ "step": 1,
+ "default": 3
+ }
+ ],
+ "aspectRatios": [
+ "1:1",
+ "4:3",
+ "3:4",
+ "16:9",
+ "9:16",
+ "3:2",
+ "2:3",
+ "21:9",
+ "5:4",
+ "4:5"
+ ],
+ "negativePrompt": true,
+ "seed": true,
+ "maxOutputs": 4,
+ "layout": "moss"
+ },
+ "badges": [
+ "new"
+ ],
+ "licence": {
+ "licence": "Apache-2.0",
+ "commercial": true,
+ "note": "Apache-2.0 weights (OpenMOSS-Team/MOSS-Image-SFT); hosted under fal's terms. fal's safety checker returns a black image when it flags an output",
+ "checked": "2026-10-29"
+ },
+ "defaults": {
+ "aspectRatio": "1:1"
+ },
+ "pricing": {
+ "unit": "megapixel",
+ "usd": 0.05,
+ "lorasUnknown": true
+ }
+ },
{
"id": "wan-2-7-image",
"name": "Wan 2.7 Image",
@@ -16645,7 +16744,8 @@ export const CLOUD_MODELS: ModelDef[] = [
"16:10",
"21:9"
],
- "maxImages": 4
+ "maxImages": 4,
+ "layout": "vgl"
},
"badges": [
"new"
diff --git a/src/lib/catalog/models.ts b/src/lib/catalog/models.ts
index 84feb777..31c1cf42 100644
--- a/src/lib/catalog/models.ts
+++ b/src/lib/catalog/models.ts
@@ -52,6 +52,24 @@ const TRYON_LORA = loraEntry("tryon-klein-4b");
/** The try-on LoRA card's own instruction, for a run with no words. */
export const TRYON_PROMPT = "a full-body photo of a person. Replace the outfit with the top and bottom as shown in the reference images. The final image is a full body shot.";
+/**
+ * MOSS-Image's sampler settings on your GPU (the graph's own defaults are Standard): Standard is Comfy's template
+ * (25 steps, CFG 2.5, er_sde), Quality OpenMOSS's guide (50 steps, CFG 3, euler), Fast Spectrallic's SFT with the
+ * 8-step DMD LoRA merged in (8 steps, CFG 1; a 5.4 GB file of its own; untested on layouts).
+ */
+const MOSS_QUALITY: NonNullable<ModelOptions["controls"]>[number] = {
+ param: "quality",
+ label: "Quality",
+ values: ["standard", "quality", "fast"],
+ default: "standard",
+ labels: { standard: "Standard · 25 steps", quality: "Best · 50 steps", fast: "Fast · 8 steps (extra 5.4 GB file)" },
+ sets: {
+ standard: { steps: 25, cfg: 2.5, sampler: "er_sde", scheduler: "simple" },
+ quality: { steps: 50, cfg: 3, sampler: "euler", scheduler: "simple" },
+ fast: { steps: 8, cfg: 1, sampler: "euler", scheduler: "simple", unet: "moss_image_sft_8stepdmd_int8_convrot.safetensors" },
+ },
+};
+
type OpenSpec = Omit<ModelDef, "engine" | "badges"> & { badges?: ModelDef["badges"] };
const o = (m: OpenSpec): ModelDef => ({ ...m, engine: "open", badges: ["open", ...(m.badges ?? [])] });
@@ -171,6 +189,27 @@ const open: ModelDef[] = [
options: { aspectRatios: IMG_AR, seed: true, negativePrompt: true },
defaults: { aspectRatio: "1:1" },
}),
+ // MOSS-Image (OpenMOSS, Apache-2.0; research #7 §4.6): plain words, or a layout of boxes compiled to its JSON
+ // (src/lib/layout-prompt.ts). The cloud half is `moss-image` on fal.
+ o({
+ id: "oss-moss-image",
+ name: "MOSS-Image",
+ vendor: "OpenMOSS",
+ family: "moss",
+ kind: "image",
+ tagline: "Clean Chinese and English text, follows layout boxes · on your GPU, about 13 GB of files",
+ badges: ["new"],
+ routes: [comfy("t2i", "moss-image-t2i", "MOSS-Image SFT int8, Qwen3.5-9B w4a8, FLUX.2 small decoder; core nodes")],
+ options: {
+ aspectRatios: IMG_AR,
+ resolutions: ["1K", "1.5K"],
+ seed: true,
+ negativePrompt: true,
+ layout: "moss",
+ controls: [MOSS_QUALITY],
+ },
+ defaults: { aspectRatio: "1:1", resolution: "1K" },
+ }),
o({
id: "oss-qwen-edit",
name: "Qwen-Image-Edit 2511",
diff --git a/src/lib/catalog/payload.ts b/src/lib/catalog/payload.ts
index 14c6f8f8..c4ce64ea 100644
--- a/src/lib/catalog/payload.ts
+++ b/src/lib/catalog/payload.ts
@@ -1,5 +1,6 @@
import { readTimeline, timelineTracks } from "@/lib/av/timeline";
import { upscaleFactorFor } from "@/lib/av/upscale";
+import { carriesLayout, LAYOUT_PARAM } from "@/lib/layout-prompt";
import { loraFields } from "./loras";
import { OPERATION_OUTPUT, type DurationField, type EnumField, type FieldMap, type GenInput, type MatteOutput, type MediaKind, type Operation, type PixelPoint } from "./types";
@@ -103,25 +104,52 @@ export function framedLength(f: FieldMap["numFrames"] | undefined, seconds: numb
/**
* Width and height for an aspect ratio (FieldMap.size): the table's size for the tier and shape when it has one
- * (Fuobe Soul: its first tier when the tier is unknown), else the shape on a `base`×`base` pixel budget; neither
- * side above `max` (Replicate's Z-Image takes 1440).
+ * (Fuobe Soul: its first tier when the tier is unknown), else the shape on a `base`×`base` pixel budget; or the size
+ * the request asks for (`asked`: a layout's canvas) on the route's grid. Neither side above `max` (Replicate's Z-Image
+ * takes 1440) nor below `min` (fal's MOSS-Image takes 512–2048): the shape is scaled to fit, then a side that still
+ * can't keep it is held at the limit.
*/
-export function sizeValue(f: NonNullable<FieldMap["size"]>, aspectRatio: string | undefined, resolution?: string): { width: number; height: number } {
+export function sizeValue(
+ f: NonNullable<FieldMap["size"]>,
+ aspectRatio: string | undefined,
+ resolution?: string,
+ asked?: { width: number; height: number },
+): { width: number; height: number } {
const base = f.base ?? 1024;
const ratio = (aspectRatio && ratioOf(aspectRatio)) || 1;
const round = (v: number) => Math.max(f.multiple, Math.round(v / f.multiple) * f.multiple);
const tier = f.table && (f.table[resolution ?? ""] ?? Object.values(f.table)[0]);
const exact = tier && aspectRatio ? tier[aspectRatio] : undefined;
- let width = exact ? exact[0] : round(base * Math.sqrt(ratio));
- let height = exact ? exact[1] : round(base / Math.sqrt(ratio));
+ let width = asked ? round(asked.width) : exact ? exact[0] : round(base * Math.sqrt(ratio));
+ let height = asked ? round(asked.height) : exact ? exact[1] : round(base / Math.sqrt(ratio));
if (f.max !== undefined && Math.max(width, height) > f.max) {
const k = f.max / Math.max(width, height);
width = Math.min(f.max, round(width * k));
height = Math.min(f.max, round(height * k));
}
+ if (f.min !== undefined && Math.min(width, height) < f.min) {
+ // The smallest side the grid allows at or above the minimum (512 on a 16 grid).
+ const least = Math.ceil(f.min / f.multiple) * f.multiple;
+ const k = least / Math.min(width, height);
+ width = Math.max(least, round(width * k));
+ height = Math.max(least, round(height * k));
+ if (f.max !== undefined) {
+ const most = Math.floor(f.max / f.multiple) * f.multiple;
+ width = Math.min(most, width);
+ height = Math.min(most, height);
+ }
+ }
return { width, height };
}
+/** A {width, height} the request asks for (params.extra[key]: a layout's canvas), if it gives one. */
+export function askedSize(value: unknown): { width: number; height: number } | undefined {
+ const v = value as { width?: unknown; height?: unknown } | null | undefined;
+ const width = Number(v?.width);
+ const height = Number(v?.height);
+ return v && typeof v === "object" && Number.isFinite(width) && Number.isFinite(height) && width > 0 && height > 0 ? { width, height } : undefined;
+}
+
/** Path segments that would reach Object.prototype (or a constructor) instead of the payload. */
const UNSAFE_KEYS = new Set(["__proto__", "constructor", "prototype"]);
@@ -358,8 +386,10 @@ export function buildPayload(map: FieldMap, input: GenInput): Record<string, unk
if (map.styleId && input.styleId) out[map.styleId] = input.styleId;
if (map.numLayers && input.numLayers !== undefined) out[map.numLayers] = input.numLayers;
if (map.palette && input.palette?.length) out[map.palette.key] = paletteValue(map.palette.format, input.palette);
+ // An object size field the request fills itself (a layout's canvas) is kept on the route's grid and limits.
+ const asked = map.size?.key ? askedSize(input.extra?.[map.size.key]) : undefined;
if (map.size) {
- const { width, height } = sizeValue(map.size, input.aspectRatio, input.resolution);
+ const { width, height } = sizeValue(map.size, input.aspectRatio, input.resolution, asked);
if (map.size.key) out[map.size.key] = { width, height };
if (map.size.width) out[map.size.width] = width;
if (map.size.height) out[map.size.height] = height;
@@ -422,8 +452,11 @@ export function buildPayload(map: FieldMap, input: GenInput): Record<string, unk
// 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);
- const ignore = new Set(map.ignore ?? []);
+ // A layout draft rides in params.extra for Reuse and Edit layout; the prompt already carries it, in the model's own form.
+ const ignore = new Set([...(map.ignore ?? []), LAYOUT_PARAM, ...(asked ? [map.size!.key!] : [])]);
for (const [k, v] of Object.entries({ ...map.fixed, ...input.extra })) if (!(map.timeline && k === "timeline") && !ignore.has(k)) setPath(out, k, v);
+ // The API's prompt expansion would rewrite a layout's boxes: off whenever the request carries one.
+ if (map.promptExpansion && carriesLayout(input.extra)) out[map.promptExpansion] = false;
// 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 847451da..8a288cb8 100644
--- a/src/lib/catalog/plan.ts
+++ b/src/lib/catalog/plan.ts
@@ -15,7 +15,7 @@ import { sourceSeconds } from "./clip-windows";
import { chainGapProblem, chainTiming, FIRST_AT_ZERO, frameTimes, keyframeChain, MAX_KEYFRAMES, spread } from "./keyframes";
import { cloudPath, fitLoras, gated, localOnly, loraCapacity, needsToken, routeLoraField, triggerOf } from "./loras";
import { anglesPrompt, anglesWords, ANGLES_ORIGINAL } from "./open-tools";
-import { numFramesValue, sizeValue } from "./payload";
+import { askedSize, numFramesValue, sizeValue } from "./payload";
import { characterScale, CINEMA_CROP, soulKind, soulMegapixels, soulRecipe, soulSize, type SoulOverlay } from "./soul";
/** Infer the operation from what the user attached. */
@@ -395,6 +395,8 @@ export function planGeneration(
params = { ...params, extra: Object.keys(rest).length ? rest : undefined };
}
+ params = controlSets(model, params);
+
const requested = Math.max(1, Math.min(8, params.numOutputs ?? 1));
const maxPerJob = Math.max(1, model.options.maxOutputs ?? 1);
const perJobOutputs = Math.min(requested, maxPerJob);
@@ -412,6 +414,24 @@ export function planGeneration(
};
}
+/**
+ * A control whose value stands for several settings (ModelOptions.controls[].sets: MOSS-Image's Quality is 50 steps,
+ * CFG 3 and euler on your GPU) writes them into params.extra in its own place; a setting the request gives itself wins.
+ * The request as asked (Reuse) keeps the control's value.
+ */
+export function controlSets(model: ModelDef, params: GenParams): GenParams {
+ const controls = (model.options.controls ?? []).filter((c) => c.sets);
+ if (!controls.length) return params;
+ const extra: Record<string, unknown> = { ...params.extra };
+ for (const c of controls) {
+ const value = extra[c.param] ?? c.default;
+ delete extra[c.param];
+ const chosen = value === undefined || value === null ? undefined : c.sets?.[String(value)];
+ for (const [k, v] of Object.entries(chosen ?? {})) if (!(k in extra)) extra[k] = v;
+ }
+ return { ...params, extra: Object.keys(extra).length ? extra : undefined };
+}
+
/**
* Remove background and Depth map options (Higgsfield's Video tools): what to keep, the cut-out or its alpha mask,
* the colour map and side by side, each checked against what the model makes, so nothing is quietly swapped.
@@ -687,10 +707,25 @@ function sentMegapixels(params: GenParams): number | undefined {
return Number.isFinite(w) && Number.isFinite(h) && w > 0 && h > 0 ? (w * h) / (1024 * 1024) : undefined;
}
+/**
+ * The megapixels the run's route makes when it sends a size (FieldMap.size: fal's MOSS-Image image_size): the aspect
+ * ratio's size, or the size asked for (a layout's canvas) kept on the route's grid and within its limits, as the
+ * payload sends it. fal's megapixel is 1024 × 1024 pixels. Undefined when the route sends no size.
+ */
+function routeMegapixels(model: ModelDef, params: GenParams, op?: Operation): number | undefined {
+ const size = (op ? model.routes.find((r) => r.op === op) : model.routes[0])?.map?.size;
+ if (!size) return undefined;
+ const asked = size.key ? askedSize(params.extra?.[size.key]) : undefined;
+ const { width, height } = sizeValue(size, params.aspectRatio ?? model.defaults?.aspectRatio, params.resolution ?? model.defaults?.resolution, asked);
+ return (width * height) / (1024 * 1024);
+}
+
/** Rough USD estimate for a plan (BYO-key cloud runs). Open-source runs are free. */
export function estimateCost(model: ModelDef, params: GenParams, jobs = 1, op?: Operation, withLoras = false): number | null {
if (model.engine === "open" || !model.pricing) return model.engine === "open" ? 0 : null;
const p = model.pricing;
+ // A LoRA endpoint with no published price (fal's MOSS-Image /lora): unknown, never free.
+ if (withLoras && p.lorasUnknown) return null;
const n = params.numOutputs ?? 1;
const res = params.resolution ?? model.defaults?.resolution;
// A run with LoRAs goes to the LoRA endpoint, which has its own price.
@@ -704,7 +739,9 @@ export function estimateCost(model: ModelDef, params: GenParams, jobs = 1, op?:
// Per megapixel of every image made: Soul's sizes are known (about 1 or 2 MP), so is a size sent as fal's image_size
// {width, height} (Fuobe Mixed Media's frames); other models are taken as 1 MP.
if (p.unit === "megapixel") {
- const mp = soulKind(model) ? soulMegapixels(params.aspectRatio ?? model.defaults?.aspectRatio, params.resolution ?? model.defaults?.resolution) : (sentMegapixels(params) ?? 1);
+ const mp = soulKind(model)
+ ? soulMegapixels(params.aspectRatio ?? model.defaults?.aspectRatio, params.resolution ?? model.defaults?.resolution)
+ : (routeMegapixels(model, params, op) ?? sentMegapixels(params) ?? 1);
per = usd * (p.roundUp ? Math.ceil(mp - 1e-9) : mp) * n;
}
if (p.unit === "second") {
diff --git a/src/lib/composer.ts b/src/lib/composer.ts
index aa285b45..25c1c0f0 100644
--- a/src/lib/composer.ts
+++ b/src/lib/composer.ts
@@ -971,11 +971,12 @@ export function toggleIn(list: string[], id: string): string[] {
// ---------------------------------------------------------------------------
// Cost hint
-export function costLabel(s: { demo: boolean; cost: number | null; compact?: boolean }, format: (usd: number) => string): string {
+export function costLabel(s: { demo: boolean; cost: number | null; compact?: boolean; unknown?: boolean }, format: (usd: number) => string): string {
if (s.demo) return s.compact ? "Demo" : "Demo · free";
if (s.cost === 0) return "Free";
if (s.cost != null) return `≈ ${format(s.cost)}`;
- return "";
+ // A price the provider hasn't published (fal's MOSS-Image with LoRAs): said, never shown as free.
+ return s.unknown ? "Price unknown" : "";
}
/** Prompts with an @mention: spellcheck would underline every handle. */
diff --git a/src/lib/studios.ts b/src/lib/studios.ts
index ca0b04ab..cfc8e515 100644
--- a/src/lib/studios.ts
+++ b/src/lib/studios.ts
@@ -18,6 +18,8 @@ export const IMAGE_STUDIO: StudioConfig = {
slots: [],
multiRef: { label: "Add ref", max: 8 },
defaultModels: { cloud: "nano-banana-pro", open: "oss-z-image-turbo" },
+ // A model's own settings (MOSS-Image's Quality, Ideogram's speed) sit under "Options".
+ controlsTitle: "Options",
// Color signature + Moodboard chips, and the models they can move a request to. Fuobe Soul's PixeletedFace look runs
// the face mosaic after the picture: its step's model is known here so the price counts it before the run.
signature: true,
diff --git a/src/server/assist/tools.ts b/src/server/assist/tools.ts
index 30e4c927..bcee7d98 100644
--- a/src/server/assist/tools.ts
+++ b/src/server/assist/tools.ts
@@ -62,7 +62,7 @@ function summarize(m: ModelDef) {
? "free (your machine)"
: "free (your GPU)"
: m.pricing
- ? `$${m.pricing.usd} per ${m.pricing.unit}${m.pricing.note ? ` — ${m.pricing.note}` : ""}`
+ ? `$${m.pricing.usd} per ${m.pricing.unit}${m.pricing.note ? ` — ${m.pricing.note}` : ""}${m.pricing.lorasUnknown ? "; with LoRAs the price is unknown (not published yet)" : ""}`
: "unknown",
connected: configured,
...(o.aspectRatios && { aspectRatios: o.aspectRatios }),
diff --git a/src/server/model-access.ts b/src/server/model-access.ts
index b4783d62..4eafabbc 100644
--- a/src/server/model-access.ts
+++ b/src/server/model-access.ts
@@ -262,7 +262,10 @@ export function modelLicence(m: ModelDef): { licence: LicenceInfo; cloud?: Licen
const cloudRoutes = cloud.filter((r) => r.provider !== "llm");
const cloudLicence = cloudRoutes.length ? paidApiLicence(m.vendor, cloudRoutes) : cloud.length ? routeLicence(cloud[0], m) : undefined;
if (openLicence) return { licence: openLicence, ...(cloudLicence && { cloud: cloudLicence }), packs };
- return { licence: cloudLicence ?? { name: "Not recorded", class: "unknown", note: "" }, packs };
+ // A hosted open model (fal's MOSS-Image) says what its weights are and what the research noted about the host.
+ const stop = (t: string) => t.trim().replace(/\.?$/, ".");
+ const weights = m.licence && cloudLicence?.class === "paid-api" ? ` Weights: ${stop(m.licence.note ?? m.licence.licence)}` : "";
+ return { licence: cloudLicence ? { ...cloudLicence, note: weights ? `${stop(cloudLicence.note)}${weights}` : cloudLicence.note } : { name: "Not recorded", class: "unknown", note: "" }, packs };
}
/** The presets a map key names: a map v2 preset id, or a round-1 slug (the motion, effect or app it matches). */
diff --git a/tests/cloud-catalog.test.ts b/tests/cloud-catalog.test.ts
index 70da06d0..ffd5cb3c 100644
--- a/tests/cloud-catalog.test.ts
+++ b/tests/cloud-catalog.test.ts
@@ -11,6 +11,10 @@ const research = ["paid-model-apis.json", "paid-model-apis-2.json", "paid-model-
);
const byId = new Map<string, Endpoint>();
for (const e of research) byId.set(`${e.provider}:${e.endpoint}`, { ...byId.get(`${e.provider}:${e.endpoint}`), ...e });
+// Research #7 (MOSS-Image on fal and its /lora twin): endpointRecords in the shape of part 4's endpoints.
+for (const e of (JSON.parse(fs.readFileSync("docs/research/new-models-7.json", "utf8")) as { endpointRecords: Endpoint[] }).endpointRecords) {
+ byId.set(`${e.provider}:${e.endpoint}`, { ...byId.get(`${e.provider}:${e.endpoint}`), ...e });
+}
// Originals (O1): the hosted open-weight endpoints that take LoRAs, and the plain endpoints of the same models.
const originals = JSON.parse(fs.readFileSync("docs/research/fuobe-originals-recipes-5.json", "utf8")) as {
hostedLoraEndpoints: (Endpoint & { id: string })[];
diff --git a/tests/composer.test.ts b/tests/composer.test.ts
index 76595385..fa5c748e 100644
--- a/tests/composer.test.ts
+++ b/tests/composer.test.ts
@@ -288,6 +288,9 @@ describe("cost and mentions", () => {
expect(costLabel({ demo: false, cost: 0 }, fmt)).toBe("Free");
expect(costLabel({ demo: false, cost: 0.4 }, fmt)).toBe("≈ $0.40");
expect(costLabel({ demo: false, cost: null }, fmt)).toBe("");
+ // A price the provider hasn't published (fal's MOSS-Image with LoRAs) is said, never shown as free.
+ expect(costLabel({ demo: false, cost: null, unknown: true }, fmt)).toBe("Price unknown");
+ expect(costLabel({ demo: false, cost: null, unknown: true, compact: true }, fmt)).toBe("Price unknown");
});
it("spots @mentions (spellcheck off)", () => {
expect(hasMention("@Koi_Pond_Night at dusk")).toBe(true);
diff --git a/tests/moss-image.test.ts b/tests/moss-image.test.ts
new file mode 100644
index 00000000..6780ec32
--- /dev/null
+++ b/tests/moss-image.test.ts
@@ -0,0 +1,175 @@
+import fs from "node:fs";
+import os from "node:os";
+import path from "node:path";
+import { afterAll, describe, expect, it } from "vitest";
+import { getModel, getPreset } from "@/lib/catalog";
+import { buildPayload, sizeValue } from "@/lib/catalog/payload";
+import { controlSets, estimateCost, planGeneration, routesFor } from "@/lib/catalog/plan";
+import type { GenerationRequest, ModelRoute } from "@/lib/catalog/types";
+import { layoutCompilerFor, type LayoutDraft } from "@/lib/layout-prompt";
+
+// N7-1 (docs/research/new-models-7.md §4.7): MOSS-Image on fal from research #7's endpointRecords, priced per megapixel, and
+// on your GPU; the layout flag on the models that read layouts; the Settings → Models & licences rows.
+const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "fuobe-moss-"));
+process.env.FUOBE_DATA_DIR = tmp;
+const { modelLicence, accessList } = await import("@/server/model-access");
+afterAll(() => fs.rmSync(tmp, { recursive: true, force: true }));
+
+type Spec = { type?: string; values?: unknown[]; minimum?: number; maximum?: number; default?: unknown; desc?: string; maxItems?: number; itemSchema?: Record<string, Spec> };
+type Record7 = { endpoint: string; provider: string; inputs: Record<string, Spec>; pricing: { usd: number | null; unit: string } };
+const records = (JSON.parse(fs.readFileSync("docs/research/new-models-7.json", "utf8")) as { endpointRecords: Record7[] }).endpointRecords;
+const BASE = records.find((r) => r.endpoint === "fal-ai/moss-image")!;
+const LORA = records.find((r) => r.endpoint === "fal-ai/moss-image/lora")!;
+
+const cloud = getModel("moss-image")!;
+const open = getModel("oss-moss-image")!;
+const route = cloud.routes[0] as ModelRoute & { map: NonNullable<ModelRoute["map"]> };
+const poster: LayoutDraft = {
+ summary: { caption: "A candle sale poster", meta: [], canvas: "single" },
+ items: [{ label: "text", caption: "Bold serif.", text: "30% OFF", box: [0.1, 0.05, 0.9, 0.2] }],
+};
+const plan = (req: Partial<GenerationRequest>) => planGeneration({ feature: "image", op: "t2i", prompt: "a poster", ...req } as GenerationRequest, getModel, getPreset);
+const payload = (params: GenerationRequest["params"] = {}, prompt = "a poster") => {
+ const p = plan({ modelId: "moss-image", prompt, params });
+ return buildPayload(route.map, { prompt: p.prompt, ...p.params });
+};
+
+describe("moss-image on fal", () => {
+ it("is built from research #7's endpoint records: every field it sends is in fal's schema", () => {
+ expect(cloud).toMatchObject({ engine: "cloud", kind: "image", vendor: "OpenMOSS", family: "moss", name: "MOSS-Image" });
+ expect(routesFor(cloud, "t2i").map((r) => [r.provider, r.endpoint, r.loraEndpoint])).toEqual([["fal", "fal-ai/moss-image", "fal-ai/moss-image/lora"]]);
+ const m = route.map;
+ expect(m.size).toEqual({ key: "image_size", multiple: 16, min: 512, max: 2048 });
+ expect(BASE.inputs.image_size.desc).toMatch(/multiples of 16 between 512 and 2048/);
+ expect([m.negativePrompt, m.numOutputs, m.seed, m.promptExpansion]).toEqual(["negative_prompt", "num_images", "seed", "enable_prompt_expansion"]);
+ for (const k of [m.negativePrompt, m.numOutputs, m.seed, m.promptExpansion, m.size!.key!, ...Object.keys(m.fixed ?? {})]) expect(BASE.inputs[k!], k).toBeDefined();
+ expect(BASE.inputs.output_format.values).toContain(m.fixed!.output_format);
+ expect(m.fixed).toEqual({ output_format: "png" });
+ expect(BASE.inputs.num_images).toMatchObject({ minimum: 1, maximum: 4 });
+ expect(cloud.options.maxOutputs).toBe(4);
+ // Steps and guidance are fal's own fields, with fal's range and default.
+ expect(cloud.options.sliders).toEqual([
+ { param: "num_inference_steps", label: "Steps", min: 1, max: 100, step: 1, default: 50 },
+ { param: "guidance_scale", label: "Guidance", min: 0, max: 10, step: 1, default: 3 },
+ ]);
+ expect(BASE.inputs.num_inference_steps).toMatchObject({ minimum: 1, maximum: 100, default: 50 });
+ expect(BASE.inputs.guidance_scale).toMatchObject({ minimum: 0, maximum: 10, default: 3 });
+ // LoRAs go through the /lora twin: up to 3 of {path, scale 0-4}.
+ expect(m.loras).toEqual({ shape: "items", key: "loras", max: 3, range: { min: 0, max: 4 } });
+ expect(LORA.inputs.loras).toMatchObject({ maxItems: 3, itemSchema: { scale: { minimum: 0, maximum: 4 } } });
+ });
+
+ it("sends image_size {width, height} on fal's 16-pixel grid, kept within 512-2048", () => {
+ expect(payload({ aspectRatio: "1:1" }).image_size).toEqual({ width: 1024, height: 1024 });
+ expect(payload({ aspectRatio: "16:9" }).image_size).toEqual({ width: 1360, height: 768 });
+ expect(payload({ aspectRatio: "21:9" }).image_size).toEqual({ width: 1568, height: 672 });
+ // A layout's canvas, asked for exactly: kept when it fits, else fitted to the grid and the limits.
+ expect(payload({ extra: { image_size: { width: 1536, height: 1024 } } }).image_size).toEqual({ width: 1536, height: 1024 });
+ expect(payload({ extra: { image_size: { width: 1000, height: 1000 } } }).image_size).toEqual({ width: 1008, height: 1008 });
+ expect(payload({ extra: { image_size: { width: 4096, height: 4096 } } }).image_size).toEqual({ width: 2048, height: 2048 });
+ expect(payload({ extra: { image_size: { width: 2400, height: 400 } } }).image_size).toEqual({ width: 2048, height: 512 });
+ expect(payload({ extra: { image_size: { width: 320, height: 320 } } }).image_size).toEqual({ width: 512, height: 512 });
+ for (const ar of ["1:1", "4:3", "3:4", "16:9", "9:16", "3:2", "2:3", "21:9", "5:4", "4:5"]) {
+ const { width, height } = payload({ aspectRatio: ar }).image_size as { width: number; height: number };
+ expect([width % 16, height % 16], ar).toEqual([0, 0]);
+ expect(Math.min(width, height), ar).toBeGreaterThanOrEqual(512);
+ expect(Math.max(width, height), ar).toBeLessThanOrEqual(2048);
+ }
+ expect(payload().output_format).toBe("png");
+ });
+
+ it("turns fal's prompt expansion off for a layout, and leaves fal's default for plain words", () => {
+ expect(BASE.inputs.enable_prompt_expansion).toMatchObject({ type: "boolean", default: true });
+ const plain = payload({ aspectRatio: "1:1" });
+ expect(plain).not.toHaveProperty("enable_prompt_expansion");
+ const compiled = layoutCompilerFor(cloud)(poster, 1024, 1024);
+ expect(compiled.format).toBe("moss");
+ const laid = payload({ extra: { layout: poster, image_size: { width: 1024, height: 1024 } } }, compiled.prompt);
+ expect(laid.enable_prompt_expansion).toBe(false);
+ expect(laid.prompt).toBe(compiled.prompt);
+ // The draft rides along for Reuse; it is never sent as a field.
+ expect(laid).not.toHaveProperty("layout");
+ });
+
+ it("puts LoRAs in the /lora endpoint's loras field", () => {
+ const out = buildPayload(route.map, { prompt: "a poster", loras: [{ file: "moss-style.safetensors", url: "https://example.com/moss-style.safetensors", strength: 5 }] });
+ expect(out.loras).toEqual([{ path: "https://example.com/moss-style.safetensors", scale: 4 }]);
+ });
+
+ it("costs $0.05 per megapixel of fal's 1024 × 1024 megapixel; a LoRA run's price is unknown, never free", () => {
+ expect(BASE.pricing).toMatchObject({ usd: 0.05, unit: "megapixel" });
+ expect(cloud.pricing).toEqual({ unit: "megapixel", usd: 0.05, lorasUnknown: true });
+ expect(estimateCost(cloud, { aspectRatio: "1:1" }, 1, "t2i")).toBe(0.05);
+ expect(estimateCost(cloud, { extra: { image_size: { width: 1536, height: 1024 } } }, 1, "t2i")).toBe(0.075);
+ expect(estimateCost(cloud, { aspectRatio: "1:1", numOutputs: 2 }, 1, "t2i")).toBe(0.1);
+ expect(LORA.pricing).toMatchObject({ usd: null, unit: "unknown" });
+ expect(estimateCost(cloud, { aspectRatio: "1:1" }, 1, "t2i", true)).toBeNull();
+ // Other per-megapixel models keep their 1-megapixel estimate (no size field on their route).
+ expect(estimateCost(getModel("flux-2-pro")!, { aspectRatio: "16:9" }, 1, "t2i")).toBe(0.03);
+ });
+});
+
+describe("oss-moss-image on your GPU", () => {
+ it("runs the core-node graph, free, with its size on the picker", () => {
+ expect(open).toMatchObject({ engine: "open", kind: "image", vendor: "OpenMOSS", family: "moss" });
+ expect(open.routes.map((r) => [r.op, r.provider, r.endpoint])).toEqual([["t2i", "comfyui", "moss-image-t2i"]]);
+ expect(open.tagline).toMatch(/on your GPU, about 13 GB of files/);
+ expect(open.options).toMatchObject({ layout: "moss", seed: true, negativePrompt: true, resolutions: ["1K", "1.5K"] });
+ expect(estimateCost(open, { aspectRatio: "1:1" })).toBe(0);
+ });
+
+ it("Quality stands for the sampler settings; a setting the request gives wins", () => {
+ const at = (extra?: Record<string, unknown>) => plan({ modelId: "oss-moss-image", params: { aspectRatio: "1:1", ...(extra && { extra }) } }).params.extra;
+ expect(at()).toEqual({ steps: 25, cfg: 2.5, sampler: "er_sde", scheduler: "simple" });
+ expect(at({ quality: "quality" })).toEqual({ steps: 50, cfg: 3, sampler: "euler", scheduler: "simple" });
+ expect(at({ quality: "fast" })).toEqual({ steps: 8, cfg: 1, sampler: "euler", scheduler: "simple", unet: "moss_image_sft_8stepdmd_int8_convrot.safetensors" });
+ expect(at({ quality: "quality", steps: 60 })).toMatchObject({ steps: 60, cfg: 3 });
+ // A model without such a control is left alone.
+ expect(controlSets(cloud, { extra: { num_inference_steps: 30 } })).toEqual({ extra: { num_inference_steps: 30 } });
+ });
+});
+
+describe("the models that read layouts", () => {
+ it("flags MOSS-Image on both engines, FLUX.3, Ideogram 4.5 and Bria FIBO 2", () => {
+ expect(Object.fromEntries(["oss-moss-image", "moss-image", "flux-3", "ideogram-4-5", "bria-fibo-2", "nano-banana-pro"].map((id) => [id, getModel(id)!.options.layout ?? null]))).toEqual({
+ "oss-moss-image": "moss",
+ "moss-image": "moss",
+ "flux-3": "flux3",
+ "ideogram-4-5": "ideogram",
+ "bria-fibo-2": "vgl",
+ "nano-banana-pro": null,
+ });
+ // FLUX.3's and Ideogram's own prompt expansion is turned off for a layout too; Bria has none.
+ expect(getModel("flux-3")!.routes.map((r) => r.map?.promptExpansion)).toEqual(["enable_prompt_expansion", "enable_prompt_expansion"]);
+ expect(routesFor(getModel("ideogram-4-5")!, "t2i")[0].map?.promptExpansion).toBe("enable_prompt_expansion");
+ expect(getModel("bria-fibo-2")!.routes.every((r) => !r.map?.promptExpansion)).toBe(true);
+ });
+});
+
+describe("Settings → Models & licences", () => {
+ it("shows the open weights' licence, and fal's route as a paid API with the host's catch", () => {
+ const o = modelLicence(open);
+ expect(o.licence).toMatchObject({ class: "commercial" });
+ expect(o.licence.name).toMatch(/Apache-2\.0/);
+ expect(o.packs).toEqual([]);
+ const c = modelLicence(cloud);
+ expect(c.licence).toMatchObject({ class: "paid-api", name: "Paid API · fal.ai" });
+ expect(c.licence.note).toMatch(/Weights: Apache-2\.0 weights \(OpenMOSS-Team\/MOSS-Image-SFT\); hosted under fal's terms\. fal's safety checker returns a black image when it flags an output\.$/);
+ });
+
+ it("lists both, switched on", () => {
+ const rows = accessList()
+ .models.filter((m) => m.id === "oss-moss-image" || m.id === "moss-image")
+ .map((r) => [r.id, r.on, r.offBy, r.engines])
+ .sort();
+ expect(rows).toEqual([
+ ["moss-image", true, [], ["cloud"]],
+ ["oss-moss-image", true, [], ["open"]],
+ ]);
+ });
+
+ it("the size the price and the payload use is the same", () => {
+ const size = route.map.size!;
+ expect(sizeValue(size, "3:2")).toEqual(payload({ aspectRatio: "3:2" }).image_size);
+ });
+});
diff --git a/tests/open-engine.test.ts b/tests/open-engine.test.ts
index b7a539cf..9c3e154b 100644
--- a/tests/open-engine.test.ts
+++ b/tests/open-engine.test.ts
@@ -124,7 +124,11 @@ describe("round-3 open models", () => {
const ids = r.endpoint.includes("{n}") ? ["2", "3", "4"].map((n) => r.endpoint.replace("{n}", n)) : [r.endpoint];
for (const wid of ids) {
const keys = Object.keys(workflowById.get(wid)?.bindings ?? {});
- for (const p of [...(m.options.sliders ?? []), ...(m.options.controls ?? [])].map((s) => s.param)) {
+ // A control that stands for several settings (MOSS-Image's Quality) is the settings it writes.
+ const params = [...(m.options.sliders ?? []), ...(m.options.controls ?? [])].flatMap((s) =>
+ "sets" in s && s.sets ? [...new Set(Object.values(s.sets).flatMap((v) => Object.keys(v)))] : [s.param],
+ );
+ for (const p of params) {
// Fuobe Angles' camera fields become the Multiple-angles LoRA's words in the planner (src/lib/catalog/open-tools.ts).
if (!PROVIDER_PARAMS.has(p) && p !== "cameraMotion" && !(m.id === ANGLES_ORIGINAL && (ANGLES_FIELDS as readonly string[]).includes(p))) expect(keys, `${m.id} → ${wid}: ${p}`).toContain(p);
}