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.
TypeScript ai-videocomfyuicreative-toolsgenerative-aiideogramimage-generationimage-to-3dimage-to-videoltx-videominimax-h3nextjsopen-sourceopen-weightsqwen-imagetext-to-imagevideo-generationwan
FLUX 3 Klein fixes: cloud edits keep image 1's shape, a Prompt helper on fal, Klein Base's plain routes, Edit's Best list kept
Claude371d228df4dc
diff --git a/docs/research/new-models-10.json b/docs/research/new-models-10.jsonindex 2e3faa57..2924b6b5 100644--- a/docs/research/new-models-10.json+++ b/docs/research/new-models-10.json@@ -3015,6 +3015,550 @@"schemaUrl": "https://fal.ai/api/openapi/queue/openapi.json?endpoint_id=blackforestlabs/flux-3/klein/base/edit-image/lora","capability": "edit","fetched": "2026-11-01"+ },+ {+ "family": "flux-3-klein",+ "model": "FLUX 3 Klein Base",+ "title": "FLUX.3 Klein Base (Text to Image)",+ "vendor": "Black Forest Labs",+ "operation": "t2i",+ "provider": "fal",+ "endpoint": "blackforestlabs/flux-3/klein/base/text-to-image",+ "falCategory": "text-to-image",+ "status": "active",+ "keyFields": {+ "prompt": "prompt",+ "aspectRatio": "image_size",+ "seed": "seed",+ "numOutputs": "num_images",+ "enhancePrompt": "enable_prompt_expansion",+ "boundingBoxes": "bounding_boxes"+ },+ "inputs": {+ "prompt": {+ "type": "string",+ "required": true,+ "desc": "The prompt to generate an image from. The model is trained on detailed captions: describe framing, subject, background and lighting.",+ "examples": [+ "A red fox standing in fresh snow at sunrise, its breath visible in the cold air. Soft golden light rakes across the snowfield from the left, pine forest softly blurred in the background, shot at eye level with a telephoto lens."+ ]+ },+ "enable_prompt_expansion": {+ "type": "boolean",+ "required": false,+ "default": true,+ "desc": "If set to true, the prompt is expanded into a detailed caption (grounded in the reference images when editing) before generation."+ },+ "seed": {+ "nullable": true,+ "type": "integer",+ "required": false,+ "desc": "The same seed and the same prompt given to the same version of the model will output the same image every time."+ },+ "num_images": {+ "type": "integer",+ "required": false,+ "default": 1,+ "minimum": 1,+ "maximum": 4,+ "desc": "The number of images to generate."+ },+ "enable_safety_checker": {+ "type": "boolean",+ "required": false,+ "default": true,+ "desc": "If set to true, the safety checker will be enabled."+ },+ "output_format": {+ "type": "enum",+ "values": [+ "jpeg",+ "png",+ "webp"+ ],+ "valueType": "string",+ "required": false,+ "default": "png",+ "desc": "The format of the generated image."+ },+ "sync_mode": {+ "type": "boolean",+ "required": false,+ "default": false,+ "desc": "If `True`, the media will be returned as a data URI and the output data won't be available in the request history."+ },+ "image_size": {+ "type": "union",+ "variants": [+ {+ "type": "object",+ "fields": {+ "width": {+ "type": "integer",+ "required": false,+ "default": 512,+ "maximum": 14142,+ "minimumExclusive": 0,+ "desc": "The width of the generated image."+ },+ "height": {+ "type": "integer",+ "required": false,+ "default": 512,+ "maximum": 14142,+ "minimumExclusive": 0,+ "desc": "The height of the generated image."+ }+ },+ "required": false+ },+ {+ "type": "enum",+ "values": [+ "square_hd",+ "square",+ "portrait_4_3",+ "portrait_16_9",+ "landscape_4_3",+ "landscape_16_9"+ ],+ "valueType": "string",+ "required": false+ }+ ],+ "default": "square_hd",+ "desc": "The size of the generated image. Each side can be 256 to 4096 pixels (native 4K)."+ },+ "bounding_boxes": {+ "nullable": true,+ "type": "array",+ "items": "object",+ "itemSchema": {+ "box": {+ "type": "object",+ "fields": {+ "y_max": {+ "type": "number",+ "required": false,+ "minimum": 0,+ "maximum": 1,+ "desc": "Bottom edge as a fraction of the image height (0-1).",+ "examples": [+ 0.9+ ]+ },+ "x_max": {+ "type": "number",+ "required": false,+ "minimum": 0,+ "maximum": 1,+ "desc": "Right edge as a fraction of the image width (0-1).",+ "examples": [+ 0.7+ ]+ },+ "x_min": {+ "type": "number",+ "required": false,+ "minimum": 0,+ "maximum": 1,+ "desc": "Left edge as a fraction of the image width (0-1).",+ "examples": [+ 0.3+ ]+ },+ "y_min": {+ "type": "number",+ "required": false,+ "minimum": 0,+ "maximum": 1,+ "desc": "Top edge as a fraction of the image height (0-1).",+ "examples": [+ 0.4+ ]+ }+ },+ "required": false+ },+ "label": {+ "nullable": true,+ "type": "string",+ "required": false,+ "maxLength": 64,+ "desc": "Short name for the object in this box, e.g. `fox`. Write `<fox>` in the prompt to tie the box to those words; a box the prompt doesn't name is added to the scene. Defaults to `obj_<n>`.",+ "examples": [+ "fox"+ ]+ },+ "description": {+ "type": "string",+ "required": false,+ "maxLength": 500,+ "desc": "What to draw in this box: the object and its look.",+ "examples": [+ "a red fox with thick orange fur and a white-tipped tail"+ ]+ }+ },+ "itemRequired": [+ "description",+ "box"+ ],+ "maxItems": 32,+ "required": false,+ "desc": "Optional layout: draw each described object inside its box. Box edges are fractions of the image size, with (0, 0) at the top-left. Name boxes in the prompt by label, e.g. `A red fox <fox> sits under a red umbrella <umbrella>`."+ }+ },+ "output": "images[].url",+ "price": "Planned per-image pricing by output resolution: 768×768: $0.024, 1K: $0.027, 1.5K: $0.033, 2K: $0.042, and 4K: $0.108. The same schedule is planned for text-to-image generation and image editing.",+ "pricing": {+ "usd": 0.027,+ "unit": "image",+ "byResolution": {+ "1K": 0.027,+ "1.5K": 0.033,+ "2K": 0.042,+ "4K": 0.108+ }+ },+ "license": "FLUX Kommunity License v1.0: non-commercial use, plus commercial outputs for Qualifying Users under US$5M gross annual revenue (affiliates included); other commercial use needs a BFL licence. Its commercial-use exception is not blanket permission for commercial fine-tuning or distribution. The Qwen3-VL-4B-Instruct text encoder is Apache-2.0",+ "notes": "Send enable_prompt_expansion false with a Fuobe layout; the boxes go as bounding_boxes ({box: {x_min, y_min, x_max, y_max} as 0-1 fractions, label, description}), the prompt naming each box as <label>. image_size takes 256-4096 px a side.",+ "verified": true,+ "sourceUrl": "https://fal.ai/models/blackforestlabs/flux-3/klein/base/text-to-image",+ "schemaUrl": "https://fal.ai/api/openapi/queue/openapi.json?endpoint_id=blackforestlabs/flux-3/klein/base/text-to-image",+ "capability": "t2i",+ "fetched": "2026-11-01"+ },+ {+ "family": "flux-3-klein",+ "model": "FLUX 3 Klein Base",+ "title": "FLUX.3 Klein Base (Image Editing)",+ "vendor": "Black Forest Labs",+ "operation": "edit",+ "provider": "fal",+ "endpoint": "blackforestlabs/flux-3/klein/base/edit-image",+ "falCategory": "image-to-image",+ "status": "active",+ "keyFields": {+ "prompt": "prompt",+ "aspectRatio": "image_size",+ "seed": "seed",+ "numOutputs": "num_images",+ "enhancePrompt": "enable_prompt_expansion",+ "boundingBoxes": "bounding_boxes",+ "images": "image_urls"+ },+ "inputs": {+ "prompt": {+ "type": "string",+ "required": true,+ "desc": "A complete caption of the target image with the edit folded in. Refer to the references by their order: the first image, the second image.",+ "examples": [+ "A miniature grey amigurumi knight figure crocheted from thick woolen yarn stands on a cliff of stacked yarn skeins at night, lit by a full moon, next to a large fluffy knitted dragon in terracotta and mustard yarn, with a soft out-of-focus backdrop of indigo knitted yarn."+ ]+ },+ "enable_prompt_expansion": {+ "type": "boolean",+ "required": false,+ "default": true,+ "desc": "If set to true, the prompt is expanded into a detailed caption (grounded in the reference images when editing) before generation."+ },+ "seed": {+ "nullable": true,+ "type": "integer",+ "required": false,+ "desc": "The same seed and the same prompt given to the same version of the model will output the same image every time."+ },+ "num_images": {+ "type": "integer",+ "required": false,+ "default": 1,+ "minimum": 1,+ "maximum": 4,+ "desc": "The number of images to generate."+ },+ "enable_safety_checker": {+ "type": "boolean",+ "required": false,+ "default": true,+ "desc": "If set to true, the safety checker will be enabled."+ },+ "output_format": {+ "type": "enum",+ "values": [+ "jpeg",+ "png",+ "webp"+ ],+ "valueType": "string",+ "required": false,+ "default": "png",+ "desc": "The format of the generated image."+ },+ "sync_mode": {+ "type": "boolean",+ "required": false,+ "default": false,+ "desc": "If `True`, the media will be returned as a data URI and the output data won't be available in the request history."+ },+ "image_urls": {+ "type": "array",+ "items": "string",+ "minItems": 1,+ "maxItems": 10,+ "required": true,+ "desc": "The reference images to edit or compose from (up to 10).",+ "examples": [+ [+ "https://storage.googleapis.com/falserverless/example_inputs/z-image-turbo-i2i-input.png"+ ]+ ]+ },+ "image_size": {+ "nullable": true,+ "type": "union",+ "variants": [+ {+ "type": "object",+ "fields": {+ "width": {+ "type": "integer",+ "required": false,+ "default": 512,+ "maximum": 14142,+ "minimumExclusive": 0,+ "desc": "The width of the generated image."+ },+ "height": {+ "type": "integer",+ "required": false,+ "default": 512,+ "maximum": 14142,+ "minimumExclusive": 0,+ "desc": "The height of the generated image."+ }+ },+ "required": false+ },+ {+ "type": "enum",+ "values": [+ "square_hd",+ "square",+ "portrait_4_3",+ "portrait_16_9",+ "landscape_4_3",+ "landscape_16_9"+ ],+ "valueType": "string",+ "required": false+ }+ ],+ "desc": "The size of the generated image, 256 to 4096 pixels per side. If not set, a single reference image's own size (scaled to at most 4 megapixels) is used, or the first reference image's size (at most 1 megapixel) when several are given."+ },+ "bounding_boxes": {+ "nullable": true,+ "type": "array",+ "items": "object",+ "itemSchema": {+ "box": {+ "nullable": true,+ "type": "object",+ "fields": {+ "y_max": {+ "type": "number",+ "required": false,+ "minimum": 0,+ "maximum": 1,+ "desc": "Bottom edge as a fraction of the image height (0-1).",+ "examples": [+ 0.9+ ]+ },+ "x_max": {+ "type": "number",+ "required": false,+ "minimum": 0,+ "maximum": 1,+ "desc": "Right edge as a fraction of the image width (0-1).",+ "examples": [+ 0.7+ ]+ },+ "x_min": {+ "type": "number",+ "required": false,+ "minimum": 0,+ "maximum": 1,+ "desc": "Left edge as a fraction of the image width (0-1).",+ "examples": [+ 0.3+ ]+ },+ "y_min": {+ "type": "number",+ "required": false,+ "minimum": 0,+ "maximum": 1,+ "desc": "Top edge as a fraction of the image height (0-1).",+ "examples": [+ 0.4+ ]+ }+ },+ "required": false,+ "desc": "Where the object goes in the output image, as on text-to-image. Use instead of `source_box`/`target_box`."+ },+ "source_box": {+ "nullable": true,+ "type": "object",+ "fields": {+ "y_max": {+ "type": "number",+ "required": false,+ "minimum": 0,+ "maximum": 1,+ "desc": "Bottom edge as a fraction of the image height (0-1).",+ "examples": [+ 0.9+ ]+ },+ "x_max": {+ "type": "number",+ "required": false,+ "minimum": 0,+ "maximum": 1,+ "desc": "Right edge as a fraction of the image width (0-1).",+ "examples": [+ 0.7+ ]+ },+ "x_min": {+ "type": "number",+ "required": false,+ "minimum": 0,+ "maximum": 1,+ "desc": "Left edge as a fraction of the image width (0-1).",+ "examples": [+ 0.3+ ]+ },+ "y_min": {+ "type": "number",+ "required": false,+ "minimum": 0,+ "maximum": 1,+ "desc": "Top edge as a fraction of the image height (0-1).",+ "examples": [+ 0.4+ ]+ }+ },+ "required": false,+ "desc": "Where the object is in the reference image. Requires `source_image_index`."+ },+ "label": {+ "nullable": true,+ "type": "string",+ "required": false,+ "maxLength": 64,+ "desc": "Short name for the object in this box, e.g. `dragon`. Write `<dragon>` in the prompt to tie the box to those words; a box the prompt doesn't name is added to the scene. Defaults to `obj_<n>`.",+ "examples": [+ "dragon"+ ]+ },+ "description": {+ "type": "string",+ "required": false,+ "maxLength": 500,+ "desc": "What to draw in this box: the object and its look.",+ "examples": [+ "a large fluffy knitted dragon in terracotta and mustard yarn"+ ]+ },+ "target_box": {+ "nullable": true,+ "type": "object",+ "fields": {+ "y_max": {+ "type": "number",+ "required": false,+ "minimum": 0,+ "maximum": 1,+ "desc": "Bottom edge as a fraction of the image height (0-1).",+ "examples": [+ 0.9+ ]+ },+ "x_max": {+ "type": "number",+ "required": false,+ "minimum": 0,+ "maximum": 1,+ "desc": "Right edge as a fraction of the image width (0-1).",+ "examples": [+ 0.7+ ]+ },+ "x_min": {+ "type": "number",+ "required": false,+ "minimum": 0,+ "maximum": 1,+ "desc": "Left edge as a fraction of the image width (0-1).",+ "examples": [+ 0.3+ ]+ },+ "y_min": {+ "type": "number",+ "required": false,+ "minimum": 0,+ "maximum": 1,+ "desc": "Top edge as a fraction of the image height (0-1).",+ "examples": [+ 0.4+ ]+ }+ },+ "required": false,+ "desc": "Where the object goes in the output image. Leave unset to remove a referenced object; set both boxes to move or resize it."+ },+ "source_image_index": {+ "nullable": true,+ "type": "integer",+ "required": false,+ "minimum": 0,+ "desc": "0-based index into `image_urls` of the reference the object comes from. Leave unset for a new object."+ }+ },+ "itemRequired": [+ "description"+ ],+ "maxItems": 32,+ "required": false,+ "desc": "Optional layout, with (0, 0) at the top-left of each image: keep, move, resize or remove objects from the references, or place new ones. Name boxes in the prompt by label, e.g. `<dragon>`."+ }+ },+ "output": "images[].url",+ "price": "Planned per-image pricing by output resolution: 768×768: $0.024, 1K: $0.027, 1.5K: $0.033, 2K: $0.042, and 4K: $0.108. The same schedule is planned for text-to-image generation and image editing.",+ "pricing": {+ "usd": 0.027,+ "unit": "image",+ "byResolution": {+ "1K": 0.027,+ "1.5K": 0.033,+ "2K": 0.042,+ "4K": 0.108+ }+ },+ "license": "FLUX Kommunity License v1.0: non-commercial use, plus commercial outputs for Qualifying Users under US$5M gross annual revenue (affiliates included); other commercial use needs a BFL licence. Its commercial-use exception is not blanket permission for commercial fine-tuning or distribution. The Qwen3-VL-4B-Instruct text encoder is Apache-2.0",+ "notes": "Send enable_prompt_expansion false with a Fuobe layout; the boxes go as bounding_boxes ({box: {x_min, y_min, x_max, y_max} as 0-1 fractions, label, description}), the prompt naming each box as <label>. image_size takes 256-4096 px a side.",+ "verified": true,+ "sourceUrl": "https://fal.ai/models/blackforestlabs/flux-3/klein/base/edit-image",+ "schemaUrl": "https://fal.ai/api/openapi/queue/openapi.json?endpoint_id=blackforestlabs/flux-3/klein/base/edit-image",+ "capability": "edit",+ "fetched": "2026-11-01"}]}diff --git a/docs/research/new-models-10.md b/docs/research/new-models-10.mdindex 8bb4641d..1f07693f 100644--- a/docs/research/new-models-10.md+++ b/docs/research/new-models-10.md@@ -649,7 +649,7 @@ Every brief also carries the standard CLOUD ONLY WHERE IT IS HOSTED, MAIN CHANGE- **FLUX 3 Image Klein** (checked by `nm10-flux3-klein` on 2026-11-01, corrections and additions):- The ComfyUI repack is `black-forest-labs/flux-3-image-klein-comfy` (BFL's own repository, not Comfy-Org's), revision `feef60b0`, gated "auto"; every size in §6.3 matches its tree. Its Qwen3-VL-4B int8 encoder and flux2-vae have the same names and byte sizes as the ungated Comfy-Org FIBO 2 and flux2-dev files Fuobe already pins (the gated tree hides their SHA-256, so identity is by size only). The repack's own `workflows/` folder is gated too; the graphs were read from Comfy-Org's templates (`image_flux3_klein_*`, workflow_templates 0.11.86, minComfyUIVersion 0.41.0), whose model notes name `flux3_image_klein_sd_int8_convrot.safetensors`, a file that is not in the repository (the files are `flux3-image-klein-*-int8-convrot`). The distilled template runs 15 steps (the card says 16). Every class the graphs use (TextGenerate, ReferenceMultiLatent, BatchImagesNode, EmptyFlux2LatentImage, CLIPLoader type `flux3`) is in ComfyUI v0.41.0-7 (`fc04da91`): no pin bump.- The card's download line names the int8 prompt upsampler (9.75 GB); the Comfy templates load the w4a8 one (6.72 GB), which Fuobe uses. The upsampler (`black-forest-labs/flux-3-image-klein-pup`, revision `3f3edb52`) is Apache-2.0 and ungated; its README gives the decoding (greedy, top_p 0.95, top_k 20, presence penalty 1.5 for text to image and 0 for edits) and four system prompts (`t2i`, `i2i`, `t2i_bbox`, `i2i_bbox`).- - fal: all six inference endpoints and both trainers are `active` (read with `scripts/fetch-hosted-schemas.py --new10` into this file's `endpointRecords` and the Originals research's `trainers[]`). Prices confirmed: per image $0.008 at 768², $0.009 1K, $0.011 1.5K, $0.014 2K, $0.036 4K ("planned"); /lora $0.012 per megapixel; Klein Base /lora $0.035 per megapixel; trainer $0.0043 a step (at least 100); the edit trainer $0.002 a step times a factor per reference image (x2.11 with 1 … x23.44 with 10). Schema drift since round 4: text-to-image's `image_size` now says "256 to 4096 pixels (native 4K)". The plain `base/text-to-image` and `base/edit-image` endpoints exist but are not in fal's catalog listing (planned $0.027 at 1K); not used. fal's trainer page says to run its LoRAs on the Klein LoRA endpoints, "base recommended".+ - fal: all six inference endpoints and both trainers are `active` (read with `scripts/fetch-hosted-schemas.py --new10` into this file's `endpointRecords` and the Originals research's `trainers[]`). Prices confirmed: per image $0.008 at 768², $0.009 1K, $0.011 1.5K, $0.014 2K, $0.036 4K ("planned"); /lora $0.012 per megapixel; Klein Base /lora $0.035 per megapixel; trainer $0.0043 a step (at least 100); the edit trainer $0.002 a step times a factor per reference image (x2.11 with 1 … x23.44 with 10). Schema drift since round 4: text-to-image's `image_size` now says "256 to 4096 pixels (native 4K)". Correction (the package's review, re-read the same day): the plain `base/text-to-image` and `base/edit-image` endpoints are active and in fal's catalog (`api.fal.ai/v1/models?endpoint_id=…` lists both), with the same inputs as the /lora twins minus `loras`, and planned per-image prices of $0.024 at 768², $0.027 at 1K, $0.033 at 1.5K, $0.042 at 2K and $0.108 at 4K. They are now `flux-3-klein-base`'s routes, with the /lora twins as their `loraEndpoint` (a Base run without LoRAs is $0.108 at 4K, not $0.56 on the /lora route); read with `scripts/fetch-hosted-schemas.py --new10 <endpoint …>` into `endpointRecords`. fal's trainer page says to run its LoRAs on the Klein LoRA endpoints, "base recommended".- AI-Toolkit (main `e9c72b7`, 2026-10-31) trains FLUX 3 Image Klein Base: `extensions_built_in/diffusion_models/flux3`, arch `flux3`, `black-forest-labs/flux-3-image-klein-base` (gated), its UI's defaults convrot8 quantization, shift timesteps, guidance 3.5, 28 sample steps. Fuobe pins no AI-Toolkit version (it links the repository), so the open engine trains Klein on that.- **Licences not confirmed from a LICENSE file:** FastH3 Omni, Sol-H3-VAE (HF tag empty), LightVAE, Veda, the LightX2V Qwen-Image 2.1 Lightning LoRA (HF tag empty; comfyui-wiki says Apache-2.0), akhaliq's Qwen-Image 2.1 Next-Scene and Multiple-Angles LoRAs (HF API refused an anonymous read), FeyNoBg, UltraTex, the NVIDIA VFX node pack, Kroma, Krea 2 Edit V2, Anima Reference Adapter. MiniMax Music 3's own LICENSE ("MiniMax-Music3 Community License") differs from the Comfy-Org repack's Apache-2.0 tag: both are recorded.- **VRAM:** almost no publisher gives consumer-GPU VRAM. Figures here are the publisher's tests (FastH3 Trim's 8 GB cap; FLUX 3 Klein's B200 peaks; CorridorKey's 4-6 GB; VoxCPM2's 8 GB) or third-party measurements (Freefield's 17.8 GB for Klein; one tester's ~90 GB for Alpha-Gen at 4K; the Hy-Nomas port's 5090 timings). Nothing ran on a GPU here.diff --git a/scripts/fetch-hosted-schemas.py b/scripts/fetch-hosted-schemas.pyindex b66fd482..63138786 100644--- a/scripts/fetch-hosted-schemas.py+++ b/scripts/fetch-hosted-schemas.py@@ -22,7 +22,7 @@ Run: python3 scripts/fetch-hosted-schemas.pypython3 scripts/fetch-hosted-schemas.py --base-only [endpoint …] (Genjutsu's plain endpoints, or O11's / BASE ones by id, the rest kept)python3 scripts/fetch-hosted-schemas.py --partner (partner routes in partnerEndpoints, the rest kept)python3 scripts/fetch-hosted-schemas.py --part4 [endpoint …] (PART4's records in paid-model-apis-4.json, the rest kept)- python3 scripts/fetch-hosted-schemas.py --new10 (FLUX 3 Klein: NEW10's records in new-models-10.json, its trainers)+ python3 scripts/fetch-hosted-schemas.py --new10 [endpoint …] (FLUX 3 Klein: NEW10's records in new-models-10.json, its trainers; or those named)--part4 re-reads endpoints that research part 4 recorded (docs/research/paid-model-apis-4.json) and refreshes them inplace: their inputs, the price lines of their llms.txt, their status in fal's catalog (active / playground-only, read@@ -194,6 +194,9 @@ NEW10 = {"blackforestlabs/flux-3/klein/edit-image": ("edit", KLEIN_EDIT, "FLUX 3 Klein", "FLUX.3 Klein Image Editing"),"blackforestlabs/flux-3/klein/text-to-image/lora": ("t2i", {**KLEIN_T2I, "loras": "loras"}, "FLUX 3 Klein LoRA", "FLUX 3 Klein Text to Image LoRA"),"blackforestlabs/flux-3/klein/edit-image/lora": ("edit", {**KLEIN_EDIT, "loras": "loras"}, "FLUX 3 Klein LoRA", "FLUX 3 Klein Edit LoRA"),+ # Klein Base's plain routes (no LoRAs; planned per-image prices, $0.027 at 1K) and its /lora twins.+ "blackforestlabs/flux-3/klein/base/text-to-image": ("t2i", KLEIN_T2I, "FLUX 3 Klein Base", "FLUX.3 Klein Base (Text to Image)"),+ "blackforestlabs/flux-3/klein/base/edit-image": ("edit", KLEIN_EDIT, "FLUX 3 Klein Base", "FLUX.3 Klein Base (Image Editing)"),"blackforestlabs/flux-3/klein/base/text-to-image/lora": ("t2i", {**KLEIN_T2I, "loras": "loras"}, "FLUX 3 Klein Base LoRA", "FLUX 3 Klein Base Text to Image LoRA"),"blackforestlabs/flux-3/klein/base/edit-image/lora": ("edit", {**KLEIN_EDIT, "loras": "loras"}, "FLUX 3 Klein Base LoRA", "FLUX 3 Klein Base Edit LoRA"),}@@ -456,19 +459,24 @@ def trainer_field(s):return " ".join(out)-def new10():- """Research #10's FLUX 3 Klein records: its fal endpoints (endpointRecords in new-models-10.json) and LoRA trainers."""+def new10(ids):+ """Research #10's FLUX 3 Klein records: its fal endpoints (endpointRecords in new-models-10.json) and LoRA trainers; only+ the endpoints or trainers named in `ids` when it names any, the rest kept as they are."""path = ROOT / "docs/research/new-models-10.json"data = json.loads(path.read_text(encoding="utf-8"))records = {e["endpoint"]: e for e in data.get("endpointRecords") or []}for ep, (op, kf, model, title) in NEW10.items():+ if ids and ep not in ids:+ continueinputs = fal(ep)missing = [f for f in kf.values() if f not in inputs]if missing:sys.exit(f"{ep}: keyFields {missing} are not inputs")price = llms_price(ep)per_mp = re.search(r"\$(\d+(?:\.\d+)?) per megapixel", price or "")- tiers = re.findall(r"\$(\d+(?:\.\d+)?) at (\d+(?:\.\d+)?K)\b", price or "")+ # "$0.009 at 1K" (Klein's) or "1K: $0.027" (Klein Base's plain routes).+ tiers = re.findall(r"\$(\d+(?:\.\d+)?) at (\d+(?:\.\d+)?K)\b", price or "") or [+ (v, k) for k, v in re.findall(r"\b(\d+(?:\.\d+)?K): \$(\d+(?:\.\d+)?)", price or "")]if per_mp:pricing = {"usd": float(per_mp.group(1)), "unit": "megapixel"}elif tiers:@@ -492,6 +500,8 @@ def new10():raw = json.loads(FILE.read_text(encoding="utf-8"))by_id = {t["id"]: t for t in raw["trainers"]}for ep, (family, role) in NEW10_TRAINERS.items():+ if ids and ep not in ids:+ continueinputs = fal(ep)root = json.loads(get(f"https://fal.ai/api/openapi/queue/openapi.json?endpoint_id={ep}"))result = root["paths"][f"/{ep}/requests/{{request_id}}"]["get"]["responses"]["200"]["content"]["application/json"]["schema"]@@ -514,7 +524,7 @@ def new10():def main():if "--new10" in sys.argv:- new10()+ new10(sys.argv[sys.argv.index("--new10") + 1:])returnif "--part4" in sys.argv:part4(sys.argv[sys.argv.index("--part4") + 1:])diff --git a/scripts/gen-cloud-models.py b/scripts/gen-cloud-models.pyindex e0cafc26..2307432d 100644--- a/scripts/gen-cloud-models.py+++ b/scripts/gen-cloud-models.py@@ -220,22 +220,30 @@ model("moss-image", "MOSS-Image", "OpenMOSS", "moss", "image","checked": MOSS_FAL["fetched"]})# FLUX 3 Image Klein (research #10 §6.3, package nm10-flux3-klein): BFL's open 5.6B model on fal, priced per image by tier# ($0.009 at 1K … $0.036 at 4K, fal's planned rates); a run with LoRAs goes to its /lora twin ($0.012 per megapixel, up to 3 LoRAs-# at 0-4). FLUX 3 Klein Base (the checkpoint BFL and fal's trainer train LoRAs on, which fal recommends running them on) has LoRA-# routes only, $0.035 per megapixel. A layout goes as bounding_boxes with prompt expansion off. Licence: information, never a gate.+# at 0-4). FLUX 3 Klein Base (the checkpoint BFL and fal's trainer train LoRAs on, which fal recommends running them on): its plain+# routes per image by tier ($0.027 at 1K … $0.108 at 4K, planned), a run with LoRAs on its /lora twins at $0.035 per megapixel.+# A layout with boxes goes as bounding_boxes with prompt expansion off. Licence: information, never a gate.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_BASE_REC = next(e for e in NEW_MODELS_10["endpointRecords"] if e["endpoint"] == f"{KLEIN_FAL}/base/text-to-image")KLEIN_LICENCE = {"licence": KLEIN_REC["license"].split(":")[0], "commercial": None, "note": KLEIN_REC["license"], "checked": KLEIN_REC["fetched"]}+# Options → Prompt helper, as on your GPU (params.extra.promptHelper, src/lib/catalog/models.ts KLEIN_PROMPT_HELPER): "off" sends+# enable_prompt_expansion false (payload.ts), "on" leaves fal's default; a layout that places boxes always turns it off.+KLEIN_HELPER = {"param": "promptHelper", "label": "Prompt helper", "values": ["on", "off"], "default": "on",+ "labels": {"on": "On · fal writes a full caption (not with layout boxes)", "off": "Off · your words as typed"}}model("flux-3-klein", "FLUX 3 Klein", "Black Forest Labs", "flux", "image",- "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",+ "BFL's open 5.6B model, hosted: up to 4K, edits with up to 10 references in image 1's shape, layout boxes, Prompt helper · 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"},+ ("edit", f"{KLEIN_FAL}/edit-image", "fal", {"loraEndpoint": f"{KLEIN_FAL}/edit-image/lora", "followsImage": True})],+ badges=["new"], defaults={"aspectRatio": "1:1", "resolution": "1K"}, tier_size=f"{KLEIN_FAL}/text-to-image", options={"layout": "flux3", "controls": [KLEIN_HELPER]},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",+model("flux-3-klein-base", "FLUX 3 Klein Base", "Black Forest Labs", "flux", "image","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"},+ [("t2i", f"{KLEIN_FAL}/base/text-to-image", "fal", {"loraEndpoint": f"{KLEIN_FAL}/base/text-to-image/lora"}),+ ("edit", f"{KLEIN_FAL}/base/edit-image", "fal", {"loraEndpoint": f"{KLEIN_FAL}/base/edit-image/lora", "followsImage": True})],+ badges=["new"], defaults={"aspectRatio": "1:1", "resolution": "1K"}, tier_size=f"{KLEIN_FAL}/text-to-image", options={"layout": "flux3", "controls": [KLEIN_HELPER]},+ pricing=("image", KLEIN_BASE_REC["pricing"]["usd"], "per image at 1K (fal's planned rates by size)", {"byResolution": KLEIN_BASE_REC["pricing"]["byResolution"]}),licence=KLEIN_LICENCE)model("wan-2-7-image", "Wan 2.7 Image", "Alibaba Wan", "wan", "image","Wan's image model — cinematic stills that animate well",@@ -2138,6 +2146,11 @@ def build_route(op, ep, provider, m, opts, ropts=None):route = {"op": op, "provider": provider, "endpoint": f"{ep}:{version}" if ropts.get("pin") else ep, "map": fmap}if ropts.get("note"):route["note"] = ropts["note"]+ # The picture follows image 1's shape at the chosen tier (ModelRoute.followsImage: fal's FLUX 3 Klein edit; the server sizes it).+ if ropts.get("followsImage"):+ if "size" not in fmap:+ warn(f"{m['id']}: {ep} follows image 1 but sends no size")+ route["followsImage"] = Trueif lora_ep:le = EPS.get((provider, lora_ep))if not le:diff --git a/src/lib/catalog/cloud-models.generated.ts b/src/lib/catalog/cloud-models.generated.tsindex 6d712399..81c273d0 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, hosted: up to 4K, edits with up to 10 references, layout boxes; fal writes the full caption \u00b7 FLUX Kommunity licence",+ "tagline": "BFL's open 5.6B model, hosted: up to 4K, edits with up to 10 references in image 1's shape, layout boxes, Prompt helper \u00b7 FLUX Kommunity licence","routes": [{"op": "t2i",@@ -1800,7 +1800,10 @@ export const CLOUD_MODELS: ModelDef[] = ["min": 0,"max": 4}- }+ },+ "ignore": [+ "promptHelper"+ ]},"loraEndpoint": "blackforestlabs/flux-3/klein/text-to-image/lora"},@@ -1837,8 +1840,12 @@ export const CLOUD_MODELS: ModelDef[] = ["min": 0,"max": 4}- }+ },+ "ignore": [+ "promptHelper"+ ]},+ "followsImage": true,"loraEndpoint": "blackforestlabs/flux-3/klein/edit-image/lora"}],@@ -1864,7 +1871,22 @@ export const CLOUD_MODELS: ModelDef[] = ["seed": true,"maxOutputs": 4,"maxImages": 10,- "layout": "flux3"+ "layout": "flux3",+ "controls": [+ {+ "param": "promptHelper",+ "label": "Prompt helper",+ "values": [+ "on",+ "off"+ ],+ "default": "on",+ "labels": {+ "on": "On \u00b7 fal writes a full caption (not with layout boxes)",+ "off": "Off \u00b7 your words as typed"+ }+ }+ ]},"badges": ["new"@@ -1894,7 +1916,7 @@ export const CLOUD_MODELS: ModelDef[] = [},{"id": "flux-3-klein-base",- "name": "FLUX 3 Klein Base with LoRAs",+ "name": "FLUX 3 Klein Base","vendor": "Black Forest Labs","family": "flux","engine": "cloud",@@ -1904,7 +1926,7 @@ export const CLOUD_MODELS: ModelDef[] = [{"op": "t2i","provider": "fal",- "endpoint": "blackforestlabs/flux-3/klein/base/text-to-image/lora",+ "endpoint": "blackforestlabs/flux-3/klein/base/text-to-image","map": {"numOutputs": "num_images","seed": "seed",@@ -1933,13 +1955,17 @@ export const CLOUD_MODELS: ModelDef[] = ["min": 0,"max": 4}- }- }+ },+ "ignore": [+ "promptHelper"+ ]+ },+ "loraEndpoint": "blackforestlabs/flux-3/klein/base/text-to-image/lora"},{"op": "edit","provider": "fal",- "endpoint": "blackforestlabs/flux-3/klein/base/edit-image/lora",+ "endpoint": "blackforestlabs/flux-3/klein/base/edit-image","map": {"images": "image_urls","numOutputs": "num_images",@@ -1969,8 +1995,13 @@ export const CLOUD_MODELS: ModelDef[] = ["min": 0,"max": 4}- }- }+ },+ "ignore": [+ "promptHelper"+ ]+ },+ "followsImage": true,+ "loraEndpoint": "blackforestlabs/flux-3/klein/base/edit-image/lora"}],"options": {@@ -1995,7 +2026,22 @@ export const CLOUD_MODELS: ModelDef[] = ["seed": true,"maxOutputs": 4,"maxImages": 10,- "layout": "flux3"+ "layout": "flux3",+ "controls": [+ {+ "param": "promptHelper",+ "label": "Prompt helper",+ "values": [+ "on",+ "off"+ ],+ "default": "on",+ "labels": {+ "on": "On \u00b7 fal writes a full caption (not with layout boxes)",+ "off": "Off \u00b7 your words as typed"+ }+ }+ ]},"badges": ["new"@@ -2011,8 +2057,16 @@ export const CLOUD_MODELS: ModelDef[] = ["resolution": "1K"},"pricing": {- "unit": "megapixel",- "usd": 0.035+ "unit": "image",+ "usd": 0.027,+ "note": "per image at 1K (fal's planned rates by size)",+ "byResolution": {+ "1K": 0.027,+ "1.5K": 0.033,+ "2K": 0.042,+ "4K": 0.108+ },+ "withLorasPerMegapixel": 0.035}},{diff --git a/src/lib/catalog/models.ts b/src/lib/catalog/models.tsindex f14806b5..1451c845 100644--- a/src/lib/catalog/models.ts+++ b/src/lib/catalog/models.ts@@ -80,14 +80,15 @@ 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.+ * caption Klein is made for (BFL: short prompts give generic pictures); off sends them as typed. A layout that places boxes+ * always goes as typed, which the "on" label says. The cloud's flux-3-klein carries the same control (fal's prompt expansion).*/const KLEIN_PROMPT_HELPER: NonNullable<ModelOptions["controls"]>[number] = {param: PROMPT_HELPER_PARAM,label: "Prompt helper",values: ["on", "off"],default: "on",- labels: { on: "On · writes a full caption", off: "Off · your words as typed" },+ labels: { on: "On · writes a full caption (not with layout boxes)", off: "Off · your words as typed" },};type OpenSpec = Omit<ModelDef, "engine" | "badges"> & { badges?: ModelDef["badges"] };@@ -168,6 +169,8 @@ const open: ModelDef[] = [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 Image studio's Best list, as its brief asks; the Edit studio offers it, and its Best list stays the owner's.+ bestOps: ["t2i"],// 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"),diff --git a/src/lib/catalog/payload.ts b/src/lib/catalog/payload.tsindex dda9dd08..9368f4c9 100644--- a/src/lib/catalog/payload.ts+++ b/src/lib/catalog/payload.ts@@ -1,7 +1,8 @@import { readTimeline, timelineTracks } from "@/lib/av/timeline";import { toH3MaxTrajectory, type CameraKey } from "@/lib/camera-path";import { upscaleFactorFor } from "@/lib/av/upscale";-import { carriesLayout, LAYOUT_PARAM } from "@/lib/layout-prompt";+import { carriesBoxes, carriesLayout, LAYOUT_PARAM } from "@/lib/layout-prompt";+import { PROMPT_HELPER_PARAM } from "@/lib/comfy";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";@@ -523,10 +524,14 @@ export function buildPayload(map: FieldMap, input: GenInput): Record<string, unkfor (const [k, r] of Object.entries(map.ranges ?? {})) if (typeof out[k] === "number") out[k] = inRange(out[k] as number, r);// 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!] : [])]);+ // Options → Prompt helper (params.extra.promptHelper) is Fuobe's own: it goes out as the API's prompt expansion, below.+ const ignore = new Set([...(map.ignore ?? []), LAYOUT_PARAM, PROMPT_HELPER_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;+ // The API's prompt expansion would rewrite a layout's boxes: off whenever the request carries one (a route that takes the+ // boxes in a field of their own, fal's FLUX 3 Klein, only when the draft places any). Prompt helper "off" turns it off too;+ // "on" leaves the API's default (on).+ const laidOut = map.boundingBoxes ? carriesBoxes(input.extra) : carriesLayout(input.extra);+ if (map.promptExpansion && (laidOut || input.extra?.[PROMPT_HELPER_PARAM] === "off")) 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/types.ts b/src/lib/catalog/types.tsindex b3557191..14e985bf 100644--- a/src/lib/catalog/types.ts+++ b/src/lib/catalog/types.ts@@ -550,6 +550,12 @@ export interface ModelRoute {* 2.1's inpaint) or the canvas its pads grow (expand). The composer shows no Aspect ratio or Resolution for its operation.*/unsized?: true;+ /**+ * A cloud edit whose picture follows image 1's shape at the chosen tier (fal's FLUX 3 Klein, as its GPU edit follows reference+ * 1): the server sends image 1's shape on the tier's square in the route's size field (src/server/generations.ts sizedEdit),+ * so the price stays the tier's. The composer shows Resolution but no Aspect ratio for its operation.+ */+ followsImage?: true;/*** The most images this route reads, when fewer than the model's options.maxImages (Qwen-Image 2.1's inpaint and expand* read the picture alone; its edit takes 4): the composer offers no more for its operation, and the plan refuses more.@@ -742,6 +748,12 @@ export interface ModelDef {kind: MediaKind;tagline: string;badges?: Badge[];+ /**+ * The operations whose studios rank it in "Best for this studio" by its badges (bestForStudio), when not all of them: FLUX 3+ * Klein is a top pick for text to image, and the Edit studio offers it without changing its Best list. A studio's default+ * still leads its list.+ */+ bestOps?: Operation[];routes: ModelRoute[];options: ModelOptions;defaults?: Partial<Pick<GenParams, "aspectRatio" | "resolution" | "duration" | "numOutputs" | "generateAudio" | "voice" | "targetFps" | "format">>;diff --git a/src/lib/composer.ts b/src/lib/composer.tsindex d5036d69..fcc6689a 100644--- a/src/lib/composer.ts+++ b/src/lib/composer.ts@@ -84,8 +84,10 @@ export function settingsShape(const ops = op ? [op] : studioOps;const routes = (model?.routes ?? []).filter((r) => ops.includes(r.op));const sized = !routes.length || routes.some((r) => !r.unsized);+ // A cloud edit that follows image 1's shape at the chosen tier (ModelRoute.followsImage: fal's FLUX 3 Klein) keeps Resolution only.+ const shaped = routes.length > 0 && routes.every((r) => r.unsized || r.followsImage);return {- aspect: !sized || op === "i2v" || op === "flf2v" ? null : many(o.aspectRatios),+ aspect: !sized || shaped || op === "i2v" || op === "flf2v" ? null : many(o.aspectRatios),resolution: sized ? many(o.resolutions) : null,duration: params.shots ? null : many(o.durations),count: (kind === "image" || kind === "video") && !single,@@ -1124,7 +1126,9 @@ export function filterModels(models: ModelDef[], opts: { kind?: MediaKind; ops?:*/export function bestForStudio(models: ModelDef[], engine: Engine, defaultId: string | undefined, max = 4, op?: Operation): ModelDef[] {const pool = models.filter((m) => m.engine === engine && (!op || m.id === defaultId || m.routes.some((r) => r.op === op)));- const score = (m: ModelDef) => (m.id === defaultId ? 0 : m.badges?.includes("top") ? 1 : m.badges?.includes("new") ? 2 : 9);+ // A model ranked by its badges only for some operations (ModelDef.bestOps) isn't ranked in the other studios' lists.+ const ranked = (m: ModelDef) => !op || !m.bestOps || m.bestOps.includes(op);+ const score = (m: ModelDef) => (m.id === defaultId ? 0 : !ranked(m) ? 9 : m.badges?.includes("top") ? 1 : m.badges?.includes("new") ? 2 : 9);return pool.map((m, i) => [m, score(m), i] as const).filter(([, s]) => s < 9)diff --git a/src/lib/layout-prompt.ts b/src/lib/layout-prompt.tsindex 8765d901..0a2fbf78 100644--- a/src/lib/layout-prompt.ts+++ b/src/lib/layout-prompt.ts@@ -717,3 +717,12 @@ export function layoutCompilerFor(model: { options?: { layout?: LayoutFormat } }/** True when a request's params.extra carries a layout draft (an API's own prompt expansion would rewrite it). */export const carriesLayout = (extra: Record<string, unknown> | undefined): boolean => isObj(extra?.[LAYOUT_PARAM]);++/**+ * True when a request's layout draft places at least one box. FLUX 3 Image Klein's Prompt helper (BFL's upsampler on your GPU,+ * fal's prompt expansion in the cloud) is overridden only then: an empty draft's prompt is the caption alone (compileFlux3).+ */+export const carriesBoxes = (extra: Record<string, unknown> | undefined): boolean => {+ const layout = extra?.[LAYOUT_PARAM];+ return isObj(layout) && Array.isArray(layout.items) && layout.items.length > 0;+};diff --git a/src/server/generations.ts b/src/server/generations.tsindex ed5101d0..3dbd0bcc 100644--- a/src/server/generations.ts+++ b/src/server/generations.ts@@ -14,7 +14,7 @@ import { upscaleTier } from "@/lib/av/upscale";import { chainedWaitMessage, framesWait, keyframeChain } from "@/lib/catalog/keyframes";import { clipFpsProblem, clipSizeProblem, clipTotalProblem, clipWindowProblem, elementClipProblem, sourceFrames } from "@/lib/catalog/clip-windows";import { avatarSeconds, clipEditSeconds, estimateCost, inferOperation, movedAppRequest, planGeneration, presetRoute, routeLoras, routesFor, withoutTriggers } from "@/lib/catalog/plan";-import { framedLength, keepMatte } from "@/lib/catalog/payload";+import { framedLength, keepMatte, sizeValue } from "@/lib/catalog/payload";import { fitLoras, loraName, lorasFit } from "@/lib/catalog/loras";import { dualEngine, onEngine, pickEngine } from "@/lib/catalog/engines";import { promptWithLoras, SOUL_MODELS, soulKind, soulLook, soulPostStep, soulPostSteps } from "@/lib/catalog/soul";@@ -632,6 +632,24 @@ function sizedMixedFrame(plan: ReturnType<typeof planGeneration>, req: Generatioreturn fit ? { ...plan, params: { ...plan.params, extra: { ...plan.params.extra, image_size: fit } } } : plan;}+/**+ * A cloud edit that follows image 1's shape (ModelRoute.followsImage: fal's FLUX 3 Klein, whose GPU edit keeps reference 1's+ * shape): image 1's shape on the chosen tier's square, on the route's grid and within its limits, as its size field. Without+ * it the size would be the default aspect ratio's (a 16:9 photo back as a square). The tier, and so the price, stays the one+ * picked. A size the request gives itself wins; a picture that isn't a file in Fuobe keeps the aspect ratio's size.+ */+function sizedEdit(plan: ReturnType<typeof planGeneration>, req: GenerationRequest): ReturnType<typeof planGeneration> {+ if (plan.model.engine !== "cloud" || plan.op !== "edit") return plan;+ const field = plan.model.routes.find((r) => r.op === "edit" && r.followsImage)?.map?.size;+ if (!field?.key || plan.params.extra?.[field.key] !== undefined) return plan;+ const first = req.inputs?.images?.[0];+ const head = first ? localHead(first) : null;+ const shape = head ? imageSize(head) : null;+ if (!shape) return plan;+ const fit = sizeValue(field, `${shape.width}:${shape.height}`, plan.params.resolution ?? plan.model.defaults?.resolution);+ return { ...plan, params: { ...plan.params, extra: { ...plan.params.extra, [field.key]: fit } } };+}+/*** The elements "@Name" can mention: the owner's. An account's run or a visitor's price check has none, so "@Name" stays* words there (an owner's element photo or LoRA never reaches someone else's run).@@ -652,7 +670,7 @@ function prepare(original: GenerationRequest) {const model = allowed && dualEngine(allowed) ? onEngine(allowed, engineFor(allowed, onSide)) : allowed;const lookup = (id: string) => (model && id === model.id ? model : getModel(id));const req = model ? stripMotionPaths(applySketch(applyMentions(worded, model, mentionElements()).request, model).request, model) : worded;- let plan = sizedMixedFrame(planGeneration(req, lookup, getPreset), req);+ let plan = sizedEdit(sizedMixedFrame(planGeneration(req, lookup, getPreset), req), req);if (mode !== "both" && plan.model.engine !== mode) {// An account on the open engine has no key of its own that opens (Your keys), or the studio is open-source only.const cloud = mode === "open" && tenantAccount() ? plan.model.routes.map((r) => r.provider).find(isCloudProvider) : undefined;diff --git a/src/server/providers/comfyui.ts b/src/server/providers/comfyui.tsindex be58b5d3..05cb894f 100644--- a/src/server/providers/comfyui.ts+++ b/src/server/providers/comfyui.ts@@ -43,7 +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 { carriesBoxes, 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";@@ -1478,7 +1478,7 @@ export async function prepareWorkflow(endpointTemplate: string, input: GenInput,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);+ const laidOut = carriesBoxes(extra);delete extra[PROMPT_HELPER_PARAM];delete extra[LAYOUT_PARAM];for (const [k, v] of Object.entries(extra)) values[k as BindingKey] = v;@@ -1563,7 +1563,7 @@ 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.+ // The prompt helper (FLUX 3 Image Klein's upsampler) off, or a layout with 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).diff --git a/tests/e2e/flux3-klein.mjs b/tests/e2e/flux3-klein.mjsindex 0078e234..6ce8f93c 100644--- a/tests/e2e/flux3-klein.mjs+++ b/tests/e2e/flux3-klein.mjs@@ -1,7 +1,8 @@// nm10-flux3-klein in the browser (no run reaches a GPU or fal): FLUX 3 Klein in the Image studio's model menu on both engines,// in its "Best for this studio" list on your GPU beside Ideogram 4 and Qwen-Image 2.1, with its price before the run ($0.009 an-// image at 1K in the cloud, Free on your GPU) and its Prompt helper under Options; the Edit studio taking an image and nine-// references for it (ten in all); the Train dialog's FLUX 3 Klein target ($4.30 for 1,000 steps on fal, Free on your GPU, the+// image at 1K in the cloud, Free on your GPU) and its Prompt helper under Options on both engines (saying a layout with boxes+// goes as typed); the Edit studio taking an image and nine references for it (ten in all), and in the cloud following the+// photo's shape (Resolution, no Aspect ratio); the Train dialog's FLUX 3 Klein target ($4.30 for 1,000 steps on fal, Free on your GPU, the// licence as information); and both rows in Settings → Models & licences, switched on. Each page at 1440 and 390 px, light and// dark, without sideways scroll. The API prices are checked through the preview route: with a fal key ($0.009 at 1K, $0.048 at// 2K with a LoRA on the /lora twin), else as fal's "connect" answer.@@ -167,9 +168,14 @@ try {await page.waitForFunction(() => /\bFree\b|Demo|≈ \$|Connect/.test(document.querySelector("[data-composer]")?.textContent ?? ""), null, { timeout: 20_000 }).catch(() => {});const t = flat(await composer(page).innerText());check(`${tag} ${engine}: the composer runs FLUX 3 Klein`, /FLUX 3 Klein/.test(t), t.slice(0, 100));- if (engine === "open") {- check(`${tag} open: Free before the run`, comfy ? /\bFree\b/.test(t) : /Demo|Free/.test(t), (t.match(/Demo|≈ \$[\d.]+|\bFree\b/) ?? ["no price"])[0]);- // The Prompt helper under Options (on a phone, in the Settings sheet).+ if (engine === "open") check(`${tag} open: Free before the run`, comfy ? /\bFree\b/.test(t) : /Demo|Free/.test(t), (t.match(/Demo|≈ \$[\d.]+|\bFree\b/) ?? ["no price"])[0]);+ else {+ // fal's $0.009 reads "≈ <$0.01" in the composer.+ const price = /≈ <?\$0\.0\d|Demo|Connect fal/;+ check(`${tag} cloud: its price (or fal's connect step) shows before the run`, price.test(t), (t.match(/Demo|Connect[^.]*|≈ <?\$[\d.]+/) ?? ["no price"])[0]);+ }+ {+ // The Prompt helper under Options on both engines (on a phone, in the Settings sheet).let scope = composer(page);if (width < 500) {const settings = composer(page).getByRole("button", { name: /^Settings:/ }).first();@@ -184,7 +190,8 @@ try {const helper = page.getByRole("combobox", { name: "Prompt helper" });await helper.waitFor({ timeout: 10_000 });const hbox = await helper.boundingBox();- check(`${tag} open: Options shows the Prompt helper, on by default`, /On · writes a full caption/.test(flat(await helper.innerText())), flat(await helper.innerText()));+ const on = engine === "open" ? /On · writes a full caption \(not with layout boxes\)/ : /On · fal writes a full caption \(not with layout boxes\)/;+ check(`${tag} ${engine}: Options shows the Prompt helper, on by default, layout boxes named`, on.test(flat(await helper.innerText())), flat(await helper.innerText()));// The words read in full: the text is no wider than the box that shows it.const cut = await helper.evaluate((b) => {const v = b.querySelector('[data-slot="select-value"]') ?? b;@@ -192,16 +199,12 @@ try {r.selectNodeContents(v);return { text: Math.round(r.getBoundingClientRect().width * 10) / 10, box: Math.round(v.getBoundingClientRect().width * 10) / 10 };});- check(`${tag} open: the Prompt helper's words aren't cut off`, cut.text <= cut.box + 0.5, `${cut.text} px of text in ${cut.box} px`);- check(`${tag} open: the Prompt helper fits the screen`, !!hbox && hbox.x >= 0 && hbox.x + hbox.width <= width + 1, hbox ? `${Math.round(hbox.x)}+${Math.round(hbox.width)}` : "no box");- await shoot(page, `klein-options-${width}-${scheme}.png`);+ check(`${tag} ${engine}: the Prompt helper's words aren't cut off`, cut.text <= cut.box + 0.5, `${cut.text} px of text in ${cut.box} px`);+ check(`${tag} ${engine}: the Prompt helper fits the screen`, !!hbox && hbox.x >= 0 && hbox.x + hbox.width <= width + 1, hbox ? `${Math.round(hbox.x)}+${Math.round(hbox.width)}` : "no box");+ await shoot(page, `klein-options-${engine}-${width}-${scheme}.png`);await page.keyboard.press("Escape");await page.keyboard.press("Escape");if (width < 500) await page.keyboard.press("Escape");- } else {- // fal's $0.009 reads "≈ <$0.01" in the composer.- const price = /≈ <?\$0\.0\d|Demo|Connect fal/;- check(`${tag} cloud: its price (or fal's connect step) shows before the run`, price.test(t), (t.match(/Demo|Connect[^.]*|≈ <?\$[\d.]+/) ?? ["no price"])[0]);}check(`${tag} ${engine}: no sideways scroll on the Image studio`, await noSideways(page));await shoot(page, `klein-image-${engine}-${width}-${scheme}.png`);@@ -235,6 +238,22 @@ try {await context.close();}+ // ---- Edit studio in the cloud: the result follows the photo's shape, at the Resolution picked (no Aspect ratio).+ {+ const { context, page } = await contextFor("cloud", width, scheme);+ await openStudio(page, "edit");+ await openMenu(page);+ await pick(page, "Klein", "flux-3-klein");+ await composer(page).locator('input[type="file"]').first().setInputFiles({ name: "wide.png", mimeType: "image/png", buffer: png(21, 320, 180) });+ await page.waitForFunction(() => !/Uploading/.test(document.querySelector("[data-composer]")?.textContent ?? ""), null, { timeout: 30_000 }).catch(() => {});+ await page.waitForTimeout(800);+ const settings = flat(await composer(page).getByRole("button", { name: /^Settings:/ }).first().getAttribute("aria-label"));+ check(`${tag} cloud edit: Resolution without an Aspect ratio (the photo's shape)`, /\b1K\b/.test(settings) && !/\b\d+:\d+\b/.test(settings), settings);+ check(`${tag} cloud edit: no sideways scroll`, await noSideways(page));+ await shoot(page, `klein-edit-cloud-${width}-${scheme}.png`);+ await context.close();+ }+// ---- The Train dialog: FLUX 3 Klein under More models.if (element.id) {const { context, page } = await contextFor("open", width, scheme);diff --git a/tests/flux3-klein.test.ts b/tests/flux3-klein.test.tsindex 5fdf23a6..42345a26 100644--- a/tests/flux3-klein.test.ts+++ b/tests/flux3-klein.test.ts@@ -10,7 +10,7 @@ import { modelChoices } from "@/lib/catalog/canvas";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 { filterModels, settingsShape, 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";@@ -22,6 +22,10 @@ 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");+const { setSetting } = await import("@/server/settings");+const { createGenerations, getGeneration } = await import("@/server/generations");+const { saveFile } = await import("@/server/storage");+const { db } = await import("@/server/db");afterAll(() => fs.rmSync(tmp, { recursive: true, force: true }));const dir = path.join(process.cwd(), "workflows/comfyui");@@ -148,7 +152,7 @@ describe("the provider fills Klein's graphs", () => {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 () => {+ it("takes the helper out when it's off or a layout places boxes: 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");@@ -158,6 +162,10 @@ describe("the provider fills Klein's graphs", () => {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");+ // Layout mode with no boxes yet: the prompt is the caption alone, and the helper stays (as the control's label says).+ const empty = (await prepare("flux3-klein-t2i", { prompt: "A cozy reading nook", extra: { layout: { ...POSTER, items: [] } } }, "t2i")).workflow;+ expect(empty["4"].inputs.text).toEqual(["11", 0]);+ expect(empty["11"].inputs.prompt).toBe("A cozy reading nook");// 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");@@ -217,7 +225,11 @@ describe("FLUX 3 Klein in the catalog, both engines", () => {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"]);+ // Klein Base: fal's plain routes, and their /lora twins for a run with LoRAs.+ expect(base.routes.map((r) => [r.endpoint, r.loraEndpoint])).toEqual([+ ["blackforestlabs/flux-3/klein/base/text-to-image", "blackforestlabs/flux-3/klein/base/text-to-image/lora"],+ ["blackforestlabs/flux-3/klein/base/edit-image", "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 });@@ -226,13 +238,16 @@ describe("FLUX 3 Klein in the catalog, both engines", () => {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", () => {+ it("sits in the Image studio's Best list on your GPU, beside Ideogram 4 and Qwen-Image 2.1; the Edit studio offers it outside its Best list", () => {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");+ const editable = filterModels(MODELS, { kind: "image", ops: EDIT_STUDIO.ops });+ expect(editable.map((m) => m.id)).toContain("oss-flux3-klein");+ const edit = studioBest(editable, "open", EDIT_STUDIO.defaultModels.open, EDIT_STUDIO.ops);+ expect(edit).toEqual(["oss-qwen-image-21", "oss-qwen-image-21-turbo", "oss-fibo2-dev", "oss-fibo2-edit-turbo"]);+ expect(getModel("oss-flux3-klein")!.bestOps).toEqual(["t2i"]);// 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);@@ -283,8 +298,11 @@ describe("fal's FLUX 3 Klein payloads", () => {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();+ // Klein Base: its plain routes without LoRAs, its /lora twins with them.+ for (const r of [t2i(base), edit(base)]) {+ expect(loraEndpointFor(r, [LORA])).toBe(`${r.endpoint}/lora`);+ expect(loraEndpointFor(r, [])).toBe(r.endpoint);+ }expect(buildPayload(t2i(base).map, { prompt: "photo of mayafz", loras: [LORA] }).loras).toEqual([{ path: LORA.url, scale: 0.8 }]);});@@ -334,8 +352,10 @@ describe("fal's FLUX 3 Klein payloads", () => {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 });+ // Klein Base: fal's planned per-image tiers on its plain routes ($0.027 at 1K … $0.108 at 4K), $0.035 per megapixel with LoRAs.+ expect(base.pricing).toMatchObject({ unit: "image", usd: 0.027, byResolution: { "1K": 0.027, "1.5K": 0.033, "2K": 0.042, "4K": 0.108 }, withLorasPerMegapixel: 0.035 });+ expect(estimateCost(base, { aspectRatio: "1:1", resolution: "1K" }, 1, "t2i")).toBe(0.027);+ expect(estimateCost(base, { aspectRatio: "1:1", resolution: "4K" }, 1, "t2i")).toBe(0.108);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.@@ -375,3 +395,111 @@ describe("FLUX 3 Klein as a Soul ID training target", () => {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");});});++describe("fal's FLUX 3 Klein Prompt helper, as on your GPU", () => {+ const cloud = getModel("flux-3-klein")!;+ const base = getModel("flux-3-klein-base")!;+ const route = (m: typeof cloud, op: Operation) => m.routes.find((r) => r.op === op) as ModelRoute & { map: NonNullable<ModelRoute["map"]> };+ const plan = (req: Partial<GenerationRequest>) => planGeneration({ feature: "image", prompt: "a fox", ...req } as GenerationRequest, getModel, getPreset);++ it("offers the same Options → Prompt helper on both engines, saying a layout with boxes goes as typed", () => {+ for (const m of [cloud, base, getModel("oss-flux3-klein")!, getModel("oss-flux3-klein-base")!]) {+ const helper = m.options.controls?.find((c) => c.param === "promptHelper");+ expect(helper, m.id).toMatchObject({ label: "Prompt helper", values: ["on", "off"], default: "on" });+ expect(helper!.labels!.on, m.id).toMatch(/full caption \(not with layout boxes\)$/);+ expect(helper!.labels!.off).toBe("Off · your words as typed");+ }+ });++ it("sends enable_prompt_expansion false when it's off, and leaves fal's default (on) when it's on", () => {+ for (const m of [cloud, base]) {+ for (const op of ["t2i", "edit"] as const) {+ const images = op === "edit" ? { images: ["https://x/a.png"] } : {};+ const off = plan({ modelId: m.id, op, params: { extra: { promptHelper: "off" } }, ...(op === "edit" && { inputs: { images: ["/api/files/a.png"] } }) });+ const sent = buildPayload(route(m, op).map, { prompt: off.prompt, ...off.params, ...images });+ expect(sent.enable_prompt_expansion, `${m.id} ${op}`).toBe(false);+ expect(sent.promptHelper).toBeUndefined();+ const on = buildPayload(route(m, op).map, { prompt: "a fox", extra: { promptHelper: "on" }, ...images });+ expect(on.enable_prompt_expansion).toBeUndefined();+ expect(on.promptHelper).toBeUndefined();+ }+ }+ });++ it("is overridden in Layout mode only once the draft places a box", () => {+ const empty = plan({ modelId: "flux-3-klein", prompt: "A cozy reading nook", params: { extra: { layout: { ...POSTER, items: [] }, promptHelper: "on" } } });+ const sent = buildPayload(route(cloud, "t2i").map, { prompt: empty.prompt, ...empty.params });+ expect(sent.prompt).toBe("A cozy reading nook");+ expect(sent.enable_prompt_expansion).toBeUndefined();+ expect(sent.bounding_boxes).toBeUndefined();+ const boxed = plan({ modelId: "flux-3-klein", prompt: "A cozy reading nook", params: { extra: { layout: POSTER, promptHelper: "on" } } });+ expect(buildPayload(route(cloud, "t2i").map, { prompt: boxed.prompt, ...boxed.params }).enable_prompt_expansion).toBe(false);+ // Other models' prompt expansion still goes off for any layout (their compiled prompt is the layout's, boxes or not).+ const flux3 = getModel("flux-3")!.routes.find((r) => r.op === "t2i")!;+ expect(buildPayload(flux3.map!, { prompt: "x", extra: { layout: { ...POSTER, items: [] } } }).enable_prompt_expansion).toBe(false);+ });+});++/** A PNG's first bytes, enough for its size to be read. */+function pngHeader(width: number, height: number): Buffer {+ const b = Buffer.alloc(33);+ Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]).copy(b, 0);+ b.writeUInt32BE(13, 8);+ b.write("IHDR", 12, "ascii");+ b.writeUInt32BE(width, 16);+ b.writeUInt32BE(height, 20);+ b[24] = 8;+ b[25] = 2;+ return b;+}++/** What a run handed its provider (the demo provider records the input it was given). */+async function handedOver(id: string): Promise<GenInput> {+ const end = Date.now() + 20_000;+ while (Date.now() < end) {+ const row = db().prepare("SELECT provider_input_json, status, error FROM generations WHERE id = ?").get(id) as { provider_input_json: string | null; status: string; error: string | null };+ if (row.provider_input_json) return JSON.parse(row.provider_input_json);+ if (row.status === "failed") throw new Error(row.error ?? "failed");+ await new Promise((r) => setTimeout(r, 50));+ }+ throw new Error(`${getGeneration(id)?.status}: nothing handed over`);+}++describe("fal's FLUX 3 Klein edit keeps image 1's shape, as your GPU's edit does", () => {+ const cloud = getModel("flux-3-klein")!;+ const edit = (m = cloud) => m.routes.find((r) => r.op === "edit") as ModelRoute & { map: NonNullable<ModelRoute["map"]> };+ const upload = (w: number, h: number) => saveFile({ data: pngHeader(w, h), contentType: "image/png", name: `p-${w}x${h}.png`, source: "upload" }).url;++ it("sends image 1's shape on the chosen tier's square as image_size, not the default 1:1", async () => {+ setSetting("demoMode", "auto");+ // Planned alone, the default aspect ratio would square a 16:9 photo.+ const p = planGeneration({ feature: "edit", modelId: "flux-3-klein", prompt: "make it night", inputs: { images: ["/api/files/a.png"] } } as GenerationRequest, getModel, getPreset);+ expect(buildPayload(edit().map, { prompt: p.prompt, ...p.params, images: ["https://x/a.png"] }).image_size).toEqual({ width: 1024, height: 1024 });+ // A run sizes it from the photo: 1K by default, the tier picked otherwise, on fal's 16 px grid.+ const wide = upload(4000, 2250);+ const [run] = createGenerations({ feature: "edit", modelId: "flux-3-klein", prompt: "make it night", inputs: { images: [wide] } });+ const sent = await handedOver(run.id);+ expect(sent.extra).toMatchObject({ image_size: { width: 1360, height: 768 } });+ expect(buildPayload(edit().map, { ...sent, images: ["https://x/a.png"] }).image_size).toEqual({ width: 1360, height: 768 });+ const [tall] = createGenerations({ feature: "edit", modelId: "flux-3-klein-base", prompt: "make it night", params: { resolution: "2K" }, inputs: { images: [upload(3000, 4000)] } });+ expect((await handedOver(tall.id)).extra).toMatchObject({ image_size: { width: 1776, height: 2368 } });+ // A size the request gives itself wins; text to image keeps the aspect ratio's.+ const [own] = createGenerations({ feature: "edit", modelId: "flux-3-klein", prompt: "x", params: { extra: { image_size: { width: 512, height: 512 } } }, inputs: { images: [wide] } });+ expect((await handedOver(own.id)).extra).toMatchObject({ image_size: { width: 512, height: 512 } });+ const [t2i] = createGenerations({ feature: "image", modelId: "flux-3-klein", prompt: "a fox", params: { aspectRatio: "16:9" } });+ expect((await handedOver(t2i.id)).extra?.image_size).toBeUndefined();+ // The tier's price stays; with LoRAs, the megapixels of the size sent.+ expect(estimateCost(cloud, { resolution: "1K", extra: { image_size: { width: 1360, height: 768 } } }, 1, "edit")).toBe(0.009);+ expect(estimateCost(cloud, { resolution: "1K", extra: { image_size: { width: 1360, height: 768 } } }, 1, "edit", true)).toBeCloseTo(0.012 * ((1360 * 768) / 1024 ** 2), 4);+ });++ it("offers Resolution but no Aspect ratio for the edit, as for text to image it offers both", () => {+ for (const m of [cloud, getModel("flux-3-klein-base")!]) {+ expect(edit(m).followsImage, m.id).toBe(true);+ expect(settingsShape(m, "edit", "image", true)).toMatchObject({ aspect: null, resolution: ["1K", "1.5K", "2K", "4K"] });+ expect(settingsShape(m, "t2i", "image", true).aspect).toContain("16:9");+ }+ // Your GPU's edit takes neither (it follows reference 1 at about 1 MP).+ expect(settingsShape(getModel("oss-flux3-klein")!, "edit", "image", true)).toMatchObject({ aspect: null, resolution: null });+ });+});diff --git a/tests/open-sota-studios.test.ts b/tests/open-sota-studios.test.tsindex 863af0c1..a6673152 100644--- a/tests/open-sota-studios.test.ts+++ b/tests/open-sota-studios.test.ts@@ -48,8 +48,9 @@ describe('"Best for this studio" on your GPU', () => {expect(t2i.indexOf("oss-fibo2-dev")).toBe(5);});+ // FLUX 3 Klein is offered in the Edit studio, but ranks only in the Image studio's list (ModelDef.bestOps).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-flux3-klein", "oss-fibo2-dev"]);+ expect(best(EDIT_STUDIO, "open")).toEqual(["oss-qwen-image-21", "oss-qwen-image-21-turbo", "oss-fibo2-dev", "oss-fibo2-edit-turbo"]);});it("Inpaint: Qwen-Image 2.1; Krea 2 Inpaint stays out while its add-on isn't on the owner's ComfyUI", () => {