PotionUI Docs v0.3.0

Author a preset

A preset is a folder of YAML files that gives one model a form and a pipeline. This guide takes you from an empty folder to a Z-Image preset that generates, with the same scaffold, lint and render tools the shipped presets are checked with.

GuideWritten for v0.3.0
On this page

What you will build#

A small but complete text-to-image preset for Z-Image: a preset.yml, one mode called txt2img, a form with three tabs (Generation, LoRA, Advanced) and the eight-step pipeline every shipped native image preset uses. It follows the preset tutorial, built the way the shipped Z-Image preset is, only smaller.

You need a PotionUI source checkout with its Python environment, because the scripts below run from the repository root. To generate at the end you also need the three Z-Image files (diffusion model, text encoder and VAE) in your models folders, and an administrator account. Nothing before the last step needs a GPU or a running server.

FileWhat it holds
preset.ymlThe manifest: id, name, category, engine and the list of modes. The only required file.
modes/<mode>/pipeline.ymlThe ordered list of pipes (processing steps) that runs when someone presses Generate in that mode.
modes/<mode>/form.ymlThe form the mode shows, usually a set of tabs.
modes/<mode>/tabs/*.ymlThe fields of each tab.
description.mdOptional long description in Markdown.
public/Optional cover and example images. The only folder of a preset served over HTTP.
files/form/*.ymlOptional option lists the form reads, such as a list of resolutions.

Where presets live#

PotionUI scans two roots the same way:

  • content/presets/local/<Model>/<variant>/ for presets that are yours. This folder is ignored by git, so start here.
  • content/presets/marketplace/<Model>/<variant>/ for the presets PotionUI ships.

A plugin can ship presets too, from a folder named in its manifest; see Build a plugin. Nothing reads meaning from the folder names: the engine comes from the engine: key in preset.yml, and a preset keeps its id wherever its folder sits, so moving it from local to marketplace does not make it a different preset. Fragments shared by many presets (resolution lists, common tabs) live once under content/presets/_shared/.

From an empty folder to a first picture#

  1. Scaffold the folder

    From the repository root, create the preset under your local root. --family z_image looks up the real Z-Image loader and generator pipes and writes the standard chain wired to them, plus a form already using the right model types and the generator's own defaults.

    SHscaffold
    python scripts/preset_new.py MyZImage/standard --family z_image --root content/presets/local
    What you will see

    A line reading Scaffolded preset '<id>' at content/presets/local/MyZImage/standard, the six files it created (preset.yml, and under modes/txt2img/ the pipeline, the form and three tab files), then the next steps: lint and render.

    Without --family you get a bare skeleton with a single gallery pipe, which is what you start from for a model family that has no pipes yet. Other options: --modes (comma-separated mode names, default txt2img), --category (image, video, audio, 3d or utility), --engine (default native), --name and --force to overwrite.

  2. Read the manifest

    The scaffold mints a fresh id and fills in the required keys:

    YAMLpreset.yml
    schema: 1
    id: "<a new ULID>"
    name: "MyZImage standard"
    category: "image"
    version: "1.0.0"
    engine: "native"
    tags: []
    
    vars:
      default_steps: 30
    
    formulas:
      groups: {}
    
    modes:
      - txt2img

    Change name to what users should see in the preset picker. Never change id after people have used the preset: History and assignments refer to it. Unknown top-level keys are rejected. Every key, including media, speed_profiles and llm, is listed in the preset.yml reference.

  3. Read the pipeline

    modes/txt2img/pipeline.yml lists the pipes in order. Each entry names a pipe, wires inputs from earlier pipes and passes configuration, usually read from the form:

    YAMLmodes/txt2img/pipeline.yml
    pipeline:
      - name: "model_loader/z_image"
        enabled: true
        configuration:
          diffusion_model: { file_path: "{{ form.diffusion_model }}", name: "{{ form.diffusion_model }}" }
          text_encoder: { file_path: "{{ form.text_encoder }}", name: "{{ form.text_encoder }}" }
          vae: { file_path: "{{ form.vae }}", name: "{{ form.vae }}" }
          loras:
            "@loop":
              items: "{{ form.loras }}"
              template:
                file_path: "{{ item.model }}"
                weight: "{{ item.strength }}"
    
      - name: "prompt_encoder"
        input:
        - ["text_encoder", "model_loader/z_image", "text_encoder"]
        enabled: true
        configuration:
          p_prompt:
            input: "{{ generation.prompts.first.positive }}"
            output: "{{ generation.prompts.first.positive }}"
          n_prompt:
            input: "{{ generation.prompts.first.negative }}"
            output: "{{ generation.prompts.first.negative }}"
          pairs: "{{ generation.prompts.pairs }}"
          quantity: "{{ form.quantity }}"
          guidance_scale: "{{ form.guidance }}"
    
      - name: "seed_generator"
        enabled: true
        configuration:
          seed: "{{ form.seed }}"
          quantity: "{{ form.quantity }}"
    
      - name: "dynamic_prompts_renderer"
        id: "dynamic_prompts_renderer"
        enabled: true
        configuration:
          pairs: "{{ generation.prompts.pairs }}"
          quantity: "{{ form.quantity }}"
    
      - name: "from_iotype"
        id: "from_iotype"
        enabled: true
        input:
          - ["seed", "seed_generator", "seed"]
        configuration:
          from: "seed"
    
      - name: "param_emitter"
        id: "param_emitter"
        enabled: true
        input:
          - ["seed", "from_iotype", "seed"]
        configuration:
          quantity: "{{ form.quantity }}"
          parameters:
            - ["model", "{{ form.diffusion_model }}"]
            - ["model", "{{ form.text_encoder }}"]
            - ["model", "{{ form.vae }}"]
            - ["positive_prompt", "{{ generation.prompts.positives }}"]
            - ["negative_prompt", "{{ generation.prompts.negatives }}"]
            - ["guidance", "{{ form.guidance }}"]
            - ["steps", "{{ form.steps }}"]
            - ["sampler", "{{ form.sampler }}"]
            - ["resolution", "{{ form.resolution }}"]
    
      - name: "generator/z_image"
        input:
          - ["model", "model_loader/z_image", "model"]
          - ["conditioning", "prompt_encoder", "conditioning"]
          - ["seed", "seed_generator", "seed"]
        enabled: true
        configuration:
          steps: "{{ form.steps }}"
          guidance: "{{ form.guidance }}"
          sampler: "{{ form.sampler }}"
          resolution: "{{ form.resolution }}"
          quantity: "{{ form.quantity }}"
    
      - name: "gallery"
        input:
          - ["image", "generator/z_image", "image"]
          - ["seed", "seed_generator", "seed"]
        enabled: true

    What each step does:

    • model_loader/z_image loads the three model files the form picks, plus any LoRAs, and outputs model and text_encoder.
    • prompt_encoder turns the prompt into conditioning. It needs the loader's text_encoder, which is the one wiring the chain does not make obvious.
    • seed_generator draws the seeds from the form's seed and quantity.
    • dynamic_prompts_renderer, from_iotype and param_emitter record the expanded prompts, the seed and the settings, so History can show exactly what made each picture. Copy them as they are.
    • generator/z_image samples the picture, and gallery saves it.

    An input: line reads [input name, source pipe, source output]. The source pipe is found by its id when it has one, otherwise by its name. Values in {{ }} are templates: form.* is the submitted form, generation.prompts.* the expanded prompts. The Pipes reference lists every pipe's inputs, outputs and configuration keys, and Preset context lists everything a template can read.

    Note

    The generator's key is guidance, not cfg. The scaffold names the form field after the pipe's own key; a form field and a pipe key may have different names, but the pipeline must then map one to the other.

  4. Shape the form

    modes/txt2img/form.yml is the mode's form: a tabs container whose tab bodies come from separate files.

    YAMLmodes/txt2img/form.yml
    name: "custom"
    short_description: "Generate an image from a text prompt."
    fields:
      - type: "tabs"
        children:
          - type: "tab"
            label: "Generation"
            children: "{{ paths.preset }}/modes/txt2img/tabs/generation.yml"
          - type: "tab"
            label: "LoRA"
            children: "{{ paths.preset }}/modes/txt2img/tabs/lora.yml"
          - type: "tab"
            label: "Advanced"
            audience: "advanced"
            children: "{{ paths.preset }}/modes/txt2img/tabs/advanced.yml"

    short_description is the line the Mode menu shows under the mode's name; keep it to one plain sentence. audience: "advanced" hides the whole tab until the user switches the form to advanced. The Generation tab holds the seed and quantity row, the resolution and the three model pickers:

    YAMLmodes/txt2img/tabs/generation.yml (excerpt)
    fields:
      - type: "row"
        children:
          - name: "seed"
            type: "seed"
            label: "Seed"
            default: -1
            width: "3/5"
          - name: "quantity"
            type: "stepper"
            label: "Quantity"
            default: 1
            configuration: {min: 1, max: 10, step: 1}
            width: "2/5"
    
      - name: "resolution"
        type: "resolution"
        label: "Resolution"
        configuration:
          files:
            - { path: "{{ paths._shared }}/resolutions/sdxl.yml", group: "Standard" }
        default: "1024x1024"
    
      - name: "vae"
        type: "model"
        label: "Vae"
        required: true
        configuration:
          model_type: "vae"
          placeholder: "Select a z_image vae..."

    The scaffold writes labels and placeholders from the slot names, so tidy them now, for example label: "VAE" and placeholder: "Select the Z-Image VAE...". Every field name must match the form.<name> the pipeline reads. A model field's model_type decides which folder its picker lists; a wrong value lists the wrong files.

  5. Lint it

    SHlint
    python scripts/preset_lint.py content/presets/local/MyZImage/standard
    What you will see

    Errors and warnings by file. The command exits with 0 when there are no errors; warnings do not fail it. No errors means the manifest is valid, every mode has its folder and every form.<name> in the pipeline resolves against the form.

  6. Render it

    Rendering runs the real template code with sample form data built from your defaults, and prints every pipe's configuration with its type. No server, model or GPU is involved.

    SHrender
    python scripts/preset_render.py content/presets/local/MyZImage/standard txt2img

    Check that steps came out as a number and loras as a list. Pass --form values.yml to render with your own form values instead of the defaults.

  7. Load it in the app and generate

    The server reads the preset folders when it starts, so restart the backend after adding a new preset folder. Then open Administration, Presets, find the preset in the catalog and choose Install preset. Give people access on its Access tab: only installed presets can be made available to users and groups.

    Administration, Presets with the Krea-2 preset open on its Form tab and the preset catalog on the left. A preset in Administration, Presets
    An installed preset with its Overview, Access, Configuration, Form and Requirements tabs.
    What you will see

    The preset appears in the Preset menu on the Generate page for the people you gave access, with the mode Text to Image. Pick the three model files, write a prompt and press Generate.

Forms, tabs and fields#

A mode's form.yml is its default form. A tab file holds its fields under a fields: key. Paths in children: may use {{ paths.preset }} (this preset's folder) or {{ paths._shared }} (the shared tree). Two modes that need the same tab keep one copy and point to it; do not copy files between presets or modes.

  • Field types. Text (string, textbox), numbers (number, integer, slider, stepper, seed, resolution), choices (select, segmented, checkbox_group, tags), models (model, lora_picker, sampler, schedule), media (image, video, audio, media, file) and layout (tabs, tab, row, group, accordion, section). Plugins can add more. The full, current list is in Preset context.
  • Defaults are typed. default: 30 on a slider, not "30"; default: true on a checkbox, not "true". A default may not contain a template. Lint reports a wrong type as an error.
  • Reactions. A form cannot read form data with templates. To show, hide or change a field based on another, use reactions: with when: conditions.
  • Variants. A mode can offer more than one form under modes/<mode>/variants/<name>/form.yml; the form's name: is what a request selects.
  • Shared fragments with parameters. A fragment included as children: {file: ..., vars: {...}} takes values marked {{ vars.<name> }} inside it.

Pipelines and templating#

  • Exact expressions keep their type. A value that is exactly one {{ expression }}, such as "{{ form.steps }}", becomes the real value: a number, a list or a boolean. Anything with surrounding text, like "steps: {{ form.steps }}", becomes a string. Feed pipes exact expressions.
  • Missing values are errors. Templates run strictly: a reference to a field the form does not have stops the build with an error naming the preset, mode and pipe. The only way to accept a missing value is a default, for example "{{ form.steps | default(30) }}".
  • Switching a pipe on and off. enabled: is true, false or one exact expression that gives a boolean. Leaving it out means enabled. A disabled pipe's configuration is never rendered, so it may reference fields that only exist when the feature is on.
  • Repeated slots. "@loop" with items: and template: expands one template per item, as the LoRA list above does. The active_loras filter drops LoRAs set to zero strength.
  • What templates can read. In pipeline.yml: form, request (the mode and form variant), generation (prompts and the resolved speed profile), preset (its id, name and vars), runtime and paths.preset. Form files can use only paths.preset and paths._shared. Details in Preset context.

Families other than Z-Image use the same chain with their own loader and generator, for example model_loader/flux with generator/flux, or checkpoint_loader/sdxl with generator/sdxl. Pass the family to --family and the scaffold finds the pair for you. To add a step of your own to a pipeline, see Write a pipe.

Modes#

A mode is one thing the preset does: text to image, edit, image to video. To add one, list it under modes: in preset.yml and create modes/<mode>/ with its own pipeline.yml and form.yml. A listed mode without a folder is a lint error; a folder that is not listed is a warning.

  • Name and icon. Users never see the raw key. Well-known keys get a standard name (txt2img is Text to Image, img2video is Image to Video). Set mode_label: and mode_icon: in the mode's form.yml only when the standard name would be wrong for your preset.
  • No prompt. A mode that needs no prompt, such as an upscaler, is listed in vars.promptless_modes.
  • Elixirs. Each mode can be used as a step of an elixir. Its inputs and outputs are worked out from its image and video fields and its gallery pipes; modes/<mode>/elixir.yml overrides that, and lint reports why a mode is not offered.

Model requirements#

A preset never downloads models by itself. It says what it needs in three places, and each does something different:

WhereWhat it does
recommendations on a model fieldLists downloadable models the picker offers when it is empty, by direct link or through a provider plugin with a ref. Entries can carry size_bytes, sha256, precision and GPU rules, which the Install modes recipe uses to pick and check files. python scripts/recommendations_fill.py <preset> fills those keys for Hugging Face entries.
requirements: in preset.ymlChecked live on this instance and shown on the preset's Requirements tab in Administration, Presets. Core types are binary, python_package, model (by tag, hash, file name, or in a mode's form by field), vram_min_gb and platform. A backend that fails a check is not chosen to run the preset.
requires: in preset.ymlmin_vram_gb, recommended_vram_gb and min_ram_gb, shown as a badge in the preset picker before anyone downloads anything. Pure guidance, never checked.
Note

Take requires: numbers from the measured table on Hardware requirements. Where a family is not measured, leave the key out: a wrong minimum either turns away a card that would work or promises one that will not.

Test it#

  • python scripts/preset_lint.py with no path lints every preset in both roots. --render also renders each mode's default form and reports template errors that only show when a template runs.
  • A tests.yml next to preset.yml describes real generations with checks on the result (at least one output, the expected resolution, not black). python scripts/preset_test_suite.py runs them against a running instance and writes an HTML gallery; see its --help.
  • Administrators can run the same lint over HTTP with GET /api/developer/presets/lint.

Common mistakes#

What happensWhyFix
Generation fails with an undefined value error naming a pipeThe pipeline reads form.x but the form has no field x and no default.Add the field, give it a default:, or write | default(...) in the template. Reproduce with preset_render.py.
A pipe ignores a settingA guessed configuration key, such as cfg where the pipe expects guidance. Unknown keys are passed through without an error.Copy keys from the Pipes reference.
The build stops: a pipe is not foundA made-up pipe name, or a family pipe written by hand.Scaffold with --family, or copy the name from the Pipes reference.
The generator has no conditioningprompt_encoder is missing or not wired to the loader's text_encoder.Keep the standard chain as scaffolded.
A model picker lists the wrong filesWrong model_type.Use a value from the model_type table in Preset context.
A pipe never runsenabled: is a string with text around the expression, so it never becomes true.Use true, false or one exact {{ expression }}.
Load fails with an unknown keyA removed key such as an inline description: or supported_backends: in preset.yml.Move prose to description.md; use the single engine: key. preset_lint.py --fix migrates old manifests.
The new preset is not in the catalogThe server has not read the folder yet.Restart the backend, then Install preset in Administration, Presets.

Preset tutorial ↗Preset authoring guide ↗