ComfyUI integration

How LayerShop works with ComfyUI

For people who want to know what happens under the panel, and for ComfyUI users who want LayerShop to use the setup they already have.

Who does what

LayerShop does not run models itself and contains none. It is the editor: it knows about your document, your selection and your layers. ComfyUI is the engine: it loads model files and runs them on your graphics card. They talk over ComfyUI's ordinary local HTTP interface.

LayerShopPreparesCrops around the selection, makes the mask, picks a render size, writes the workflow.
ComfyUIRendersQueues the workflow, loads the model, samples, returns an image.
LayerShopPlacesFits the image to the selection and adds it as a masked layer with its settings.

Because the interface is ComfyUI's own, anything that speaks it works: the copy LayerShop installs, ComfyUI Desktop, the portable build, a git checkout, or a server on another machine reached through a tunnel.

The managed engine

If you let the wizard set things up, you get a private ComfyUI with its own Python in LayerShop's folder. You never have to open it.

  • It starts when needed. The first local generation starts ComfyUI hidden; the panel shows "Starting ComfyUI…" for about half a minute. Later generations reuse it.
  • It stops when you quit. Only a server LayerShop started is ever stopped, on quit or with Stop Server.
  • Its output is kept. Everything ComfyUI prints goes to comfyui.log in the settings folder, and a start that fails quotes the last lines.

The switch for this is Preferences › Generative AI › Local Server › Start ComfyUI when a local model needs it and it isn't running.

Using your own ComfyUI

If a ComfyUI already answers at the configured address, LayerShop uses it as it is. Nothing is started, and nothing is stopped later: it is yours.

  • Address. The portable build listens on http://127.0.0.1:8188, ComfyUI Desktop on http://127.0.0.1:8000. Set it on the Local Server page and press Connect.
  • Find Installation fills in the Python, folder and arguments from the ComfyUI that is running now, exactly as it was started, or from the installation ComfyUI Desktop recorded.
  • Browse… is for anything else: choose main.py and python.exe. Whichever half sits in a usual place next to the other (.venv, venv, python_embeded) is filled in for you.

ComfyUI Desktop and a server started by LayerShop want the same port. If Desktop will not start, press Stop Server in LayerShop first; it will then use Desktop's server.

Managing models

Preferences › Generative AI › Manage Models is one list of every model, cloud first and then local, in the order the panel shows them.

The Manage Models page of Preferences: a list of cloud and local models with the selected model's settings beside it, and Scan Server, Restore Defaults and Recommended Order buttons below
  • Scan Server adds a model for every model file your ComfyUI has. If you have a recommended model stored another way (bf16 where the list expects int8), the listed entry is pointed at your file and keeps its settings.
  • + Add Model adds a cloud model, a local one by architecture, or one of the models made for inpainting.
  • Restore Defaults puts back recommended models that are missing and changes nothing else.
  • The switches at the top leave cloud or local models out of the panel without removing them.
  • A local model whose file the server does not have is marked, so you know before you press Generate.

Built-in workflows

Each local model has an architecture, and the architecture decides the workflow LayerShop queues. The workflows follow ComfyUI's own templates and use only nodes that ship with ComfyUI, so there are no custom nodes to install and none to break on an update.

ArchitectureLoadsSampling
Qwen Image 2.1diffusion model, text encoder, its own VAEits own prompt node, KSampler
Z-Imagediffusion model, text encoder, VAEAuraFlow shift, KSampler
FLUX.2 (Klein, Dev)diffusion model, text encoder, VAEFlux2Scheduler, CFG guider
Krea 2diffusion model, text encoder, VAEKSampler
Ideogram 4diffusion model and unconditional model, text encoder, VAEAuraFlow shift, dual-model guider
Ming Imagediffusion model, text encoder, its own VAEFLUX shift by size, guider without CFG
HiDream O1one checkpointnoise scale, patch seam smoothing, KSampler
Ernie Imagediffusion model, text encoder, VAEKSampler
FLUX.1 Fill inpaintingdiffusion model, two text encoders, VAEInpaint Model Conditioning, FLUX guidance
Qwen Image + InstantX inpaintingdiffusion model, text encoder, VAE, ControlNetControlNet Inpainting Apply
Checkpoint (SD, SDXL)one checkpointKSampler
Custom workflowwhatever yours loadsyours

