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.

FLUX 3 Klein on your GPU and as a Soul ID target: the Image and Edit studios' Best lists, Prompt helper, 10 references

Claude5332d982e3f5
diff --git a/scripts/gen-cloud-models.py b/scripts/gen-cloud-models.py
index 4fa13926..c2b40caf 100644
--- a/scripts/gen-cloud-models.py
+++ b/scripts/gen-cloud-models.py
@@ -226,14 +226,14 @@ KLEIN_FAL = "blackforestlabs/flux-3/klein"
KLEIN_REC = next(e for e in NEW_MODELS_10["endpointRecords"] if e["endpoint"] == f"{KLEIN_FAL}/text-to-image")
KLEIN_LICENCE = {"licence": KLEIN_REC["license"].split(":")[0], "commercial": None, "note": KLEIN_REC["license"], "checked": KLEIN_REC["fetched"]}
model("flux-3-klein", "FLUX 3 Klein", "Black Forest Labs", "flux", "image",
- "BFL's open 5.6B model: text to image, edits with up to 10 references, layout boxes",
+ "BFL's open 5.6B model, hosted: up to 4K, edits with up to 10 references, layout boxes; fal writes the full caption · FLUX Kommunity licence",
[("t2i", f"{KLEIN_FAL}/text-to-image", "fal", {"loraEndpoint": f"{KLEIN_FAL}/text-to-image/lora"}),
("edit", f"{KLEIN_FAL}/edit-image", "fal", {"loraEndpoint": f"{KLEIN_FAL}/edit-image/lora"})],
badges=["new"], defaults={"aspectRatio": "1:1", "resolution": "1K"}, tier_size=f"{KLEIN_FAL}/text-to-image", options={"layout": "flux3"},
pricing=("image", KLEIN_REC["pricing"]["usd"], "per image at 1K (fal's planned rates by size)", {"byResolution": KLEIN_REC["pricing"]["byResolution"]}),
licence=KLEIN_LICENCE)
model("flux-3-klein-base", "FLUX 3 Klein Base with LoRAs", "Black Forest Labs", "flux", "image",
- "The undistilled Klein your FLUX 3 Klein LoRAs are trained on: text to image and edits with them",
+ "The undistilled Klein your FLUX 3 Klein LoRAs are trained on, hosted: up to 3 of them · FLUX Kommunity licence",
[("t2i", f"{KLEIN_FAL}/base/text-to-image/lora"), ("edit", f"{KLEIN_FAL}/base/edit-image/lora")],
badges=["new"], defaults={"aspectRatio": "1:1", "resolution": "1K"}, tier_size=f"{KLEIN_FAL}/text-to-image", options={"layout": "flux3"},
licence=KLEIN_LICENCE)
diff --git a/src/components/lora-settings.tsx b/src/components/lora-settings.tsx
index 5c842135..6829c691 100644
--- a/src/components/lora-settings.tsx
+++ b/src/components/lora-settings.tsx
@@ -61,6 +61,7 @@ function baseName(base: string): string {
[/^qwen-image-edit/, "Qwen-Image-Edit"],
[/^flux2-klein-4b/, "FLUX.2 [klein] 4B"],
[/^flux2-klein-9b/, "FLUX.2 [klein] 9B"],
+ [/^flux3-klein/, "FLUX 3 Klein"],
];
return known.find(([re]) => re.test(base))?.[1] ?? base;
}
diff --git a/src/lib/catalog/cloud-models.generated.ts b/src/lib/catalog/cloud-models.generated.ts
index f614afea..0e033561 100644
--- a/src/lib/catalog/cloud-models.generated.ts
+++ b/src/lib/catalog/cloud-models.generated.ts
@@ -1766,7 +1766,7 @@ export const CLOUD_MODELS: ModelDef[] = [
"family": "flux",
"engine": "cloud",
"kind": "image",
- "tagline": "BFL's open 5.6B model: text to image, edits with up to 10 references, layout boxes",
+ "tagline": "BFL's open 5.6B model, hosted: up to 4K, edits with up to 10 references, layout boxes; fal writes the full caption \u00b7 FLUX Kommunity licence",
"routes": [
{
"op": "t2i",
@@ -1899,7 +1899,7 @@ export const CLOUD_MODELS: ModelDef[] = [
"family": "flux",
"engine": "cloud",
"kind": "image",
- "tagline": "The undistilled Klein your FLUX 3 Klein LoRAs are trained on: text to image and edits with them",
+ "tagline": "The undistilled Klein your FLUX 3 Klein LoRAs are trained on, hosted: up to 3 of them \u00b7 FLUX Kommunity licence",
"routes": [
{
"op": "t2i",
diff --git a/src/lib/catalog/models.ts b/src/lib/catalog/models.ts
index 5c5fb498..8259fe95 100644
--- a/src/lib/catalog/models.ts
+++ b/src/lib/catalog/models.ts
@@ -1,6 +1,7 @@
import { CLOUD_MODELS, ORIGINAL_CLOUD } from "./cloud-models.generated";
import { DEFAULT_FPS_TARGET, FPS_TARGETS, SLOW_MOTION } from "@/lib/av/fps";
import { ASR_LANGUAGES, WHISPER_LANGUAGES } from "../speech-languages";
+import { PROMPT_HELPER_PARAM } from "@/lib/comfy";
import { loraEntry, loraRef } from "./loras";
import { ANGLES_LORA, MOSAIC_SCALE, MOSAIC_TARGET, SPEAK_GRAPH, SPEAK_LORA, SPEAK_PROMPT } from "./open-tools";
import { CINEMA_CROP, SOUL_ASPECTS, SOUL_TIERS } from "./soul";
@@ -71,6 +72,18 @@ const MOSS_QUALITY: NonNullable<ModelOptions["controls"]>[number] = {
},
};
+/**
+ * FLUX 3 Image Klein's Prompt helper on your GPU: BFL's upsampler (a 6.7 GB Qwen3.5 9B file) turns the words into the full
+ * caption Klein is made for (BFL: short prompts give generic pictures); off sends them as typed. A layout always goes as typed.
+ */
+const KLEIN_PROMPT_HELPER: NonNullable<ModelOptions["controls"]>[number] = {
+ param: PROMPT_HELPER_PARAM,
+ label: "Prompt helper",
+ values: ["on", "off"],
+ default: "on",
+ labels: { on: "On · writes the full caption (BFL's advice)", off: "Off · your words as typed" },
+};
+
type OpenSpec = Omit<ModelDef, "engine" | "badges"> & { badges?: ModelDef["badges"] };
const o = (m: OpenSpec): ModelDef => ({ ...m, engine: "open", badges: ["open", ...(m.badges ?? [])] });
@@ -138,6 +151,38 @@ const open: ModelDef[] = [
options: { maxImages: 4, seed: true },
}),
+ // FLUX 3 Image Klein (BFL, 2026-10-13; research #10 §6.3): text to image and edits with up to 10 references, a layout of
+ // boxes in its own table (compileFlux3), BFL's prompt helper first unless it is off. Klein Base takes your FLUX 3 Klein
+ // LoRAs. The cloud halves are flux-3-klein and flux-3-klein-base on fal. Not a default anywhere (the owner's picks stay).
+ o({
+ id: "oss-flux3-klein",
+ name: "FLUX 3 Klein",
+ vendor: "Black Forest Labs",
+ family: "flux",
+ kind: "image",
+ tagline: "BFL's open 5.6B model: images up to 4K, edits with up to 10 references, layout boxes · 16-24 GB GPU · FLUX Kommunity licence",
+ badges: ["new", "top"],
+ // The edit follows reference 1's shape (about 1 MP); text to image takes the aspect ratio and size.
+ routes: [
+ comfy("t2i", "flux3-klein-t2i", "16 steps; the prompt helper writes the full caption"),
+ { ...comfy("edit", "flux3-klein-edit", "16 steps, up to 10 references"), unsized: true, maxImages: 10 },
+ ],
+ options: { aspectRatios: IMG_AR, resolutions: ["1K", "1.5K", "2K", "4K"], maxImages: 10, seed: true, layout: "flux3", controls: [KLEIN_PROMPT_HELPER] },
+ defaults: { aspectRatio: "1:1", resolution: "1K" },
+ }),
+ o({
+ id: "oss-flux3-klein-base",
+ name: "FLUX 3 Klein Base",
+ vendor: "Black Forest Labs",
+ family: "flux",
+ kind: "image",
+ tagline: "The undistilled Klein your FLUX 3 Klein LoRAs are trained on: 50 steps with them · 16-24 GB GPU · FLUX Kommunity licence",
+ badges: ["new"],
+ routes: [comfy("t2i", "flux3-klein-base-t2i-lora", "50 steps, CFG 3.5; your LoRAs load after it")],
+ options: { aspectRatios: IMG_AR, resolutions: ["1K", "1.5K", "2K", "4K"], seed: true, layout: "flux3", controls: [KLEIN_PROMPT_HELPER] },
+ defaults: { aspectRatio: "1:1", resolution: "1K" },
+ }),
+
// Krea 2 text to image (its edit models come after FIBO 2's, as the owner ranks them).
o({
id: "oss-krea2-realism",
diff --git a/src/lib/catalog/training.ts b/src/lib/catalog/training.ts
index 3eb6e827..9cf6910e 100644
--- a/src/lib/catalog/training.ts
+++ b/src/lib/catalog/training.ts
@@ -2,7 +2,7 @@
* Fuobe Soul ID (build plan O3): a character or a style trained as a LoRA on open weights, on either engine
* (AI-Toolkit on the user's GPU, or fal's hosted trainers), then used whenever the element is @mentioned on a
* model of the family it was trained for: Fuobe Soul and Soul Cinema (Z-Image Turbo), Fuobe Soul HD
- * (Qwen-Image 2512), and every other base fal or AI-Toolkit trains (FLUX.1 / FLUX.2 [dev], FLUX.2 [klein] 4B and 9B,
+ * (Qwen-Image 2512), and every other base fal or AI-Toolkit trains (FLUX.1 / FLUX.2 [dev], FLUX.2 [klein] 4B and 9B, FLUX 3 Klein,
* Krea 2) on the models of that base. Pure logic, no I/O.
*
* - A LoRA belongs to a family (its base), not to one model, and works on both engines where the family has models:
@@ -24,7 +24,7 @@ import type { Engine, ModelDef } from "./types";
export type TrainingProvider = "fal" | "ai-toolkit";
/** The base a LoRA is trained on. A trained LoRA works on every model of its family. */
-export type TrainingFamily = "z-image-turbo" | "qwen-image-2512" | "flux1-dev" | "flux2-dev" | "flux2-klein-4b" | "flux2-klein-9b" | "krea-2";
+export type TrainingFamily = "z-image-turbo" | "qwen-image-2512" | "flux1-dev" | "flux2-dev" | "flux2-klein-4b" | "flux2-klein-9b" | "krea-2" | "flux3-klein";
/** What a training learns: a subject (a person, a place, an object) or a style (a moodboard). */
export type TrainingKind = "subject" | "style";
@@ -176,6 +176,16 @@ export const TRAINING_FAMILIES: Record<TrainingFamily, FamilyInfo> = {
models: ["krea-2-turbo-lora-cloud"],
trainer: "fal-ai/krea-2-trainer",
},
+ // FLUX 3 Image Klein (nm10-flux3-klein): trained on Klein Base, which a LoRA runs on first (fal recommends it); the distilled
+ // Klein takes it too, on both engines.
+ "flux3-klein": {
+ name: "FLUX 3 Klein",
+ base: "FLUX 3 Image Klein Base",
+ original: false,
+ lead: { open: "oss-flux3-klein-base", cloud: "flux-3-klein-base" },
+ models: ["oss-flux3-klein-base", "oss-flux3-klein", "flux-3-klein-base", "flux-3-klein"],
+ trainer: "blackforestlabs/flux-3/klein/base/trainer",
+ },
};
export const TRAINING_FAMILY_IDS = Object.keys(TRAINING_FAMILIES) as TrainingFamily[];
@@ -413,6 +423,32 @@ export const TRAINING_TARGETS: TrainingTarget[] = [
description: `fal's Krea 2 trainer, at 1024 px. ${TO_FAL}`,
eta: "~15–30 min",
}),
+ // FLUX 3 Klein (nm10-flux3-klein): BFL's licence lets Qualifying Users (under US$5M revenue) sell outputs, but it is not
+ // blanket permission for commercial fine-tuning or distribution: the description says so beside the price.
+ target({
+ id: "aitk-flux3-klein",
+ name: "Your GPU",
+ engine: "open",
+ provider: "ai-toolkit",
+ family: "flux3-klein",
+ kinds: ["subject", "style"],
+ steps: 2000,
+ description: `AI-Toolkit on your own GPU (24 GB; Klein Base in 8-bit), its flux3 trainer. Needs a Hugging Face token with the FLUX Kommunity licence accepted, which is not blanket permission for commercial fine-tuning. ${LOCAL}`,
+ eta: "~1–2 h on a 24 GB GPU",
+ }),
+ target({
+ id: "fal-flux3-klein",
+ name: "Cloud",
+ engine: "cloud",
+ provider: "fal",
+ family: "flux3-klein",
+ kinds: ["subject", "style"],
+ trainer: "blackforestlabs/flux-3/klein/base/trainer",
+ steps: 1000,
+ extra: { resolution: 1024 },
+ description: `BFL's FLUX 3 Klein trainer on fal, on Klein Base at 1024 px. The FLUX Kommunity licence is not blanket permission for commercial fine-tuning. ${TO_FAL}`,
+ eta: "~15–30 min",
+ }),
];
export const getTrainingTarget = (id: string) => TRAINING_TARGETS.find((t) => t.id === id);
@@ -580,7 +616,7 @@ export function trainedLoraUrl(t: Pick<TrainingTarget, "trainer">, out: Record<s
* arch names from extensions_built_in/diffusion_models; FLUX.1 and Qwen-Image from config/examples). Z-Image Turbo
* trains with ostris's training adapter v2 (research §4.5); the gated FLUX [dev] repos need an HF token.
*/
-const AITK_MODELS: Partial<Record<TrainingFamily, { model: Record<string, unknown>; guidance: number; sampleSteps: number }>> = {
+const AITK_MODELS: Partial<Record<TrainingFamily, { model: Record<string, unknown>; guidance: number; sampleSteps: number; timestepType?: string }>> = {
"z-image-turbo": {
model: {
name_or_path: "Tongyi-MAI/Z-Image-Turbo",
@@ -615,6 +651,23 @@ const AITK_MODELS: Partial<Record<TrainingFamily, { model: Record<string, unknow
guidance: 4,
sampleSteps: 25,
},
+ // FLUX 3 Image Klein Base (AI-Toolkit's flux3 model, main at e9c72b7, 2026-10-31: its UI's defaults, convrot8 quantization,
+ // shift timesteps; a repack file already in ComfyUI's models folder is used in place). The repo is gated: an HF token.
+ "flux3-klein": {
+ model: {
+ name_or_path: "black-forest-labs/flux-3-image-klein-base",
+ arch: "flux3",
+ quantize: true,
+ qtype: "convrot8",
+ quantize_te: true,
+ qtype_te: "convrot8",
+ low_vram: true,
+ model_kwargs: { match_target_res: true },
+ },
+ guidance: 3.5,
+ sampleSteps: 28,
+ timestepType: "shift",
+ },
};
/** The bases AI-Toolkit trains for Fuobe (the training kit's choices). */
@@ -668,7 +721,7 @@ export function aiToolkitJob(opts: {
cache_text_embeddings: true,
ema_config: { use_ema: false },
steps: opts.steps ?? (style ? 1500 : 2000),
- timestep_type: "weighted",
+ timestep_type: base.timestepType ?? "weighted",
},
model: base.model,
sample: {
diff --git a/src/lib/comfy.ts b/src/lib/comfy.ts
index da612330..089f74d2 100644
--- a/src/lib/comfy.ts
+++ b/src/lib/comfy.ts
@@ -583,6 +583,33 @@ export function bypassNode(wf: ComfyWorkflow, nodeId: string, input: string, kee
return dropUnused(out, keep);
}
+/**
+ * Graphs that run a prompt helper before the model (FLUX 3 Image Klein's: BFL's upsampler, a TextGenerate whose caption the
+ * text encoder reads). Options → Prompt helper "off" (params.extra.promptHelper) or a layout of boxes takes it out.
+ */
+export const PROMPT_HELPER_GRAPHS: ReadonlySet<string> = new Set(["flux3-klein-t2i", "flux3-klein-edit", "flux3-klein-base-t2i-lora"]);
+
+/** params.extra.promptHelper: "on" (the graph's default) or "off". */
+export const PROMPT_HELPER_PARAM = "promptHelper";
+
+/**
+ * The words as typed, without the prompt helper: every CLIPTextEncode that reads a TextGenerate's caption reads that
+ * TextGenerate's own prompt instead, and the helper's nodes (its model, system prompt, the references it looked at) go
+ * with dropUnused. Unchanged when no encoder reads a TextGenerate.
+ */
+export function skipPromptHelper(wf: ComfyWorkflow, keep: string[] = []): ComfyWorkflow {
+ const readers = Object.values(wf).filter((n) => n.class_type === "CLIPTextEncode" && isLinkValue(n.inputs.text) && wf[n.inputs.text[0]]?.class_type === "TextGenerate");
+ if (!readers.length) return wf;
+ const out = cloneWorkflow(wf);
+ for (const n of Object.values(out)) {
+ const t = n.inputs.text;
+ if (n.class_type !== "CLIPTextEncode" || !isLinkValue(t) || out[t[0]]?.class_type !== "TextGenerate") continue;
+ const words = out[t[0]].inputs.prompt;
+ n.inputs.text = isLinkValue(words) ? [...words] : String(words ?? "");
+ }
+ return dropUnused(out, keep);
+}
+
/** Remove nodes whose outputs nothing reads, over and over, keeping the output nodes `keep`. */
export function dropUnused(wf: ComfyWorkflow, keep: string[]): ComfyWorkflow {
const out = cloneWorkflow(wf);
diff --git a/src/lib/licences.ts b/src/lib/licences.ts
index 86f44608..4b29dc91 100644
--- a/src/lib/licences.ts
+++ b/src/lib/licences.ts
@@ -108,7 +108,7 @@ export function licenceTerms(text: string): { flags: LicenceFlag[]; excludes?: s
const noWeights = /^(n\/a|no model)\b/i.test(text.trim());
const nonCommercial = /NON-COMMERCIAL/.test(text) || /^CC-BY-NC/.test(text.trim());
const excludes = /\bEXCLUDES\s+([^);]+)/.exec(text)?.[1].trim();
- const conditional = /Community License|OpenRAIL|Model Use License|CogVideoX License|SAM License|DINOv3 License|Terms of Use|free below|below US\$/i.test(text);
+ const conditional = /Community License|Kommunity License|OpenRAIL|Model Use License|CogVideoX License|SAM License|DINOv3 License|Terms of Use|free below|below US\$/i.test(text);
const flags: LicenceFlag[] = [];
if (nonCommercial) flags.push("non-commercial");
if (excludes) flags.push("territory");
@@ -283,6 +283,8 @@ const KNOWN: { re: RegExp; name: string; class: LicenceClass; url?: string }[] =
{ re: /LTX-2(?:\.x)? Community License/, name: "LTX-2 Community License", class: "conditions" },
{ re: /Stability AI Community License|Stability Community License/, name: "Stability AI Community License", class: "conditions", url: "https://stability.ai/community-license-agreement" },
{ re: /Krea 2 Community License/, name: "Krea 2 Community License", class: "conditions" },
+ // FLUX 3 Image Klein (nm10-flux3-klein): non-commercial, with commercial outputs for Qualifying Users below US$5M revenue.
+ { re: /FLUX Kommunity License/, name: "FLUX Kommunity License v1.0", class: "conditions", url: "https://huggingface.co/black-forest-labs/flux-3-image-klein" },
{ re: /IndexTTS-2 Model Use License/, name: "bilibili IndexTTS-2 Model Use License", class: "conditions" },
{ re: /Llama 3\.1 Community License/, name: "Llama 3.1 Community License", class: "conditions", url: "https://www.llama.com/llama3_1/license/" },
{ re: /DINOv3 License/, name: "DINOv3 License", class: "conditions" },
diff --git a/src/lib/studios.ts b/src/lib/studios.ts
index 78f1a341..d932f664 100644
--- a/src/lib/studios.ts
+++ b/src/lib/studios.ts
@@ -16,14 +16,15 @@ export const IMAGE_STUDIO: StudioConfig = {
pickerOps: ["t2i"],
feed: { kind: "image", features: ["image", "edit", "app:*", "character:*"] },
slots: [],
- multiRef: { label: "Add ref", max: 8 },
+ // Up to 10 references where the model takes them (FLUX 3 Klein); each model's own limit caps it (composer refMax).
+ multiRef: { label: "Add ref", max: 10 },
defaultModels: { cloud: "nano-banana-pro", open: "oss-ideogram-4" },
// Ideogram 4 runs on a caption the install's local model writes: an account, a guest or an install with none opens on
// Qwen-Image 2.1, the next pick (plain words give Ideogram's grey safety card on about half the pictures of people).
uncaptioned: { open: "oss-qwen-image-21" },
// A model's own settings (MOSS-Image's Quality, Ideogram's speed) sit under "Options".
controlsTitle: "Options",
- // Layout mode: boxes on the picture, one row each, read in place by MOSS-Image, FLUX.3 and Ideogram 4.5.
+ // Layout mode: boxes on the picture, one row each, read in place by MOSS-Image, FLUX.3, FLUX 3 Klein and Ideogram 4.5.
layout: true,
// 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.
@@ -46,7 +47,8 @@ export const EDIT_STUDIO: StudioConfig = {
ops: ["edit"],
feed: { kind: "image", features: ["edit"] },
slots: [{ key: "image", label: "Image", accept: "image", required: true }],
- multiRef: { label: "Add ref", max: 6 },
+ // The image and up to 9 references (FLUX 3 Klein takes 10 in all); each model's own limit caps it.
+ multiRef: { label: "Add ref", max: 9 },
sketch: ["mask", "draw"],
defaultModels: { cloud: "nano-banana-pro", open: "oss-qwen-image-21" },
suggestions: [
diff --git a/src/server/providers/comfyui.ts b/src/server/providers/comfyui.ts
index 2cbb0cfc..1d620b63 100644
--- a/src/server/providers/comfyui.ts
+++ b/src/server/providers/comfyui.ts
@@ -25,6 +25,9 @@ import {
languageName,
paletteSentence,
parseCueLines,
+ PROMPT_HELPER_GRAPHS,
+ PROMPT_HELPER_PARAM,
+ skipPromptHelper,
randomSeed,
splitCueWords,
swatchPixels,
@@ -40,6 +43,7 @@ import {
import { fpsPlan } from "@/lib/av/fps";
import { resolveWorkflowId } from "@/lib/comfy-variants";
import { h3Canvas, h3Frames, isH3Graph } from "@/lib/h3-prompt";
+import { carriesLayout, LAYOUT_PARAM } from "@/lib/layout-prompt";
import { fixFromPromptError } from "@/lib/gpu/fix-codes";
import { loadIndex } from "../gpu/index-file";
import { crossfadeProblem, fadeCurveWav } from "@/lib/av/crossfade";
@@ -832,7 +836,15 @@ const SLOT_RULES: Record<string, { reuse?: boolean; required?: string[]; hints?:
* person): a reference left out goes with the nodes only it feeds, and the encoder runs on the ones it was given.
* Slots drop from the last, so an encoder's numbered inputs never have a gap.
*/
-const OPTIONAL_REFERENCE_INPUTS: ReadonlySet<string> = new Set(["TextEncodeQwenImage21", "TextEncodeFibo2", "Krea2EditModelPatch", "Krea2EditGroundedEncode"]);
+const OPTIONAL_REFERENCE_INPUTS: ReadonlySet<string> = new Set([
+ "TextEncodeQwenImage21",
+ "TextEncodeFibo2",
+ "Krea2EditModelPatch",
+ "Krea2EditGroundedEncode",
+ // FLUX 3 Image Klein's edit: its references on one ReferenceMultiLatent, and the batch its prompt helper looks at.
+ "ReferenceMultiLatent",
+ "BatchImagesNode",
+]);
/** Uploads that are sides of one object (image = the first side, image2 the second…), and the node they all go into. */
interface ViewSlots {
@@ -841,6 +853,8 @@ interface ViewSlots {
}
const IMAGE_SLOTS = ["image", "image2", "image3", "image4"] as const;
+/** Every reference slot a graph can bind, in order (FLUX 3 Image Klein's edit takes 10). */
+const REFERENCE_SLOTS = ["image", "image2", "image3", "image4", "image5", "image6", "image7", "image8", "image9", "image10"] as const;
/**
* Which slot each photo of a multi-view 3D model goes to: params.extra.views names the side of each photo
@@ -864,6 +878,12 @@ const MEDIA_HINT: Record<string, string> = {
image2: "Add a second image",
image3: "Add a third image",
image4: "Add a fourth image",
+ image5: "Add a fifth image",
+ image6: "Add a sixth image",
+ image7: "Add a seventh image",
+ image8: "Add an eighth image",
+ image9: "Add a ninth image",
+ image10: "Add a tenth image",
endImage: "Add an end frame",
mask: "Paint the area to change",
video: "Add a video",
@@ -1064,6 +1084,8 @@ export async function prepareWorkflow(endpointTemplate: string, input: GenInput,
image2: images[1],
image3: images[2],
image4: images[3],
+ // FLUX 3 Image Klein's edit binds up to ten references.
+ ...Object.fromEntries(REFERENCE_SLOTS.slice(4).map((k, i) => [k, images[i + 4]])),
endImage: input.endImage,
mask: input.mask,
video: input.video ?? clips[0],
@@ -1438,6 +1460,11 @@ export async function prepareWorkflow(endpointTemplate: string, input: GenInput,
const sourceChannels = b.channels ? (ctx.media?.(String(values.audio ?? ""))?.channels ?? (Number(extra.sourceChannels) || undefined)) : undefined;
if (b.channels) values.channels = dbsChannelsFor(extra.channels, sourceChannels);
for (const k of ["separationModel", "channels", "sourceChannels"]) delete extra[k];
+ // Options → Prompt helper (FLUX 3 Image Klein) and a layout's draft (kept for Reuse): read here, never bound.
+ const helper = extra[PROMPT_HELPER_PARAM];
+ const laidOut = carriesLayout(extra);
+ delete extra[PROMPT_HELPER_PARAM];
+ delete extra[LAYOUT_PARAM];
for (const [k, v] of Object.entries(extra)) values[k as BindingKey] = v;
// SeedVR2's `scale` multiplies the picture before one diffusion pass over all of it, and its graph is made for up to
// limits.maxWidth × maxHeight: the multiplier comes down to fit the picture (a 3000 × 2000 photo at the template's 4x
@@ -1483,7 +1510,7 @@ export async function prepareWorkflow(endpointTemplate: string, input: GenInput,
}
// The Character swap without an anchor frame: its loader and fit are taken out after binding.
if (dropAnchor) left.push("image2");
- for (const [k, prev] of [["image2", "image"], ["image3", "image2"], ["image4", "image3"]] as const) {
+ for (const [k, prev] of REFERENCE_SLOTS.slice(1).map((slot, i) => [slot, REFERENCE_SLOTS[i]] as const)) {
if (rules.views || !b[k] || values[k] !== undefined || rules.required?.includes(k) || left.includes(k)) continue;
if (values[prev] === undefined && !left.includes(prev)) continue;
const loader = b[k]!.length === 1 ? b[k]![0].node : undefined;
@@ -1520,6 +1547,8 @@ export async function prepareWorkflow(endpointTemplate: string, input: GenInput,
if (bound.missing.length) throw new ProviderError(`Workflow ${manifest.id} bindings point at missing nodes: ${bound.missing.join(", ")}`);
let wf = bound.workflow;
const outputIds = manifest.outputs.map((o) => o.node);
+ // The prompt helper (FLUX 3 Image Klein's upsampler) off, or a layout whose boxes it would rewrite: the words as typed.
+ if (PROMPT_HELPER_GRAPHS.has(manifest.id) && (helper === "off" || laidOut)) wf = skipPromptHelper(wf, outputIds);
if (dropAnchor) wf = withoutAnchor(wf, b.image2![0].node);
// LoRA "none": the swap LoRA's loader is linked out (H3 runs with the Turbo LoRA alone).
if (dropSwapLora && b.lora?.length === 1) wf = bypassNode(wf, b.lora[0].node, "model", outputIds);
diff --git a/tests/flux3-klein.test.ts b/tests/flux3-klein.test.ts
new file mode 100644
index 00000000..41045476
--- /dev/null
+++ b/tests/flux3-klein.test.ts
@@ -0,0 +1,371 @@
+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, MODELS } from "@/lib/catalog";
+import { loraEndpointFor } from "@/lib/catalog/loras";
+import { buildPayload } from "@/lib/catalog/payload";
+import { estimateCost, planGeneration, routesFor } from "@/lib/catalog/plan";
+import { aiToolkitJob, falTrainingInput, familyOfModel, getTrainer, getTrainingTarget, TRAINING_FAMILIES } from "@/lib/catalog/training";
+import type { GenerationRequest, GenInput, LoraRef, ModelRoute, Operation } from "@/lib/catalog/types";
+import { PROMPT_HELPER_GRAPHS, skipPromptHelper, type ComfyWorkflow, type Manifest } from "@/lib/comfy";
+import { filterModels, studioBest } from "@/lib/composer";
+import { compileFlux3, flux3Boxes, flux3Caption, validateLayout, type LayoutDraft } from "@/lib/layout-prompt";
+import { licenceInfo } from "@/lib/licences";
+import { EDIT_STUDIO, IMAGE_STUDIO } from "@/lib/studios";
+
+// Package nm10-flux3-klein (docs/research/new-models-10.md §6.3): FLUX 3 Image Klein on both engines. Three ComfyUI graphs from
+// Comfy-Org's Klein templates on BFL's pinned repack, fal's routes and LoRA twins from research #10's endpoint records, a layout
+// as fal's bounding_boxes, and a Soul ID training target on fal's Klein Base trainer and on AI-Toolkit's flux3 model.
+const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "fuobe-klein-"));
+process.env.FUOBE_DATA_DIR = tmp;
+process.env.COMFYUI_URL = "http://comfy.test:8188";
+const { prepareWorkflow } = await import("@/server/providers/comfyui");
+afterAll(() => fs.rmSync(tmp, { recursive: true, force: true }));
+
+const dir = path.join(process.cwd(), "workflows/comfyui");
+const manifest = JSON.parse(fs.readFileSync(path.join(dir, "manifest.json"), "utf8")) as Manifest;
+const pins = JSON.parse(fs.readFileSync(path.join(dir, "model-pins.json"), "utf8")) as Record<string, { revision: string; sizeBytes: number }>;
+const entry = (id: string) => manifest.workflows.find((w) => w.id === id)!;
+const graph = (id: string) => JSON.parse(fs.readFileSync(path.join(dir, `${id}.json`), "utf8")) as ComfyWorkflow;
+
+const REPO = "https://huggingface.co/black-forest-labs/flux-3-image-klein-comfy/resolve/feef60b0aaf63a4773ace96636ebbcf43b881312";
+/** The repack's sizes in bytes (the Hugging Face tree at feef60b0, read 2026-11-01). */
+const SIZES: Record<string, number> = {
+ "diffusion_models/flux3-image-klein-int8-convrot.safetensors": 5827874779,
+ "diffusion_models/flux3-image-klein-nvfp4.safetensors": 5277685632,
+ "diffusion_models/flux3-image-klein-bf16.safetensors": 11097404512,
+ "diffusion_models/flux3-image-klein-base-int8-convrot.safetensors": 5807427339,
+ "diffusion_models/flux3-image-klein-base-nvfp4.safetensors": 5257238192,
+ "diffusion_models/flux3-image-klein-base-bf16.safetensors": 11076957072,
+ "text_encoders/qwen3.5_9b_flux3_prompt_upsampler_w4a8.safetensors": 6724090780,
+};
+
+async function prepare(id: string, input: GenInput, op: Operation, loras?: LoraRef[]) {
+ const uploads: string[] = [];
+ const res = await prepareWorkflow(id, { seed: 7, ...input, ...(loras && { loras }) }, {
+ generationId: "g-klein",
+ op,
+ upload: async (_d, _t, name) => {
+ uploads.push(name);
+ return `up_${name}`;
+ },
+ });
+ return { ...res, uploads };
+}
+const classes = (wf: ComfyWorkflow) => Object.values(wf).map((n) => n.class_type);
+
+describe("FLUX 3 Image Klein's ComfyUI graphs", () => {
+ it("are validated core-node graphs with the contract's bindings, limits and licence", () => {
+ for (const id of ["flux3-klein-t2i", "flux3-klein-edit", "flux3-klein-base-t2i-lora"]) {
+ const e = entry(id);
+ expect(e, id).toMatchObject({ validated: true, customNodes: [], vramGb: 16, source: `hand-built (scripts/comfy/hand-built/${id}.json)` });
+ expect(e.license, id).toMatch(/^FLUX Kommunity License v1\.0 .*not blanket permission for commercial fine-tuning/);
+ expect(e.outputs, id).toEqual([{ node: "9", kind: "image" }]);
+ // The prompt goes to the helper, the seed to the sampler and to the helper's sampling.
+ expect(e.bindings.prompt, id).toEqual([{ node: "11", input: "prompt" }]);
+ expect(e.bindings.seed, id).toEqual([
+ { node: "7", input: "seed" },
+ { node: "11", input: "sampling_mode.seed" },
+ ]);
+ expect(e.notes, id).toBeTruthy();
+ expect(PROMPT_HELPER_GRAPHS.has(id), id).toBe(true);
+ }
+ expect(Object.keys(entry("flux3-klein-t2i").bindings).sort()).toEqual(["filenamePrefix", "height", "prompt", "seed", "steps", "unet", "width"]);
+ expect(entry("flux3-klein-t2i").defaults).toEqual({ width: 1024, height: 1024, steps: 16, unet: "flux3-image-klein-int8-convrot.safetensors" });
+ expect(entry("flux3-klein-t2i").limits).toEqual({ maxWidth: 4096, maxHeight: 4096, dimensionMultiple: 16 });
+ // Klein Base: the card's 50 steps and CFG 3.5, the one LoRAs are trained on.
+ expect(entry("flux3-klein-base-t2i-lora").defaults).toEqual({ width: 1024, height: 1024, steps: 50, cfg: 3.5, unet: "flux3-image-klein-base-int8-convrot.safetensors" });
+ // The edit binds ten references, each on its own LoadImage, and follows reference 1's shape (no size bindings).
+ const edit = entry("flux3-klein-edit");
+ const refs = ["image", "image2", "image3", "image4", "image5", "image6", "image7", "image8", "image9", "image10"];
+ expect(refs.map((k) => edit.bindings[k]?.[0])).toEqual(refs.map((_, i) => ({ node: String(20 + i), input: "image" })));
+ for (const k of refs) expect(graph("flux3-klein-edit")[edit.bindings[k]![0].node].class_type).toBe("LoadImage");
+ expect(edit.bindings.width).toBeUndefined();
+ expect(edit.limits).toEqual({ maxImages: 10 });
+ });
+
+ it("runs the distilled model at 16 steps without guidance, Base at 50 with CFG 3.5, behind BFL's prompt helper", () => {
+ const t2i = graph("flux3-klein-t2i");
+ expect(t2i["7"].inputs).toMatchObject({ steps: 16, cfg: 1, sampler_name: "er_sde", scheduler: "simple" });
+ expect(graph("flux3-klein-base-t2i-lora")["7"].inputs).toMatchObject({ steps: 50, cfg: 3.5, sampler_name: "euler" });
+ expect(graph("flux3-klein-edit")["7"].inputs).toMatchObject({ steps: 16, cfg: 1, sampler_name: "euler" });
+ for (const id of ["flux3-klein-t2i", "flux3-klein-edit", "flux3-klein-base-t2i-lora"]) {
+ const g = graph(id);
+ expect(g["10"].inputs, id).toEqual({ clip_name: "qwen3.5_9b_flux3_prompt_upsampler_w4a8.safetensors", type: "flux3", device: "default" });
+ expect(g["2"].inputs, id).toMatchObject({ clip_name: "qwen3vl_4b_int8_convrot.safetensors", type: "flux3" });
+ expect(g["11"].class_type).toBe("TextGenerate");
+ // The card's decoding: greedy (top_k 1), presence penalty 1.5 for text to image and 0 for edits.
+ expect(g["11"].inputs).toMatchObject({ max_length: 3584, "sampling_mode.top_k": 1, "sampling_mode.top_p": 0.95, thinking: false });
+ expect(g["11"].inputs["sampling_mode.presence_penalty"]).toBe(id === "flux3-klein-edit" ? 0 : 1.5);
+ expect(g["4"].inputs.text, id).toEqual(["11", 0]);
+ // BFL's system prompts (flux-3-image-klein-pup, Apache-2.0), with real line breaks.
+ expect(String(g["12"].inputs.value)).toMatch(id === "flux3-klein-edit" ? /^You are the prompt upsampler of an image-editing model/ : /^You are the prompt upsampler of a text-to-image model/);
+ expect(String(g["12"].inputs.value)).toContain("\n\n");
+ }
+ // The edit's references sit on one ReferenceMultiLatent (1 MP each) and on the batch the helper looks at.
+ const e = graph("flux3-klein-edit");
+ expect(e["30"].inputs).toMatchObject({ resolution: "resize", "resolution.megapixels": 1 });
+ for (let i = 0; i < 10; i++) {
+ expect(e["30"].inputs[`images.image${i}`]).toEqual([String(20 + i), 0]);
+ expect(e["31"].inputs[`images.image${i}`]).toEqual([String(20 + i), 0]);
+ }
+ expect(e["11"].inputs.image).toEqual(["31", 0]);
+ });
+
+ it("pins BFL's gated repack at feef60b0 with its sizes; the shared encoder and VAE download without a token", () => {
+ for (const id of ["flux3-klein-t2i", "flux3-klein-edit", "flux3-klein-base-t2i-lora"]) {
+ const files = Object.fromEntries(entry(id).models.map((m) => [m.file, m]));
+ expect(files["qwen3vl_4b_int8_convrot.safetensors"]).toMatchObject({ folder: "text_encoders", sizeGb: 4.86 });
+ expect(files["qwen3vl_4b_int8_convrot.safetensors"].gated).toBeUndefined();
+ expect(files["flux2-vae.safetensors"]).toMatchObject({ folder: "vae", sizeGb: 0.34 });
+ expect(files["qwen3.5_9b_flux3_prompt_upsampler_w4a8.safetensors"]).toMatchObject({ folder: "text_encoders", sizeGb: 6.72, gated: true });
+ }
+ const t2i = Object.fromEntries(entry("flux3-klein-t2i").models.map((m) => [m.file, m]));
+ expect(t2i["flux3-image-klein-int8-convrot.safetensors"]).toMatchObject({ folder: "diffusion_models", sizeGb: 5.83, gated: true });
+ expect(t2i["flux3-image-klein-nvfp4.safetensors"]).toMatchObject({ sizeGb: 5.28, gated: true, optional: true });
+ expect(t2i["flux3-image-klein-bf16.safetensors"]).toMatchObject({ sizeGb: 11.1, gated: true, optional: true });
+ const base = Object.fromEntries(entry("flux3-klein-base-t2i-lora").models.map((m) => [m.file, m]));
+ expect(base["flux3-image-klein-base-int8-convrot.safetensors"]).toMatchObject({ sizeGb: 5.81, gated: true });
+ for (const [file, bytes] of Object.entries(SIZES)) {
+ expect(pins[`${REPO}/${file}`], file).toEqual({ revision: "feef60b0aaf63a4773ace96636ebbcf43b881312", sizeBytes: bytes });
+ }
+ // Every Klein file in the manifest points at the pinned revision.
+ for (const id of ["flux3-klein-t2i", "flux3-klein-edit", "flux3-klein-base-t2i-lora"]) {
+ for (const m of entry(id).models.filter((x) => x.file.includes("flux3"))) expect(m.url, m.file).toBe(`${REPO}/${m.folder}/${m.file}`);
+ }
+ });
+});
+
+describe("the provider fills Klein's graphs", () => {
+ it("sends the words through the prompt helper by default", async () => {
+ const { workflow: wf } = await prepare("flux3-klein-t2i", { prompt: "a fox in snow", extra: { width: 1536, height: 1024 } }, "t2i");
+ expect(wf["11"].inputs.prompt).toBe("a fox in snow");
+ expect(wf["11"].inputs["sampling_mode.seed"]).toBe(7);
+ expect(wf["7"].inputs.seed).toBe(7);
+ expect(wf["4"].inputs.text).toEqual(["11", 0]);
+ expect(wf["6"].inputs).toMatchObject({ width: 1536, height: 1024 });
+ });
+
+ it("takes the helper out when it's off or a layout is attached: the words reach the encoder as typed", async () => {
+ const off = (await prepare("flux3-klein-t2i", { prompt: "a fox in snow", extra: { promptHelper: "off" } }, "t2i")).workflow;
+ expect(off["4"].inputs.text).toBe("a fox in snow");
+ expect(classes(off)).not.toContain("TextGenerate");
+ expect(classes(off)).not.toContain("PrimitiveStringMultiline");
+ expect(Object.values(off).some((n) => n.inputs.clip_name === "qwen3.5_9b_flux3_prompt_upsampler_w4a8.safetensors")).toBe(false);
+ const layout = compileFlux3(POSTER);
+ const laid = (await prepare("flux3-klein-t2i", { prompt: layout, extra: { layout: POSTER } }, "t2i")).workflow;
+ expect(laid["4"].inputs.text).toBe(layout);
+ expect(classes(laid)).not.toContain("TextGenerate");
+ // The edit's helper goes with the batch of references it looked at; the references stay on the model.
+ const edit = (await prepare("flux3-klein-edit", { prompt: "make it night", images: ["a.png"], extra: { promptHelper: "off" } }, "edit")).workflow;
+ expect(classes(edit)).not.toContain("BatchImagesNode");
+ expect(edit["30"].inputs["images.image0"]).toEqual(["20", 0]);
+ });
+
+ it("leaves out the references not given, from the last, on the model and on the helper's batch", async () => {
+ const { workflow: wf } = await prepare("flux3-klein-edit", { prompt: "Put the cat of the second image on the sofa", images: ["a.png", "b.png", "c.png"] }, "edit");
+ expect(Object.keys(wf["30"].inputs).filter((k) => k.startsWith("images.")).sort()).toEqual(["images.image0", "images.image1", "images.image2"]);
+ expect(Object.keys(wf["31"].inputs).sort()).toEqual(["images.image0", "images.image1", "images.image2"]);
+ for (const id of ["23", "24", "25", "26", "27", "28", "29"]) expect(wf[id], id).toBeUndefined();
+ expect(wf["22"].inputs.image).toBe("c.png");
+ const ten = (await prepare("flux3-klein-edit", { prompt: "a collage", images: Array.from({ length: 10 }, (_, i) => `r${i}.png`) }, "edit")).workflow;
+ expect(Object.keys(ten["30"].inputs).filter((k) => k.startsWith("images."))).toHaveLength(10);
+ expect(ten["29"].inputs.image).toBe("r9.png");
+ await expect(prepare("flux3-klein-edit", { prompt: "x", images: [] }, "edit")).rejects.toThrow(/Add an image/);
+ });
+
+ it("loads your LoRAs after Klein Base's model loader", async () => {
+ const { workflow: wf } = await prepare("flux3-klein-base-t2i-lora", { prompt: "photo of mayafz" }, "t2i", [{ file: "mayafz_flux3_klein.safetensors", strength: 0.9 }]);
+ const lora = Object.entries(wf).find(([, n]) => n.class_type === "LoraLoaderModelOnly")!;
+ expect(lora[1].inputs).toMatchObject({ model: ["1", 0], lora_name: "mayafz_flux3_klein.safetensors", strength_model: 0.9 });
+ expect(wf["7"].inputs.model).toEqual([lora[0], 0]);
+ });
+
+ it("skipPromptHelper leaves a graph without a helper as it is", () => {
+ const wf: ComfyWorkflow = { "1": { class_type: "CLIPTextEncode", inputs: { text: "plain", clip: ["2", 0] } }, "2": { class_type: "CLIPLoader", inputs: {} } };
+ expect(skipPromptHelper(wf)).toBe(wf);
+ });
+});
+
+const POSTER: LayoutDraft = {
+ summary: { caption: "A cozy reading nook", meta: [], canvas: "single" },
+ items: [
+ { label: "object", caption: "a green armchair", box: [0.1, 0.4, 0.5, 0.95] },
+ { label: "text", caption: "neon sign", text: "READ", box: [0.55, 0.1, 0.9, 0.3] },
+ ],
+};
+
+describe("FLUX 3 Klein in the catalog, both engines", () => {
+ const cloud = getModel("flux-3-klein")!;
+ const base = getModel("flux-3-klein-base")!;
+ const open = getModel("oss-flux3-klein")!;
+ const openBase = getModel("oss-flux3-klein-base")!;
+
+ it("runs on your GPU (text to image, edits with 10 references, Base with LoRAs) and on fal's hosted routes", () => {
+ expect(open).toMatchObject({ engine: "open", kind: "image", vendor: "Black Forest Labs" });
+ expect(open.routes.map((r) => [r.op, r.endpoint])).toEqual([
+ ["t2i", "flux3-klein-t2i"],
+ ["edit", "flux3-klein-edit"],
+ ]);
+ expect(open.options).toMatchObject({ maxImages: 10, layout: "flux3", resolutions: ["1K", "1.5K", "2K", "4K"] });
+ expect(open.routes.find((r) => r.op === "edit")!.unsized).toBe(true);
+ expect(open.options.controls).toEqual([
+ { param: "promptHelper", label: "Prompt helper", values: ["on", "off"], default: "on", labels: expect.any(Object) },
+ ]);
+ expect(openBase.routes.map((r) => [r.op, r.endpoint])).toEqual([["t2i", "flux3-klein-base-t2i-lora"]]);
+ expect(routesFor(cloud, "t2i").map((r) => [r.endpoint, r.loraEndpoint])).toEqual([["blackforestlabs/flux-3/klein/text-to-image", "blackforestlabs/flux-3/klein/text-to-image/lora"]]);
+ expect(routesFor(cloud, "edit").map((r) => [r.endpoint, r.loraEndpoint])).toEqual([["blackforestlabs/flux-3/klein/edit-image", "blackforestlabs/flux-3/klein/edit-image/lora"]]);
+ expect(base.routes.map((r) => r.endpoint)).toEqual(["blackforestlabs/flux-3/klein/base/text-to-image/lora", "blackforestlabs/flux-3/klein/base/edit-image/lora"]);
+ expect(cloud.options).toMatchObject({ maxImages: 10, maxOutputs: 4, layout: "flux3", resolutions: ["1K", "1.5K", "2K", "4K"] });
+ // The licence is information: recorded, switched on, never a gate.
+ expect(cloud.licence).toMatchObject({ licence: "FLUX Kommunity License v1.0", commercial: null });
+ expect(cloud.licence!.note).toMatch(/not blanket permission for commercial fine-tuning/);
+ expect(licenceInfo(entry("flux3-klein-t2i").license!)).toMatchObject({ name: "FLUX Kommunity License v1.0", class: "conditions" });
+ for (const m of [cloud, base, open, openBase]) expect(m.hidden, m.id).toBeFalsy();
+ });
+
+ it("sits in the Image and Edit studios' Best lists on your GPU, beside Ideogram 4 and Qwen-Image 2.1; the defaults stay", () => {
+ expect(IMAGE_STUDIO.defaultModels).toEqual({ cloud: "nano-banana-pro", open: "oss-ideogram-4" });
+ expect(EDIT_STUDIO.defaultModels).toEqual({ cloud: "nano-banana-pro", open: "oss-qwen-image-21" });
+ const image = studioBest(filterModels(MODELS, { kind: "image", ops: IMAGE_STUDIO.pickerOps }), "open", IMAGE_STUDIO.defaultModels.open, IMAGE_STUDIO.ops);
+ expect(image.slice(0, 3)).toEqual(["oss-ideogram-4", "oss-qwen-image-21", "oss-flux3-klein"]);
+ const edit = studioBest(filterModels(MODELS, { kind: "image", ops: EDIT_STUDIO.ops }), "open", EDIT_STUDIO.defaultModels.open, EDIT_STUDIO.ops);
+ expect(edit).toContain("oss-flux3-klein");
+ // Ten references: the Image studio's refs, or the Edit studio's image and nine refs.
+ expect(IMAGE_STUDIO.multiRef!.max).toBe(10);
+ expect(1 + EDIT_STUDIO.multiRef!.max).toBe(10);
+ });
+
+ it("plans an edit with ten references on either engine; your GPU's graph refuses an eleventh rather than drop it", () => {
+ const images = Array.from({ length: 10 }, (_, i) => `/api/files/r${i}.png`);
+ for (const modelId of ["oss-flux3-klein", "flux-3-klein"]) {
+ const p = planGeneration({ feature: "edit", modelId, prompt: "a collage", inputs: { images } } as GenerationRequest, getModel, getPreset);
+ expect(p.op, modelId).toBe("edit");
+ }
+ const eleven = { feature: "edit", modelId: "oss-flux3-klein", prompt: "x", inputs: { images: [...images, "/api/files/r10.png"] } } as GenerationRequest;
+ expect(() => planGeneration(eleven, getModel, getPreset)).toThrow(/up to 10 images/);
+ });
+});
+
+describe("fal's FLUX 3 Klein payloads", () => {
+ const cloud = getModel("flux-3-klein")!;
+ const base = getModel("flux-3-klein-base")!;
+ const t2i = (m = cloud) => m.routes.find((r) => r.op === "t2i") as ModelRoute & { map: NonNullable<ModelRoute["map"]> };
+ const edit = (m = cloud) => m.routes.find((r) => r.op === "edit") as ModelRoute & { map: NonNullable<ModelRoute["map"]> };
+ const plan = (req: Partial<GenerationRequest>) => planGeneration({ feature: "image", prompt: "a fox", ...req } as GenerationRequest, getModel, getPreset);
+ const LORA: LoraRef = { file: "mayafz.safetensors", url: "https://v3.fal.media/files/mayafz.safetensors", strength: 0.8 };
+
+ it("sends the size as image_size on the tier's square and keeps fal's prompt expansion for plain words", () => {
+ const p = plan({ modelId: "flux-3-klein", params: { aspectRatio: "16:9", resolution: "2K", seed: 3 } });
+ const body = buildPayload(t2i().map, { prompt: p.prompt, ...p.params });
+ expect(body).toMatchObject({ prompt: "a fox", image_size: { width: 2736, height: 1536 }, seed: 3 });
+ expect(body.enable_prompt_expansion).toBeUndefined();
+ expect(body.bounding_boxes).toBeUndefined();
+ expect(buildPayload(t2i().map, { prompt: "x", aspectRatio: "1:1", resolution: "4K" }).image_size).toEqual({ width: 4096, height: 4096 });
+ // 4K at 16:9 is held at fal's 4096 a side.
+ expect(buildPayload(t2i().map, { prompt: "x", aspectRatio: "16:9", resolution: "4K" }).image_size).toEqual({ width: 4096, height: 2304 });
+ });
+
+ it("goes to the /lora twin with up to 3 LoRAs of {path, scale 0-4}", () => {
+ for (const r of [t2i(), edit()]) {
+ expect(loraEndpointFor(r, [LORA])).toBe(`${r.endpoint}/lora`);
+ expect(loraEndpointFor(r, [])).toBe(r.endpoint);
+ expect(r.map.loras).toEqual({ shape: "items", key: "loras", max: 3, range: { min: 0, max: 4 } });
+ const body = buildPayload(r.map, { prompt: "photo of mayafz", aspectRatio: "1:1", resolution: "1K", loras: [LORA], ...(r.op === "edit" && { images: ["https://x/a.png"] }) });
+ expect(body.loras).toEqual([{ path: LORA.url, scale: 0.8 }]);
+ expect(body.image_size).toEqual({ width: 1024, height: 1024 });
+ }
+ expect(buildPayload(edit().map, { prompt: "x", images: Array.from({ length: 10 }, (_, i) => `https://x/${i}.png`) }).image_urls).toHaveLength(10);
+ // Klein Base's own routes are the LoRA routes.
+ expect(t2i(base).loraEndpoint).toBeUndefined();
+ expect(buildPayload(t2i(base).map, { prompt: "photo of mayafz", loras: [LORA] }).loras).toEqual([{ path: LORA.url, scale: 0.8 }]);
+ });
+
+ it("puts a layout's boxes in bounding_boxes, the caption naming them, with prompt expansion off", () => {
+ for (const [m, op] of [
+ [cloud, "t2i"],
+ [cloud, "edit"],
+ [base, "t2i"],
+ [base, "edit"],
+ ] as const) {
+ const p = plan({ modelId: m.id, op, prompt: "A cozy reading nook", params: { extra: { layout: POSTER } }, ...(op === "edit" && { inputs: { images: ["/api/files/a.png"] } }) });
+ const route = op === "t2i" ? t2i(m) : edit(m);
+ const body = buildPayload(route.map, { prompt: p.prompt, ...p.params, ...(op === "edit" && { images: ["https://x/a.png"] }) });
+ expect(body.prompt, `${m.id} ${op}`).toBe(flux3Caption(POSTER));
+ expect(body.prompt).toContain("<obj_1> a green armchair, <obj_2> the words \"READ\"");
+ expect(String(body.prompt)).not.toContain("bbox");
+ expect(body.bounding_boxes).toEqual(flux3Boxes(POSTER));
+ expect(body.enable_prompt_expansion).toBe(false);
+ expect(body.layout).toBeUndefined();
+ }
+ // The same boxes as the open engine's table (0-1000 grid, y before x), as fractions.
+ expect(flux3Boxes(POSTER)).toEqual([
+ { label: "obj_1", description: "a green armchair", box: { x_min: 0.1, y_min: 0.4, x_max: 0.5, y_max: 0.95 } },
+ { label: "obj_2", description: 'neon sign "READ"', box: { x_min: 0.55, y_min: 0.1, x_max: 0.9, y_max: 0.3 } },
+ ]);
+ expect(compileFlux3(POSTER)).toBe(`${flux3Caption(POSTER)} [{"id": "obj_1", "bbox": [400, 100, 950, 500], "desc": "a green armchair"}, {"id": "obj_2", "bbox": [100, 550, 300, 900], "desc": "neon sign \\"READ\\""}]`);
+ // On your GPU the compiled table is the prompt (the helper is taken out by the provider).
+ const local = plan({ modelId: "oss-flux3-klein", prompt: "A cozy reading nook", params: { extra: { layout: POSTER } } });
+ expect(local.prompt).toBe(compileFlux3(POSTER));
+ expect(local.params.extra?.bounding_boxes).toBeUndefined();
+ });
+
+ it("checks fal's limits on boxes before the run", () => {
+ const many: LayoutDraft = { ...POSTER, items: Array.from({ length: 33 }, (_, i) => ({ label: "object" as const, caption: `thing ${i}`, box: [0, 0, 0.1, 0.1] as [number, number, number, number] })) };
+ expect(validateLayout(many, 1024, 1024, "flux3-boxes").map((x) => x.message)).toContain("FLUX 3 Klein takes up to 32 boxes (this layout has 33)");
+ expect(() => plan({ modelId: "flux-3-klein", prompt: "x", params: { extra: { layout: many } } })).toThrow(/up to 32 boxes/);
+ const long: LayoutDraft = { ...POSTER, items: [{ label: "object", caption: "x".repeat(501), box: [0, 0, 0.5, 0.5] }] };
+ expect(() => plan({ modelId: "flux-3-klein", prompt: "x", params: { extra: { layout: long } } })).toThrow(/500 characters/);
+ // Your GPU reads the table in the prompt: no such limit there.
+ expect(() => plan({ modelId: "oss-flux3-klein", prompt: "x", params: { extra: { layout: many } } })).not.toThrow();
+ });
+
+ it("prices fal's planned per-image tiers, and $0.012 per megapixel with LoRAs (1024 and 2048 squares)", () => {
+ expect(cloud.pricing).toMatchObject({ unit: "image", usd: 0.009, byResolution: { "1K": 0.009, "1.5K": 0.011, "2K": 0.014, "4K": 0.036 }, withLorasPerMegapixel: 0.012 });
+ expect(estimateCost(cloud, { aspectRatio: "1:1", resolution: "1K" }, 1, "t2i")).toBe(0.009);
+ expect(estimateCost(cloud, { aspectRatio: "1:1", resolution: "2K", numOutputs: 2 }, 1, "t2i")).toBe(0.028);
+ expect(estimateCost(cloud, { aspectRatio: "1:1", resolution: "1K" }, 1, "t2i", true)).toBe(0.012);
+ expect(estimateCost(cloud, { aspectRatio: "1:1", resolution: "2K" }, 1, "t2i", true)).toBe(0.048);
+ expect(estimateCost(cloud, { aspectRatio: "1:1", resolution: "2K" }, 1, "edit", true)).toBe(0.048);
+ // Klein Base: $0.035 per megapixel.
+ expect(base.pricing).toEqual({ unit: "megapixel", usd: 0.035 });
+ expect(estimateCost(base, { aspectRatio: "1:1", resolution: "1K" }, 1, "t2i", true)).toBe(0.035);
+ expect(estimateCost(base, { aspectRatio: "1:1", resolution: "2K" }, 1, "t2i", true)).toBe(0.14);
+ // Free on your GPU.
+ expect(estimateCost(getModel("oss-flux3-klein")!, { aspectRatio: "1:1", resolution: "4K" }, 1, "t2i")).toBe(0);
+ });
+});
+
+describe("FLUX 3 Klein as a Soul ID training target", () => {
+ it("trains on fal's Klein Base trainer at $0.0043 a step, and on AI-Toolkit's flux3 model on your GPU", () => {
+ const fal = getTrainingTarget("fal-flux3-klein")!;
+ expect(fal).toMatchObject({ engine: "cloud", provider: "fal", family: "flux3-klein", trainer: "blackforestlabs/flux-3/klein/base/trainer", steps: 1000, costUsd: 4.3 });
+ expect(fal.price).toBe("≈ $4.30 (1,000 steps)");
+ expect(fal.licence).toMatch(/^FLUX Kommunity License v1\.0/);
+ expect(fal.commercial).toBeNull();
+ expect(fal.description).toMatch(/not blanket permission for commercial fine-tuning/);
+ const tr = getTrainer(fal.trainer)!;
+ expect(tr).toMatchObject({ usdPerStep: 0.0043, minBilledSteps: 100, dataField: "images_data_url", loraOutput: ["lora_file"], status: "active" });
+ expect(falTrainingInput(fal, "https://x/data.zip", "photo of mayafz", "mayafz")).toEqual({
+ images_data_url: "https://x/data.zip",
+ steps: 1000,
+ trigger_phrase: "mayafz",
+ resolution: 1024,
+ });
+ // The edit trainer's price grows with the references per pair: no single rate is guessed.
+ expect(getTrainer("blackforestlabs/flux-3/klein/base/trainer/edit")!.usdPerStep).toBeUndefined();
+ const gpu = getTrainingTarget("aitk-flux3-klein")!;
+ expect(gpu).toMatchObject({ engine: "open", provider: "ai-toolkit", family: "flux3-klein", costUsd: 0, price: "Free" });
+ const job = aiToolkitJob({ name: "maya", trigger: "mayafz", datasetFolder: "/d", outputFolder: "/o", family: "flux3-klein" });
+ const proc = job.config.process[0];
+ expect(proc.model).toMatchObject({ name_or_path: "black-forest-labs/flux-3-image-klein-base", arch: "flux3", quantize: true, qtype: "convrot8" });
+ expect(proc.train.timestep_type).toBe("shift");
+ expect(proc.sample).toMatchObject({ guidance_scale: 3.5, sample_steps: 28 });
+ });
+
+ it("a FLUX 3 Klein LoRA runs on Klein Base first, and on the distilled Klein, on both engines", () => {
+ expect(TRAINING_FAMILIES["flux3-klein"].lead).toEqual({ open: "oss-flux3-klein-base", cloud: "flux-3-klein-base" });
+ for (const id of ["oss-flux3-klein-base", "oss-flux3-klein", "flux-3-klein-base", "flux-3-klein"]) expect(familyOfModel(id), id).toBe("flux3-klein");
+ });
+});
diff --git a/tests/gpu-readiness.test.ts b/tests/gpu-readiness.test.ts
index c94dce77..11b46fcc 100644
--- a/tests/gpu-readiness.test.ts
+++ b/tests/gpu-readiness.test.ts
@@ -183,7 +183,8 @@ describe("readiness (§7)", () => {
});
it("asks for the licence of gated files", () => {
- const gated = Object.entries(idx.files).find(([, f]) => f.gated)!;
+ // A gated file a workflow needs (FLUX 3 Klein's nvfp4 / bf16 files are gated too, but only optional).
+ const gated = Object.entries(idx.files).find(([k, f]) => f.gated && Object.values(idx.workflows).some((w) => w.files.includes(k as never)))!;
const id = Object.keys(idx.workflows).find((k) => idx.workflows[k].files.includes(gated[0] as never))!;
const r = workflowReadiness(id, inventory([]), idx, ctx);
expect(r.needs.some((n) => n.kind === "hf-licence")).toBe(true);
diff --git a/tests/licences.test.ts b/tests/licences.test.ts
index 0b5b7b4f..ad751e4f 100644
--- a/tests/licences.test.ts
+++ b/tests/licences.test.ts
@@ -32,6 +32,12 @@ describe("licences", () => {
const variants = new Set(["video-depth-da3", "video-depth-vda-small", "bg-remove-rmbg"]);
for (const w of manifest.workflows) {
const text = workflowLicence(w);
+ // The FLUX Kommunity License (FLUX 3 Image Klein) is non-commercial with a revenue tier: Qualifying Users below US$5M
+ // may sell outputs, so it reads as a licence with conditions.
+ if (/Kommunity License/.test(text)) {
+ expect(licenceTerms(text).flags, w.id).toEqual(["conditions"]);
+ continue;
+ }
if (!/non-commercial|CC-BY-NC/i.test(text) || variants.has(w.id)) continue;
expect(licenceTerms(text).flags, w.id).toContain("non-commercial");
}
diff --git a/tests/open-engine.test.ts b/tests/open-engine.test.ts
index b4d1f73a..643a555e 100644
--- a/tests/open-engine.test.ts
+++ b/tests/open-engine.test.ts
@@ -84,7 +84,8 @@ const ROUND3_MODELS: Record<string, { op: Operation; kind: MediaKind; workflow:
const manifest = JSON.parse(fs.readFileSync(path.join(process.cwd(), "workflows/comfyui/manifest.json"), "utf8")) as Manifest;
const workflowById = new Map(manifest.workflows.map((w) => [w.id, w]));
/** Settings the ComfyUI provider consumes itself instead of writing them into a binding. */
-const PROVIDER_PARAMS = new Set(["wordsPerCaption", "paletteWeights", "cues"]);
+// promptHelper: FLUX 3 Image Klein's Prompt helper, which the provider reads to take the helper's branch out (skipPromptHelper).
+const PROVIDER_PARAMS = new Set(["wordsPerCaption", "paletteWeights", "cues", "promptHelper"]);
describe("round-3 open models", () => {
it.each(Object.entries(ROUND3_MODELS))("%s routes to its validated workflow", (id, want) => {
diff --git a/tests/open-sota-studios.test.ts b/tests/open-sota-studios.test.ts
index bc3788cb..863af0c1 100644
--- a/tests/open-sota-studios.test.ts
+++ b/tests/open-sota-studios.test.ts
@@ -40,14 +40,16 @@ describe("studio defaults on your GPU", () => {
});
describe('"Best for this studio" on your GPU', () => {
- it("Image: Ideogram 4, then Qwen-Image 2.1, Krea 2 Realism and MOSS-Image (FIBO 2 Dev is next)", () => {
- expect(best(IMAGE_STUDIO, "open")).toEqual(["oss-ideogram-4", "oss-qwen-image-21", "oss-krea2-realism", "oss-moss-image"]);
+ // FLUX 3 Image Klein (nm10-flux3-klein) sits beside Ideogram 4 and Qwen-Image 2.1, as its brief asks; MOSS-Image moves to
+ // More models.
+ it("Image: Ideogram 4, then Qwen-Image 2.1, FLUX 3 Klein and Krea 2 Realism (MOSS-Image, then FIBO 2 Dev, are next)", () => {
+ expect(best(IMAGE_STUDIO, "open")).toEqual(["oss-ideogram-4", "oss-qwen-image-21", "oss-flux3-klein", "oss-krea2-realism"]);
const t2i = MODELS.filter((m) => m.engine === "open" && m.badges?.includes("top") && m.routes.some((r) => r.op === "t2i")).map((m) => m.id);
- expect(t2i.indexOf("oss-fibo2-dev")).toBe(4);
+ expect(t2i.indexOf("oss-fibo2-dev")).toBe(5);
});
it("Edit: the new edit models, Qwen-Image 2.1 first, not the text-to-image models its first route would rank", () => {
- expect(best(EDIT_STUDIO, "open")).toEqual(["oss-qwen-image-21", "oss-qwen-image-21-turbo", "oss-fibo2-dev", "oss-fibo2-edit-turbo"]);
+ expect(best(EDIT_STUDIO, "open")).toEqual(["oss-qwen-image-21", "oss-qwen-image-21-turbo", "oss-flux3-klein", "oss-fibo2-dev"]);
});
it("Inpaint: Qwen-Image 2.1; Krea 2 Inpaint stays out while its add-on isn't on the owner's ComfyUI", () => {
@@ -279,7 +281,7 @@ describe("Ideogram 4 as the Image studio's default", () => {
expect(viewerDefaults(d, IMAGE_STUDIO.uncaptioned, undefined)).toBe(d);
expect(viewerDefaults(EDIT_STUDIO.defaultModels, EDIT_STUDIO.uncaptioned, false)).toBe(EDIT_STUDIO.defaultModels);
const studio = { ...IMAGE_STUDIO, defaultModels: viewerDefaults(d, IMAGE_STUDIO.uncaptioned, false) };
- expect(best(studio, "open")).toEqual(["oss-qwen-image-21", "oss-ideogram-4", "oss-krea2-realism", "oss-moss-image"]);
+ expect(best(studio, "open")).toEqual(["oss-qwen-image-21", "oss-ideogram-4", "oss-flux3-klein", "oss-krea2-realism"]);
});
});
diff --git a/tests/training.test.ts b/tests/training.test.ts
index 974ec2c3..1c699a10 100644
--- a/tests/training.test.ts
+++ b/tests/training.test.ts
@@ -130,6 +130,8 @@ describe("Fuobe Soul ID targets (build plan O3)", () => {
"fal-flux2-klein-4b",
"fal-flux2-klein-9b",
"fal-krea-2",
+ "aitk-flux3-klein",
+ "fal-flux3-klein",
]);
// The portrait trainer crops to a face: no style on it, and no place or object either (they train on FLUX.1 on the GPU).
// Fuobe Soul's style trains on fal's Z-Image trainer.