ComfyUI Gateway
Overview
REST API gateway for ComfyUI servers. Workflow management, job queuing, webhooks, caching, auth, rate limiting, and image delivery (URL + base64).
When to Use This Skill
- When the user mentions "comfyui" or related topics
- When the user mentions "comfy ui" or related topics
- When the user mentions "stable diffusion api gateway" or related topics
- When the user mentions "gateway comfyui" or related topics
- When the user mentions "api gateway imagens" or related topics
- When the user mentions "queue imagens" or related topics
Do Not Use This Skill When
- The task is unrelated to comfyui gateway
- A simpler, more specific tool can handle the request
- The user needs general-purpose assistance without domain expertise
How It Works
A production-grade REST API gateway that transforms any ComfyUI server into a universal,
secure, and scalable service. Supports workflow templates with placeholders, job queuing
with priorities, webhook callbacks, result caching, and multiple storage backends.
Architecture Overview
┌─────────────┐ ┌──────────────────────────────────┐ ┌──────────┐
│ Clients │────▶│ ComfyUI Gateway │────▶│ ComfyUI │
│ (curl, n8n, │ │ │ │ Server │
│ Claude, │ │ ┌─────────┐ ┌──────────────┐ │ │ (local/ │
│ Lovable, │ │ │ Fastify │ │ BullMQ Queue │ │ │ remote) │
│ Supabase) │ │ │ API │──│ (or in-mem) │ │ └──────────┘
│ │◀────│ └─────────┘ └──────────────┘ │
│ │ │ ┌─────────┐ ┌──────────────┐ │ ┌──────────┐
│ │ │ │ Auth + │ │ Storage │ │────▶│ S3/MinIO │
│ │ │ │ RateL. │ │ (local/S3) │ │ │(optional)│
│ │ │ └─────────┘ └──────────────┘ │ └──────────┘
└─────────────┘ └──────────────────────────────────┘
Components
| Component |
Purpose |
File(s) |
| API Gateway |
REST endpoints, validation, CORS |
src/api/ |
| Worker |
Processes jobs, talks to ComfyUI |
src/worker/ |
| ComfyUI Client |
HTTP + WebSocket to ComfyUI |
src/comfyui/ |
| Workflow Manager |
Template storage, placeholder rendering |
src/workflows/ |
| Storage Provider |
Local disk + S3-compatible |
src/storage/ |
| Cache |
Hash-based deduplication |
src/cache/ |
| Notifier |
Webhook with HMAC signing |
src/notifications/ |
| Auth |
API key + JWT + rate limiting |
src/auth/ |
| DB |
SQLite (better-sqlite3) or Postgres |
src/db/ |
| CLI |
Init, add-workflow, run, worker |
src/cli/ |
Quick Start
## 1. Install
cd comfyui-gateway
npm install
## 2. Configure
cp .env.example .env
## 3. Initialize
npx tsx src/cli/index.ts init
## 4. Add A Workflow
npx tsx src/cli/index.ts add-workflow ./workflows/sdxl_realism_v1.json \
--id sdxl_realism_v1 --schema ./workflows/sdxl_realism_v1.schema.json
## 5. Start (Api + Worker In One Process)
npm run dev
## Or Separately:
npm run start:api # API only
npm run start:worker # Worker only
Environment Variables
All configuration is via .env — nothing is hardcoded:
| Variable |
Default |
Description |
PORT |
3000 |
API server port |
HOST |
0.0.0.0 |
API bind address |
COMFYUI_URL |
http://127.0.0.1:8188 |
ComfyUI server URL |
COMFYUI_TIMEOUT_MS |
300000 |
Max wait for ComfyUI (5min) |
API_KEYS |
"" |
Comma-separated API keys (key:role) |
JWT_SECRET |
"" |
JWT signing secret (empty = JWT disabled) |
REDIS_URL |
"" |
Redis URL (empty = in-memory queue) |
DATABASE_URL |
./data/gateway.db |
SQLite path or Postgres URL |
STORAGE_PROVIDER |
local |
local or s3 |
STORAGE_LOCAL_PATH |
./data/outputs |
Local output directory |
S3_ENDPOINT |
"" |
S3/MinIO endpoint |
S3_BUCKET |
"" |
S3 bucket name |
S3_ACCESS_KEY |
"" |
S3 access key |
S3_SECRET_KEY |
"" |
S3 secret key |
S3_REGION |
us-east-1 |
S3 region |
WEBHOOK_SECRET |
"" |
HMAC signing secret for webhooks |
WEBHOOK_ALLOWED_DOMAINS |
* |
Comma-separated allowed callback domains |
MAX_CONCURRENCY |
1 |
Parallel jobs per GPU |
MAX_IMAGE_SIZE |
2048 |
Maximum dimension (width or height) |
MAX_BATCH_SIZE |
4 |
Maximum batch size |
CACHE_ENABLED |
true |
Enable result caching |
CACHE_TTL_SECONDS |
86400 |
Cache TTL (24h) |
RATE_LIMIT_MAX |
100 |
Requests per window |
RATE_LIMIT_WINDOW_MS |
60000 |
Rate limit window (1min) |
LOG_LEVEL |
info |
Pino log level |
PRIVACY_MODE |
false |
Redact prompts from logs |
CORS_ORIGINS |
* |
Allowed CORS origins |
NODE_ENV |
development |
Environment |
Health & Capabilities
GET /health
→ { ok: true, version, comfyui: { reachable, url, models? }, uptime }
GET /capabilities
→ { workflows: [..
1---2name: comfyui-gateway3description: REST API gateway for ComfyUI servers. Workflow management, job queuing, webhooks, caching, auth, rate limiting, and image delivery (URL + base64). 4category: Creative & Media5source: antigravity6tags: [python, javascript, typescript, node, api, claude, ai, llm, workflow, template]7url: https://github.com/sickn33/antigravity-awesome-skills/tree/main/skills/comfyui-gateway8metadata:9 source: https://skillmd.com/skills/sickn33/comfyui-gateway10---111213# ComfyUI Gateway1415## Overview1617REST API gateway for ComfyUI servers. Workflow management, job queuing, webhooks, caching, auth, rate limiting, and image delivery (URL + base64).1819## When to Use This Skill2021- When the user mentions "comfyui" or related topics22- When the user mentions "comfy ui" or related topics23- When the user mentions "stable diffusion api gateway" or related topics24- When the user mentions "gateway comfyui" or related topics25- When the user mentions "api gateway imagens" or related topics26- When the user mentions "queue imagens" or related topics2728## Do Not Use This Skill When2930- The task is unrelated to comfyui gateway31- A simpler, more specific tool can handle the request32- The user needs general-purpose assistance without domain expertise3334## How It Works3536A production-grade REST API gateway that transforms any ComfyUI server into a universal,37secure, and scalable service. Supports workflow templates with placeholders, job queuing38with priorities, webhook callbacks, result caching, and multiple storage backends.3940## Architecture Overview4142```43┌─────────────┐ ┌──────────────────────────────────┐ ┌──────────┐44│ Clients │────▶│ ComfyUI Gateway │────▶│ ComfyUI │45│ (curl, n8n, │ │ │ │ Server │46│ Claude, │ │ ┌─────────┐ ┌──────────────┐ │ │ (local/ │47│ Lovable, │ │ │ Fastify │ │ BullMQ Queue │ │ │ remote) │48│ Supabase) │ │ │ API │──│ (or in-mem) │ │ └──────────┘49│ │◀────│ └─────────┘ └──────────────┘ │50│ │ │ ┌─────────┐ ┌──────────────┐ │ ┌──────────┐51│ │ │ │ Auth + │ │ Storage │ │────▶│ S3/MinIO │52│ │ │ │ RateL. │ │ (local/S3) │ │ │(optional)│53│ │ │ └─────────┘ └──────────────┘ │ └──────────┘54└─────────────┘ └──────────────────────────────────┘55```5657## Components5859| Component | Purpose | File(s) |60|-----------|---------|---------|61| **API Gateway** | REST endpoints, validation, CORS | `src/api/` |62| **Worker** | Processes jobs, talks to ComfyUI | `src/worker/` |63| **ComfyUI Client** | HTTP + WebSocket to ComfyUI | `src/comfyui/` |64| **Workflow Manager** | Template storage, placeholder rendering | `src/workflows/` |65| **Storage Provider** | Local disk + S3-compatible | `src/storage/` |66| **Cache** | Hash-based deduplication | `src/cache/` |67| **Notifier** | Webhook with HMAC signing | `src/notifications/` |68| **Auth** | API key + JWT + rate limiting | `src/auth/` |69| **DB** | SQLite (better-sqlite3) or Postgres | `src/db/` |70| **CLI** | Init, add-workflow, run, worker | `src/cli/` |7172## Quick Start7374```bash7576## 1. Install7778cd comfyui-gateway79npm install8081## 2. Configure8283cp .env.example .env8485## 3. Initialize8687npx tsx src/cli/index.ts init8889## 4. Add A Workflow9091npx tsx src/cli/index.ts add-workflow ./workflows/sdxl_realism_v1.json \92 --id sdxl_realism_v1 --schema ./workflows/sdxl_realism_v1.schema.json9394## 5. Start (Api + Worker In One Process)9596npm run dev9798## Or Separately:99100npm run start:api # API only101npm run start:worker # Worker only102```103104## Environment Variables105106All configuration is via `.env` — nothing is hardcoded:107108| Variable | Default | Description |109|----------|---------|-------------|110| `PORT` | `3000` | API server port |111| `HOST` | `0.0.0.0` | API bind address |112| `COMFYUI_URL` | `http://127.0.0.1:8188` | ComfyUI server URL |113| `COMFYUI_TIMEOUT_MS` | `300000` | Max wait for ComfyUI (5min) |114| `API_KEYS` | `""` | Comma-separated API keys (`key:role`) |115| `JWT_SECRET` | `""` | JWT signing secret (empty = JWT disabled) |116| `REDIS_URL` | `""` | Redis URL (empty = in-memory queue) |117| `DATABASE_URL` | `./data/gateway.db` | SQLite path or Postgres URL |118| `STORAGE_PROVIDER` | `local` | `local` or `s3` |119| `STORAGE_LOCAL_PATH` | `./data/outputs` | Local output directory |120| `S3_ENDPOINT` | `""` | S3/MinIO endpoint |121| `S3_BUCKET` | `""` | S3 bucket name |122| `S3_ACCESS_KEY` | `""` | S3 access key |123| `S3_SECRET_KEY` | `""` | S3 secret key |124| `S3_REGION` | `us-east-1` | S3 region |125| `WEBHOOK_SECRET` | `""` | HMAC signing secret for webhooks |126| `WEBHOOK_ALLOWED_DOMAINS` | `*` | Comma-separated allowed callback domains |127| `MAX_CONCURRENCY` | `1` | Parallel jobs per GPU |128| `MAX_IMAGE_SIZE` | `2048` | Maximum dimension (width or height) |129| `MAX_BATCH_SIZE` | `4` | Maximum batch size |130| `CACHE_ENABLED` | `true` | Enable result caching |131| `CACHE_TTL_SECONDS` | `86400` | Cache TTL (24h) |132| `RATE_LIMIT_MAX` | `100` | Requests per window |133| `RATE_LIMIT_WINDOW_MS` | `60000` | Rate limit window (1min) |134| `LOG_LEVEL` | `info` | Pino log level |135| `PRIVACY_MODE` | `false` | Redact prompts from logs |136| `CORS_ORIGINS` | `*` | Allowed CORS origins |137| `NODE_ENV` | `development` | Environment |138139## Health & Capabilities140141```142GET /health143→ { ok: true, version, comfyui: { reachable, url, models? }, uptime }144145GET /capabilities146→ { workflows: [..