How to run FLUX Kontext in ComfyUI on Runpod
This guide covers running FLUX.1 Kontext in ComfyUI on Runpod. Kontext is Black Forest Labs' instruction-based image editing model: you give it an image and a sentence describing what to change, and it edits that one thing while leaving the rest of the frame alone.
By the end you'll have ComfyUI running on a pod with the Kontext dev workflow loaded, and you'll know which prompt patterns actually hold character and composition steady across edits. If you'd rather skip the setup entirely, Runpod also hosts Kontext dev as a public endpoint you can call today.
What is FLUX Kontext?
FLUX.1 Kontext is a multimodal editing model that takes text and image input together. Where a standard text-to-image model generates from scratch every run, Kontext reads the context of the image you hand it and applies a targeted change.
The open version, FLUX.1 Kontext [dev], is a 12-billion-parameter rectified flow transformer. Its defining property is consistency: facial features, object identity, and composition layout stay stable across multiple rounds of editing, which is what makes iterative work practical.
The family has three tiers:
- FLUX.1 Kontext [pro]: Commercial API version, tuned for fast iterative editing
- FLUX.1 Kontext [max]: Experimental version with stronger prompt adherence
- FLUX.1 Kontext [dev]: The 12B open-weights version covered in this guide
Kontext dev is released under Black Forest Labs' non-commercial license, with commercial licensing available directly from Black Forest Labs. Check the license terms before you build it into a product.
What is ComfyUI?
ComfyUI is an open-source, node-based interface for generative AI pipelines. You connect visual nodes, each one a model loader, a sampler, a conditioning step, or an output, into a workflow graph instead of writing code.
For Kontext, ComfyUI handles loading the diffusion model, the dual text encoders, and the VAE, then wires your input image and edit instruction into the sampler. ComfyUI ships a native Kontext dev workflow, so the graph is already built when you open it.
Why run FLUX Kontext on Runpod?
The fp8 checkpoint wants roughly 20 GB of VRAM, and full precision wants more than 30 GB. That's above what most desktop cards carry, and image editing is bursty work: you need the GPU for an hour of iteration, not for a month.
On Runpod you pick the card that matches the checkpoint, deploy a pre-built ComfyUI template, and pay per second while the pod runs. Nothing idles between sessions.
Runpod also runs Kontext dev as a public endpoint, priced at $0.025 per image edited. No pod, no model files, no workflow graph:
curl -X POST "https://api.runpod.ai/v2/black-forest-labs-flux-1-kontext-dev/runsync" \
-H "Authorization: Bearer $RUNPOD_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"input": {
"prompt": "Change the background to a rainy city street, keep the subject in the exact same position and pose",
"image": "https://example.com/portrait.png",
"num_inference_steps": 28,
"guidance": 2,
"size": "1024*1024"
}
}'
Use the endpoint when you want edits in an application. Use ComfyUI when you want to chain Kontext with LoRAs, masking, upscalers, or multi-pass graphs.
GPU requirements for FLUX Kontext
VRAM depends on which checkpoint you load, so treat these as starting points:
- 8–12 GB VRAM (RTX 3080, RTX 4000 Ada): GGUF quantizations (Q4/Q5), with quality trade-offs at higher resolutions
- 24 GB VRAM (RTX 4090, RTX 3090, A5000): flux1-dev-kontext_fp8_scaled comfortably, with headroom for the fp16 T5 encoder
- 40–48 GB VRAM (L40S, A6000): Full-precision weights, longer prompt encoders, batch editing
- 80 GB VRAM (A100 80GB, H100): Multi-pass graphs, high-resolution output, several workflows queued at once
The fp8 scaled checkpoint is the sensible default. It's roughly half the download of full precision and the quality gap on editing tasks is small.
Templates for running FLUX Kontext on Runpod
ComfyUI (official Runpod template) Runpod's first-party template. Ships with the current ComfyUI build on CUDA 12.8, plus ComfyUI-Manager, KJNodes, Civicomfy, and ComfyUI-RunpodDirect pre-installed. ComfyUI copies itself to your workspace on first boot. Wait for [ComfyUI-Manager] All startup tasks have been completed. in the pod logs before opening the interface. You add the Kontext model files yourself, which takes a few minutes and leaves you with a clean environment.
For other options, browse console.runpod.io/hub and search for ComfyUI. The Hub is a live catalog, so community templates are added and deprecated over time. Check the image version and last-updated date before deploying one.
Step 1: Create a Runpod account
Go to runpod.io and sign up with email, GitHub, or Google. Add credits or a payment method so you can deploy a GPU.
Step 2: Deploy a ComfyUI pod
- Open the Pods section of the console and select an RTX 4090 or equivalent 24 GB card.
- Click Change Template and select the official ComfyUI template.
- Set container disk to at least 40 GB. The Kontext checkpoint and T5 encoder together run to roughly 20 GB before you add anything else.
- Attach a network volume if you plan to come back to this setup. Model files persist on the volume instead of downloading again on every deploy.
- Click Deploy.
The pod itself comes up in under 30 seconds. First-boot setup for the template takes a few minutes longer.
Step 3: Download the Kontext model files
Open a terminal on the pod (the web terminal or JupyterLab, depending on your template) and pull the files into ComfyUI's model directories.
You need four files:
- Diffusion model: flux1-dev-kontext_fp8_scaled.safetensors → ComfyUI/models/diffusion_models/
- Text encoder 1: clip_l.safetensors → ComfyUI/models/text_encoders/
- Text encoder 2: t5xxl_fp16.safetensors or t5xxl_fp8_e4m3fn_scaled.safetensors → ComfyUI/models/text_encoders/
- VAE: ae.safetensors → ComfyUI/models/vae/
The fp8 T5 encoder saves several GB of VRAM against the fp16 version. On a 24 GB card, use fp8.
If your template includes Civicomfy or ComfyUI-RunpodDirect, you can pull these through the UI instead of the terminal.
Step 4: Open ComfyUI and load the workflow
Once the pod shows a running state, click Connect, then open port 8188. ComfyUI opens in a new browser tab.
Load the Kontext dev workflow from the Template Library, or drag in the workflow file from ComfyUI's Flux Kontext dev documentation. Then check four nodes before you run anything:
- Load Diffusion Model points at flux1-dev-kontext_fp8_scaled.safetensors
- DualCLIPLoader has both clip_l and your chosen T5 file loaded
- Load VAE points at ae.safetensors
- Load Image has your input image
Run the graph once on the default prompt before changing anything. If it completes, your file paths are right and you can start iterating.
Step 5: Write edit instructions that hold
Kontext responds to instructions, not keyword soup. The prompt patterns below come from Black Forest Labs' and ComfyUI's published guidance, and they're the difference between a clean edit and a regenerated image.
Name what stays, not just what changes. The most common failure is Kontext redrawing the whole subject when you only wanted one attribute changed.
- Weak: Transform the person into a Viking
- Strong: Change the clothes to a Viking warrior outfit while preserving facial features
Pin position explicitly on background swaps.
- Weak: Put him on a beach
- Strong: Change the background to a beach while keeping the person in the exact same position, scale, and pose
Describe styles concretely.
- Weak: Make it a sketch
- Strong: Convert to pencil sketch with natural graphite lines, cross-hatching, and visible paper texture
Quote text you want replaced. Replace 'joy' with 'BFL', maintain the same font style.
Use nouns, not pronouns. "The woman with short black hair" beats "she" every time.
Split complex edits into passes. Change the background, run it, then change the outfit on the output. Two clean edits beat one prompt trying to do both.
Verb choice matters more than it looks: "change" and "replace" produce targeted edits, "transform" invites the model to redraw.
Pro tips
Chain edits from the output node. ComfyUI's Load Image (from output) node pulls from your output folder, so each round of editing starts from the last result without downloading and re-uploading.
Watch guidance, not steps. Kontext defaults to a guidance value around 2, which is low compared to text-to-image Flux workflows. Raising it hard tends to produce over-baked edits rather than better adherence. Adjust the prompt first.
Attach a network volume. Pod storage is ephemeral. A network volume keeps the Kontext checkpoint, your LoRAs, and your saved workflows across sessions.
Export your workflow JSON. When a graph is dialed in, export it from ComfyUI's menu. Re-importing restores the exact configuration on a fresh pod.
Stop your pod when you're done. Runpod bills by the second while a pod runs. An idle 4090 overnight is money for nothing.
Wrapping up
Kontext made instruction-based editing something you can run yourself rather than call as a hosted API, and ComfyUI is where it gets interesting: masking, LoRAs, upscalers, and multi-pass graphs around the edit itself. Start on the public endpoint if you want a result in the next two minutes, then move to a pod when you need the graph.
Ready to try it? Test Kontext dev in the playground, or deploy the ComfyUI template for full workflow control.
FAQ
What's the difference between Kontext dev, pro, and max?
Dev is the open-weights 12B version you can run yourself, covered in this guide. Pro is the commercial API version tuned for fast iterative editing. Max is an experimental version with stronger prompt adherence. Pro and max are API-only, available in ComfyUI through partner nodes.
What GPU do I need to run FLUX Kontext on Runpod?
A 24 GB card such as the RTX 4090 handles the fp8 scaled checkpoint comfortably. Full-precision weights want more than 30 GB, so an L40S, A6000, or A100 is the better fit there. GGUF quantizations bring it down to 8–12 GB cards with some quality cost.
Can I use Kontext commercially?
FLUX.1 Kontext [dev] is released under a non-commercial license. Black Forest Labs offers commercial licensing separately. Review their current terms before shipping anything built on the dev weights.
Why does Kontext change my subject's face when I only asked for a background swap?
The prompt is under-specified. Add an explicit preservation clause: "keep the person in the exact same position, scale, and pose" and "while maintaining the same facial features." Kontext holds identity well, but it needs to be told what's off limits.
Can I run Kontext as an API instead of a UI?
Yes, two ways. Runpod's public endpoint gives you Kontext dev as a REST API with no deployment at $0.025 per image. Or containerize your ComfyUI workflow and deploy it to Runpod Serverless, which scales to zero between requests and bills per second of compute.
