ComfyUI API is an enterprise-grade API gateway, distributed job queue coordinator, worker bridge daemon, and management dashboard for ComfyUI inference workloads. Built to seamlessly power generative production pipelines, GPU farms (such as local AMD EPYC / NVIDIA RTX GPU rigs and cloud instances), and automation systems including comfyui-pack-factory.
ββββββββββββββββββββββββββββββββββββββββββββββββ
β Clients / Apps / Pack Factory / Frontends β
ββββββββββββββββββββββββ¬ββββββββββββββββββββββββ
β HTTP / REST / WebSocket
βΌ
ββββββββββββββββββββββββββββββββββββββββββββββββ
β Cloudflare Worker API Gateway β
β - API Key Auth & Role Access Control β
β - Job Submission & Batch Generation β
β - Workflow Template Catalog & Versioning β
β - Rate Limiting, CORS & Error Sanitization β
ββββββββββββββββββββββββ¬ββββββββββββββββββββββββ
β
βΌ
ββββββββββββββββββββββββββββββββββββββββββββββββ
β Cloudflare D1 (SQLite Edge DB) β
β - jobs, workflows, gpu_nodes, job_logs β
β - Atomic worker leases & priority queues β
ββββββββββββββββββββββββ²ββββββββββββββββββββββββ
β
Long Poll & Lease β Status / Progress / Artifacts
β
ββββββββββββββββββββββββ΄ββββββββββββββββββββββββ
β GPU Worker Daemon Bridge β
β (`bridge/comfy_worker_daemon.py`) β
β - Auto node registration & heartbeats β
β - Atomic job claiming with lease timeouts β
β - WebSocket progress streaming β
ββββββββββββββββββββββββ¬ββββββββββββββββββββββββ
β REST + WebSocket
βΌ
ββββββββββββββββββββββββββββββββββββββββββββββββ
β Local / Remote ComfyUI Instance β
β (http://127.0.0.1:8188) β
ββββββββββββββββββββββββββββββββββββββββββββββββ
- Distributed Job Queue: Prioritized job execution (levels 1-10), atomic leases, timeout detection, and automatic retry handling.
- Workflow Registry: Store, version, tag, and execute reusable ComfyUI workflow templates without re-uploading large graph payloads.
- GPU Fleet Telemetry: Real-time heartbeat tracking, VRAM telemetry, load balancing across worker rigs.
- WebSocket Streaming: Real-time progress updates, sampler step counters (
18/30 steps), and detailed node execution logs. - Batch Processing: Enqueue parameter matrices (prompts, seeds, dimensions) in single batch calls with batch tracking IDs.
- Python Client SDK: Sync (
ComfyUIClient) and Async (AsyncComfyUIClient) SDKs for seamless Python automation. - Interactive UI Dashboard: Modern dark-mode dashboard with glassmorphic aesthetics, live queue monitor, workflow launcher, logs viewer, and artifact gallery.
- Enterprise Security: Bearer / API-Key authentication (
admin,client,workerroles), timing-safe comparisons, CORS preflight handling, and request guardrails.
βββ bridge/
β βββ comfy_worker_daemon.py # GPU server worker bridge daemon
β βββ workflow_adapter.py # AST parameter override engine
βββ client/
β βββ comfyui_api_client.py # Sync & Async Python Client SDK
β βββ __init__.py
βββ deploy/
β βββ d1/
β β βββ schema.sql # D1 SQLite database schema & indexes
β βββ frontend/
β β βββ app.js # Dashboard application logic
β β βββ index.html # Management dashboard UI
β β βββ style.css # Dark glassmorphic design system
β βββ workers/
β βββ wrangler.toml # Cloudflare Worker configuration
β βββ src/
β βββ worker.js # Core API Gateway & Queue Worker
βββ scripts/
β βββ go_live_check.py # Go-live readiness verification audit
βββ tests/
β βββ test_client_sdk.py # Python Client SDK test suite
β βββ test_worker_api.js # Cloudflare Worker test suite
β βββ test_worker_bridge.py # Bridge & adapter test suite
βββ .env.example # Environment variables template
βββ package.json # Node dependencies and scripts
βββ pyproject.toml # Python package configuration
Install dependencies or install in editable mode:
pip install -r requirements.txtfrom client.comfyui_api_client import ComfyUIClient
# Initialize client
client = ComfyUIClient(
api_url="https://api.comfyui.hardonian.com",
api_key="your-api-key"
)
# Submit and wait for generated artifacts
result = client.generate(
workflow="flux-ultra-portrait",
params={
"prompt": "Cinematic portrait of a futuristic nomad, 8k, volumetric light",
"steps": 28,
"seed": 42,
"width": 1024,
"height": 1024,
},
priority=8,
on_progress=lambda status: print(f"Progress: {status['progress']}% - {status.get('current_node')}")
)
print("Job Status:", result["status"])
print("Generated Outputs:", result["outputs"])Run the bridge daemon on your EPYC rig or GPU machine:
python -m bridge.comfy_worker_daemon \
--api-url https://api.comfyui.hardonian.com \
--comfy-url http://127.0.0.1:8188 \
--worker-key "sk_worker_secret" \
--output-dir "./outputs"- Copy
.env.exampleto.envand set your credentials. - Initialize and deploy with Wrangler:
cd deploy/workers
wrangler d1 create comfyui_api_db
wrangler d1 execute comfyui_api_db --remote --file=../d1/schema.sql
wrangler deploy| Method | Endpoint | Role | Description |
|---|---|---|---|
GET |
/health |
Public | System health check and queue stats |
GET |
/api/v1/stats |
Public | Fleet, queue, and workflow metrics |
POST |
/api/v1/jobs |
Client / Admin | Enqueue a generation job |
GET |
/api/v1/jobs |
Client / Admin | List jobs with status/pagination filters |
GET |
/api/v1/jobs/:id |
Client / Admin | Get detailed job status, outputs, and params |
GET |
/api/v1/jobs/:id/status |
Client / Admin | Lightweight polling endpoint |
POST |
/api/v1/jobs/:id/cancel |
Client / Admin | Cancel a queued or running job |
POST |
/api/v1/jobs/:id/retry |
Client / Admin | Requeue a failed or cancelled job |
GET |
/api/v1/jobs/:id/logs |
Client / Admin | Get execution logs for a job |
POST |
/api/v1/nodes/register |
Worker / Admin | Register a GPU worker node |
POST |
/api/v1/nodes/heartbeat |
Worker / Admin | Send worker heartbeat ping |
GET |
/api/v1/nodes |
Public / Admin | List all registered GPU nodes |
POST |
/api/v1/jobs/claim |
Worker / Admin | Atomically claim next available job lease |
POST |
/api/v1/jobs/:id/progress |
Worker / Admin | Report job progress and extend lease |
POST |
/api/v1/jobs/:id/complete |
Worker / Admin | Finalize job with output artifacts |
POST |
/api/v1/jobs/:id/fail |
Worker / Admin | Report execution failure / retry |
POST |
/api/v1/workflows |
Client / Admin | Register a workflow template |
GET |
/api/v1/workflows |
Public | List available workflow templates |
GET |
/api/v1/workflows/:id |
Public | Retrieve workflow template by ID/slug |
POST |
/api/v1/workflows/:id/execute |
Client / Admin | Execute a workflow template directly |
POST |
/api/v1/batch/submit |
Client / Admin | Submit a parameter matrix batch |
Run the full automated test suite:
# Test Cloudflare Worker API
npm test
# Test Python Bridge & SDK
python -m pytest tests/ -v
# Run Comprehensive Go-Live Audit
python scripts/go_live_check.pyMIT License Β© 2026 Hardonian AI