All posts
ComfyUIRunPodAI imagesserverlessPython

I Generated 100 AI Images At Once

Renato Dinis

ComfyUI is a great prototyping tool. It's terrible for scale. Clicking through a UI to generate one image at a time doesn't work when you need hundreds. This is how to fix that.

The problem with ComfyUI at scale

The UI is manual by design. No API, no parallelism, no way to trigger it from code without hacks. If you want to run a batch job, you're sitting there clicking. RunPod Serverless solves this by wrapping your workflow in a Docker container and exposing it as an API. The pod sits cold at zero cost when idle. An API call wakes it up, runs the job, and the pod sleeps again when done.

The pipeline

flowchart LR
  CUI[ComfyUI\nworkflow JSON] --> TOOL[comfy.getrunpod.io\nconvert tool]
  TOOL --> REPO[GitHub repo\nDockerfile + API]
  REPO --> RP[RunPod\nServerless endpoint]
  PY[Python script\nThreadPoolExecutor] -->|parallel requests| RP
  RP -->|images| OUT[Saved output]
  1. Export your ComfyUI workflow as JSON
  2. Convert it to a GitHub repository using the ComfyUI-to-API tool
  3. Deploy the repo as a serverless endpoint on RunPod
  4. Hit the API from Python to trigger parallel generations

Step 1: Export the workflow

In ComfyUI, right-click in the canvas and choose Export (not Export API). Name the file whatever you want. This produces a plain JSON file with the full workflow graph.

Step 2: Convert to a RunPod repository

Go to comfy.getrunpod.io and upload the JSON. The tool scans it for custom nodes and model dependencies, then generates a GitHub repository with:

  • A Dockerfile that installs ComfyUI plus your custom nodes
  • A README.md
  • An example_request.json with a sample payload

Important: This tool is still in beta. Check the Dockerfile manually. If your model wasn't found automatically, copy the download URL and add it to the models section yourself. The tool is wrong often enough that a manual review is worth the two minutes.

Step 3: Deploy the endpoint

From the tool, click Deploy. It redirects you to RunPod to configure the endpoint:

  • Worker type: GPU (CPU won't cut it for image generation)
  • GPU memory: 24 GB works for SD 1.5 and similar models
  • No credentials needed if your model is a public download

Click Deploy. Depending on how large your Dockerfile is, the build can take several minutes.

Step 4: Test with the example payload

Back in RunPod, go to your endpoint and paste the contents of example_request.json as the request body. Click Run.

Expect two things on the first run:

  1. A cold start delay of 5-10 seconds. Normal. Subsequent requests reuse the warm pod.
  2. Possibly an error. The example payload from the beta tool often has missing fields.

If you hit an error like "node 5 has missing fields," go back to ComfyUI, find the node, check its inputs, and add the missing ones to your payload. In the video example, the Empty Latent Image node needed width, height, and batch_size specified.

Step 5: Batch generation in Python

Once the endpoint works with the corrected payload, scaling is a Python script:

import concurrent.futures
import requests

ENDPOINT = "https://api.runpod.ai/v2/YOUR_ID/runsync"
HEADERS = {"Authorization": "Bearer YOUR_API_KEY"}

prompts = open("prompts.txt").readlines()

def generate(prompt):
    payload = {**base_payload, "input": {**base_input, "positive_prompt": prompt}}
    r = requests.post(ENDPOINT, json=payload, headers=HEADERS)
    save_image(r.json())

with concurrent.futures.ThreadPoolExecutor(max_workers=20) as ex:
    ex.map(generate, prompts)

The ThreadPoolExecutor fires all requests in parallel. Each request lands at the RunPod endpoint, which spins up workers to handle them concurrently. Your 100-image batch runs in roughly the time it takes to generate 5 images sequentially.

Getting your API key

In RunPod, go to Settings in the left sidebar, scroll to API Keys, and create one. Paste it as the Authorization: Bearer header on every request.

What to watch out for

  • The beta conversion tool misses model downloads occasionally. Check the Dockerfile.
  • Cold starts are real. First request of the day takes longer.
  • Terminate your pod when done. RunPod charges by uptime, not by job count.

If you need image generation or any other AI pipeline running at scale in your business, get in touch. We build AI UGC ad pipelines end to end.

Need this built for your business?

Atuals builds custom AI agents and workflows. Drop us a note — we reply within 24 hours with an honest take on whether we can help.


Atualsatuals
© 2026 Atuals · AI automation agency