--- name: image-lab license: Apache-2.0 description: "Turn one image prompt into several strong alternatives at once — the Model Advisor spreads them across the 2-3 image models that best fit the brief, shows the estimated total before any spend, generates them in parallel, then builds a shareable gallery you pick the winner from. Use when someone wants several options of one image prompt, wants to try more than one image model without pricing anxiety, wants a cost estimate before generating an image, or wants to compare specific models on a brief. Triggers include \"generate that with Image Lab\", \"8 options of this with Image Lab\", \"run Image Lab on this prompt\", \"with Image Lab, compare Nano Banana Pro and GPT Image 2\". It needs to be named — a bare \"generate an image\" belongs to native image generation, not here. This skill only turns one finished prompt into several alternatives. For controlled variations, creative directions, a reference photo, a workbook of options, or when the user says \"Image Lab 2\", use the image-lab-2 skill instead." --- # Image Lab **One prompt. Several strong possibilities. Pick the image you want.** See the price. Approve once. Generate in parallel. Image Lab helps you **pick an image, not pick a model**. It does not write prompts and is not tied to any prompt source — it takes a finished prompt, and its Model Advisor spreads your requested number of alternatives across the models that best fit the brief. Pair it with `ai-image-prompts-skill`, any other prompt skill, or use your own prompt. ## The five user-facing steps ``` PLAN -> QUOTE -> APPROVE -> GENERATE -> RESULTS ``` - **PLAN** — you classify the prompt to one creative intent; `image.py` deterministically scores the models and produces an **allocation** (which models, how many alternatives each, at what size). - **QUOTE** — the estimated total (printed by the same `resolve` call). No server-side quote exists. - **APPROVE** — one `AskUserQuestion`: Generate / Adjust / Stop. Nothing is spent before this. **This is the only gate — the wallet boundary.** - **GENERATE** — the whole allocation submitted together as independent gateway tasks. `run` works in the **background**; you poll its progress file and post a short "N/total done" update every ~30–60s so the user is never staring at nothing. - **RESULTS** — every image, the actual cost, **and** a shareable exploration page built automatically. Then ask: pick a favourite, adjust the prompt and generate another round, or stop. Adjusting loops back to PLAN — it is a brand-new spend, so it goes through its own QUOTE → APPROVE, never skipping the gate just because "it's the same session." The exploration page (step 7) is a self-contained static folder of the brief + every alternative + the pick. It spends nothing, so it is always built — never ask "do you want a page?". `pipelines/generate.yaml` is the stage manifest. Follow it. ## Input contract Only the **prompt** is required. Everything else is inferred or optional. | Field | Source | |---|---| | prompt text | conversation context (any skill or the user), or a local file path | | creative intent | **you** classify it (see step 2) | | model allocation | `image.py` decides deterministically; the user may override by name | | size | `image.py` picks a valid size per model from the intent + each model's minimum | | alternatives count | **4** by default; **1 / 2 / 4 / 8** supported. 1 → A only; 2 / 4 → A + B (two models); **8 → A + B + C (three models, a "deep exploration" widen)**. `count` is a number of images, never "top-N models". | | reference image | out of scope in v0.1 — if the prompt needs one, say so and stop | Do not read another skill's files. Do not rewrite the prompt. ### Mapping natural language to `count` | The user says | `count` | |---|---| | "just one", "a single image" | 1 | | "a couple", "compare a few", "two options" | 2 | | *(nothing about count)*, "some options", "explore this" | **4** | | "lots", "as many as makes sense", "deep dive", "make 8" | 8 | Never invent other numbers. If they ask for 5, round to 4; for 6+, use 8. ## Workflow ### 1. capture Take the final prompt from context (the last prompt an upstream skill produced, or what the user pasted / a file they named). No prompt → ask for one. If the prompt clearly needs a reference/input image, say Image Lab v0.1 is text-to-image only and stop. ### 2. classify the intent Pick the single best match from this list (from `references/generation-policy.md`): `launch / announcement image` · `profile / avatar` · `social post` · `blog hero / article cover` · `poster / flyer` · `infographic / diagram` · `illustration / concept art` · `3D render / isometric illustration` · `product / e-commerce shot` · `generic` Use `generic` only if nothing else fits. This is your one judgement call — the user can correct it ("no, treat it as a poster"). ### 3. plan + quote (PLAN → QUOTE) Run (one call does both): ``` python scripts/image.py resolve --intent "" --count --out ./out --explain ``` Add `--models "[,]"` **only** if the user named specific models ("use GPT Image 2", "compare Nano Banana Pro and Seedream"). The Advisor never silently replaces a model the user asked for. `--out` names the **session** (`./out` unless the user asked for somewhere else) — pass the same value you'll give `run` at step 5; resolve only ever reads it (to preview the round number and cumulative spend), never writes there. At `count 8` the allocation normally spans **three** models (A ×3 + B ×3 + C ×2) — the "deep exploration" widen. That is expected, not a bug; `count` is still a number of images. It checks readiness, resolves the token, and returns `plan` with: - `allocation` — a list of `{ model, label, size, usd_per_image, n, subtotal_usd }` - `alloc_arg` — the exact string to hand to `run` at step 5 (copy it verbatim) - `fingerprint` — a sha256 of `alloc_arg`; the exact value `run --confirm` must be given at step 5. Not a bare yes/no flag — it binds the approval to this specific allocation, so `run` refuses if the `--alloc` it's given doesn't match what `--confirm` was issued for (e.g. a stale value from an earlier turn, or a plan that changed after Adjust). Also note: the fingerprint binds the allocation, not the prompt — a prompt-only edit still needs a fresh `resolve` call (see step 8). - `estimated_usd` — the total; `sufficient` — whether the balance covers it - `out_dir` — this round's actual folder (`/round-N`, auto-numbered) — a preview only, nothing exists there yet - `round` / `session_cumulative_usd` — which round this would be and how much the session has spent so far (0 / round 1 the first time) - `why` — one line explaining the model choice - the full score table on stderr (from `--explain`) If it errors (loomloom not ready, no token), relay the one fix and stop. If `sufficient` is false, say the balance is short and stop — do not reach APPROVE. Present the PLAN as the script prints it — each model, its count, its size, its subtotal — then the `why` line, the output path, and the estimated total. From round 2 onward it also prints a one-line reminder ("this is round N of this session — $X spent across it so far"); include it, it helps the user decide whether to keep iterating. The estimate is a pre-flight guess of the gateway's own `cost`; the actual can be lower (e.g. `gemini-3.1-flash-image` currently bills $0 under a launch preview but is quoted conservatively so the gate stays honest). RESULTS shows the real charge. ### 4. approve (APPROVE) Call `AskUserQuestion` with exactly: - **Generate ** — proceed - **Adjust** — change intent / models / count, then re-run step 3 - **Stop** — halt; nothing spent Because one request can spend across multiple models, the question text must name the actual mix and the total (e.g. "Generate 4 — Nano Banana Pro ×2 + GPT Image 2 ×2, ~$0.11?"). ### 5. generate (GENERATE) `--out` names the **session** (default `./out`), not this round's own folder — `run` auto-detects the round number from `/session.json` and writes this round's images/record to `/round-N/`, never overwriting an earlier round. Run it **in the background** with a progress file: ``` python scripts/image.py run --alloc "" \ --prompt "" --intent "" --out ./out \ --progress-file "/progress.json" \ --confirm "" ``` `` is `resolve`'s own preview of this round's folder (`./out/round-1`, `./out/round-2`, …) — round-scoped, not the session root, so a new round's progress file is never mistaken for an earlier round's stale `done` state. While it runs, every ~30–60s read `/progress.json` and post a compact update — do not leave the user with no signal for minutes: ``` GENERATING 8 · 3 models GPT Image 2 A ✓115s B ✓114s C ⋯ D … Nano Banana Pro E ✓35s F ⋯ G … Nano Banana 2 H … 4/8 done · $0.37 so far ``` `progress.json` fields: `phase` (`submitted` → `generating` → `done`), `done`, `failed`, `total`, `actual_usd_so_far`, and `branches[]` (`label`, `model_label`, `status`, `seconds`, `cost_usd`). When `phase` is `done`, read the run record from stdout and go to RESULTS. The record's own `out_dir` field names this round's actual folder (`./out/round-1` the first time, `./out/round-2` after one Adjust-the-prompt loop, etc.) — use that value rather than assuming `./out`; each branch downloads to `/variant-a.png` … **If it exits with `status: model_unavailable`** (exit code 3): the first model was rejected by the gateway. It prints a `suggested_model` / `suggested_size`. Show the user: ``` MODEL UNAVAILABLE could not be generated right now. Suggested replacement: (~$/image) [ Use replacement ] [ Stop ] ``` On "Use replacement" → re-run step 3 with `--models ""` (plus any still-good model), then step 4. This is a *changed plan*, so a fresh approval is correct. ### 6. results (RESULTS) `run` prints the run record (JSON) to stdout and writes it to `/run.json` (see step 5 — `` is this round's own folder, not necessarily `./out` itself). `alternatives[]` carries each branch's `label`, `model_label`, `seconds` (generation time), `cost_usd`, and `actual_size`; `file` is a basename (the image is `/`). The record also carries `round` and `session_cumulative_usd` — from round 2 onward, `run` prints a one-line reminder to stderr ("this is round N of this session — $X spent across it so far"); relay it, it is not an error. - **Send each image as its own `SendUserFile` call** with a caption that names its label and model — e.g. `A · Nano Banana Pro`, `C · GPT Image 2` — so the user can tell which is which. The files are `/variant-a.png` … - Present a RESULTS table with columns **label · model · time · cost · size** (from `alternatives[]`), then `Actual total: $X.XXXX (estimated ~$Y.YYYY)`. - If a branch failed or is incomplete, name it plainly — no retry in v0.1; the user still picks from what succeeded. - Then **build/update the case-study page (step 7)** and hand the user the link. - Finally, ask what's next (step 8): pick a favourite, adjust the prompt and do another round, or stop. Do not ask before building the page — the page costs nothing and picking is ordinary conversation, not a gate. ### 7. case-study page (part of RESULTS — always built, no gate) One page per **session**, at a **fixed address that never moves**, no matter how many rounds pile up — `//index.html`, where `` is set once from the *first* round's `--title` and never recalculated afterward, even if a later round's title changes. Build/rebuild it every round: ``` python scripts/build-exploration-page.py --session ./out --inline \ --title "<3-5 word title for THIS round>" --subject "" \ --invocation "" \ [--selected