Skip to main content

comfy-proxy

A Python client library for interacting with ComfyUI servers and managing image generation workflows.

Features

  • Single and multi-instance ComfyUI server management
  • Async workflow execution
  • Flexible address configuration (single, multiple, port ranges)
  • Built-in workflow templates
  • Customizable image sizes and parameters
  • Websocket-based image generation and retrieval

Installation

ComfyProxy requires Python 3.11 or later. Install using pip:

pip install comfy-proxy

Quick Start

import asyncio
from comfy_proxy.comfy import SingleComfy
from comfy_proxy.workflows.flux import FluxModel, FluxWorkflowParams, FluxWorkflow
from comfy_proxy.workflow import Sizes

async def generate_image():
    # Initialize a ComfyUI instance
    comfy = Comfy("127.0.0.1:7821")
    
    # Configure model and parameters
    model = FluxModel()
    params = FluxWorkflowParams(
        prompt="a beautiful sunset over mountains",
        model=model,
        size=Sizes.LANDSCAPE_16_9,
        seed=42,
        batch_size=1
    )
    
    # Create and execute workflow
    workflow = FluxWorkflow(params)
    async for image_data in comfy.generate(workflow):
        with open("generated_image.png", "wb") as f:
            f.write(image_data)
        break  # Save first image only

# Run the example
asyncio.run(generate_image())

Multiple ComfyUI Instances

ComfyProxy can distribute work across multiple ComfyUI servers:

from comfy_proxy.comfy import Comfy

# Initialize with multiple instances
comfy = Comfy("127.0.0.1:8188-8192")  # Port range
# or
comfy = Comfy(["127.0.0.1:8188", "127.0.0.1:8189"])  # List
# or
comfy = Comfy("127.0.0.1:8188,127.0.0.1:8189")  # Comma-separated

Development

Requirements:

  • Python 3.11+
  • Poetry for dependency management

Setup:

# Clone repository
git clone https://github.com/yourusername/comfy-proxy.git
cd comfy-proxy

# Install dependencies
poetry install

# Run tests
poetry run pytest

Built-In Workflows

  • Flux t2i
  • Wan 2.2 i2v (first frame, first+last frame, lightning)
  • Qwen Image (regular, lightning)
  • Qwen Image Edit 2509 (regular, lightning)

These correspond roughly to the default ComfyUI workflows and should be highly compatible.

Custom Workflows

ComfyProxy comes with some built-in workflows (like FluxWorkflow), but you can easily create your own:

from comfy_proxy.workflow import ComfyWorkflow, ComfyNode

class MyCustomWorkflow(ComfyWorkflow):
    def __init__(self, params):
        super().__init__()
        self.params = params
        self._build_workflow()
        
    def _build_workflow(self):
        # Add nodes to create your workflow
        checkpoint_node = self.add_node(
            "CheckpointLoaderSimple",
            {"ckpt_name": "sd_xl_base_1.0.safetensors"}
        )
        # ... add more nodes and connect them

We welcome contributions of basic workflows for popular models:

  • Stable Diffusion 1.5
  • SDXL
  • SD Turbo
  • SD 3.0
  • etc.

For more complex use cases, you can implement the ComfyWorkflow class directly in your own codebase to create custom workflows with additional functionality.

License

MIT License - see LICENSE file for details.

Metadata

Release files for comfy-proxy 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for comfy-proxy 0.2.1
File Size Uploaded
comfy_proxy-0.2.1.tar.gz 14.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for comfy-proxy 0.2.1
File Interpreter ABI Platform
comfy_proxy-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 34.2 kB

Release files / comfy_proxy-0.2.1.tar.gz

Download URL comfy_proxy-0.2.1.tar.gz
Size 14.6 kB
Tags Source
SHA-256 checksum
How to use checksums
59a89a1bb10d376c69f1a2668ee0f2ee239034e2fc241fa014db9db48d282cf5
BLAKE2b-256 checksum
How to use checksums
a84c1c1f19375b4438e60d15fce0245c710554cd7d5251a0b78d33556bc0fbc3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.2.1 CPython/3.11.13 Linux/6.8.0-85-generic

Release files / comfy_proxy-0.2.1-py3-none-any.whl

Download URL comfy_proxy-0.2.1-py3-none-any.whl
Size 19.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
91b759e59a652c277024ee3a36ea55014e4a30b4a2f9c15a9d5c88e8875d775a
BLAKE2b-256 checksum
How to use checksums
57f8209d042b07026f13ec15346ee6f19be9a8ed7c13857a84fde91ef55e6488
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.2.1 CPython/3.11.13 Linux/6.8.0-85-generic

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page