Per model you can set steps, CFG, sampler, scheduler, shift, guidance, seed, a negative prompt, an optional LoRA and the render size. The defaults are the values each model was tested at.

Custom workflows

For anything the built-in graphs do not cover, such as LoRA stacks, prompt enhancers or custom nodes, use your own workflow. In ComfyUI choose Workflow › Export (API), add a model of the architecture Custom workflow in LayerShop, and paste the JSON. Put these placeholders where the values go:

PlaceholderBecomes
%prompt% %negative%The prompt, and the model's negative prompt
%width% %height%The render size worked out from your selection
%seed% %steps% %cfg%The model's settings
%denoise%The panel's Strength (1 for text to image)
%image% %mask%File names of the picture and the mask, uploaded to ComfyUI's input folder

A field that is exactly a numeric placeholder, such as "%width%", becomes a number. The workflow needs a Save Image or Preview Image node. To fill selections with it, give it two Load Image nodes whose image is %image% and %mask%; the mask file is transparent where to paint, so the second node's MASK output is the mask.

workflow_api.json (excerpt)
"10": { "class_type": "LoadImage", "inputs": { "image": "%image%" } },
"11": { "class_type": "LoadImage", "inputs": { "image": "%mask%" } },
"6":  { "class_type": "CLIPTextEncode", "inputs": { "text": "%prompt%", "clip": ["4", 1] } },
"3":  { "class_type": "KSampler",
        "inputs": { "seed": "%seed%", "steps": "%steps%", "cfg": "%cfg%",
                    "denoise": "%denoise%", /* … */ } }

Cloud models

Cloud models are optional and sit in the same list. Each provider needs your own key, entered on the API Keys page.

ProviderModels offered
OpenAIGPT Image 2.5 Sunburst and Flare, GPT Image 2
GoogleNano Banana 2, Nano Banana Pro, Nano Banana 2.1
xAIGrok Imagine Image 2.0
MetaMuse Image
Black Forest LabsFLUX 3 Image, and older FLUX endpoints by id
  • Keys are stored in their own file, apart from the preferences, and a key is only ever sent to its own provider.
  • The Model ID is editable, so a newer model of the same API works without waiting for an update.
  • Where the provider reports or publishes prices, the panel shows an estimate before you generate and what the last image cost.

Scripting and agents

Everything in LayerShop is a command with an id and JSON parameters, and the AI features are no exception. The panel runs the same commands that are exposed over MCP, so an agent can drive the running editor.

fill a selection from a script
select.rect  { "x": 860, "y": 400, "width": 460, "height": 470, "ellipse": true, "feather": 12 }
ai.generate  { "prompt": "a red deer stag standing in the tall grass",
               "mode": "inpaint", "model": "flux-2-klein-9b" }
→ { "layer": 8, "mode": "inpaint", "renderSize": [1008, 992], "seed": 4242 }
CommandDoes
ai.generateCreate, fill (inpaint), restyle (img2img) or change by instruction (imgEdit), onto a new layer
ai.modelsThe models, what each can do and whether it can run now
ai.sourcesWhat a restyle or an edit can start from
ai.maskPaint the area to change instead of selecting it
ai.comfyModelsThe model files a ComfyUI server has
ai.server.statusThe local server's state

A generated layer carries its settings under generation, named the way ai.generate names its parameters, so they can be passed straight back. Two things agents cannot do: read API keys, and change how the local server is launched, since that names a program to run.

The demo pictures on this site were made exactly this way, by a script calling these commands. The source is on GitHub.