Image · October 27, 2026 · 3 min read
Building a text-to-image pipeline with ComfyUI on cloud GPUs
Learn how to deploy and scale ComfyUI on Podstack cloud GPUs using Python and the Podstack API for high-performance, per-second billed image generation.
Deploying high-performance image generation workflows often means balancing the flexibility of a GUI with the scalability of a cloud environment. ComfyUI has emerged as the gold standard for ML engineers who need node-based control over Stable Diffusion, Flux, and SDXL models. However, running these locally often leads to VRAM bottlenecks and thermal throttling.
In this post, we will walk through setting up a production-ready text-to-image pipeline using ComfyUI on Podstack, leveraging on-demand GPUs to ensure you only pay for the seconds your model is actually generating pixels.
Why ComfyUI for Production?
Unlike monolithic interfaces, ComfyUI treats image generation as a computational graph. Each component—the CLIP text encoder, the VAE, the Sampler—is a discrete node. For developers, this is advantageous because:
- Reproducibility: Workflows can be exported as JSON files and triggered via API.
- Efficiency: It only re-runs nodes that have changed, saving precious GPU cycles.
- Extensibility: Custom nodes allow for integrating ControlNet, IP-Adapter, or custom Python logic directly into the pipeline.
Step 1: Setting up the Podstack Environment
To get started, you need the Podstack API. Since Podstack bills per second, we can spin up a high-VRAM instance (like an A100 or H100), perform our heavy lifting, and tear it down immediately.
First, authenticate your environment:
Podstack does not ship a command-line interface. Use the console, the Python package `podstack-sdk`, or the API at https://podstack.ai/api/v1 with a `ps_live_` key.
Now, we will launch a GPU job. While you can run ComfyUI as a persistent server, many developers prefer to launch it as a managed job for batch processing.
Step 2: Preparing the ComfyUI Container
The most efficient way to run ComfyUI on Podstack is via a Docker container. You can use a pre-built image or a custom one that includes your specific models and custom nodes. Below is a Python script using the Podstack SDK to launch a ComfyUI instance with an attached persistent volume for your models.
import podstack
# Initialize the client
client = podstack.Client()
# Define the GPU workload
# We use an NVIDIA A100 for high-resolution Flux generation
job = client.jobs.create(
name="comfyui-text-to-image",
gpu="A100",
image="comfyui/comfyui:latest",
env={
"EXTRA_ARGS": "--listen 0.0.0.0 --port 8188",
},
ports=[8188],
volumes=[{
"name": "model-storage",
"mount_path": "/home/user/ComfyUI/models"
}]
)
print(f"Job started: {job.id}")
print(f"Access your UI at: {job.public_url}:8188")
Step 3: Headless Execution via API
Once your workflow is perfected in the ComfyUI web interface, you don’t want to manually click "Queue Prompt" every time. You can export the workflow as "API Format" (JSON) and send it to the ComfyUI backend running on Podstack.
Here is how you can programmatically trigger a generation from your local machine:
import requests
import json
def generate_image(prompt_text, server_address):
# Load your exported ComfyUI JSON workflow
with open("workflow_api.json", "r") as f:
prompt = json.load(f)
# Update the positive prompt node (usually ID '6' in default workflows)
prompt["6"]["inputs"]["text"] = prompt_text
payload = {"prompt": prompt}
response = requests.post(f"http://{server_address}/prompt", json=payload)
return response.json()
# Example usage with your Podstack endpoint
generate_image("A futuristic cyberpunk cityscape, cinematic lighting", "your-job-url.podstack.run")
Practical Tips for GPU Optimization
- Model Cold Starts: Large models like Flux.1 can take 30+ seconds to load into VRAM. Use Podstack’s persistent volumes to keep your model weights cached close to the GPU, reducing the time between job initialization and the first image generated.
- Scale to Zero: For inference-only workloads, consider wrapping your ComfyUI logic in a Podstack Serverless Function. This allows the GPU to spin down completely when no requests are in the queue.
- FP8 Quantization: If you are running on lower-tier GPUs (like the A10 or RTX 3090), use the FP8 checkpoints for SDXL or Flux to reduce VRAM usage by nearly 50% with minimal quality loss.
Running at Scale on Podstack
Podstack is designed to handle the infrastructure overhead so you can focus on the creative logic of your workflows. By using the Podstack API and our per-second billing, you can execute massive batch image generation tasks without worrying about idle server costs.
Whether you are building a generative AI startup or a custom internal tool, moving your ComfyUI pipelines to Podstack provides the necessary performance overhead. You can start with a single on-demand GPU for prototyping and transition to serverless endpoints for production traffic with the same codebase.
Ready to deploy? Head over to the Podstack dashboard, grab your API key, and launch your first A100 instance in seconds.