CodeVetter · Repo Unpack · Feature catalog
Comfy-Org/ComfyUI
The user-facing surface is an HTTP+WebSocket API driving a node-graph execution engine, plus a large built-in node library. HTTP covers prompt submission, queue/history management, job status, image upload/view, model listing, object_info schema introspection, user data storage, and workflow templates. The node catalog spans core SD nodes in nodes.py, ~130 comfy_extras modules (audio, video, 3D, model merging, advanced samplers), and comfy_api_nodes that call paid third-party APIs. The optional ComfyUI Manager integration and the assets system (blake3-hashed media catalog in SQLite) are feature-flagged subsystems.
- POST /prompt accepts a workflow graph {node_id: {class_type, inputs}} plus optional client_id/extra_data/prompt_id/partial_execution_targets, runs validate_prompt, and heapq-pushes (number, prompt_id, prompt, extra_data, outputs_to_execute, sensitive) onto PromptQueue returning {prompt_id, number, node_errors}.
- Queue and history endpoints: GET /queue returns running+pending with sensitive fields stripped by _remove_sensitive_from_queue; POST /queue supports clear/delete; GET /history and /history/{prompt_id} read the in-memory history dict; POST /history clears or deletes entries.
- A jobs API exposes GET /api/jobs, GET /api/jobs/{job_id}, POST /api/jobs/{job_id}/cancel and POST /api/jobs/cancel backed by comfy_execution/jobs.py with JobStatus pending/in_progress/completed/failed/cancelled.
- POST /interrupt either targets a specific running prompt_id or globally interrupts via nodes.interrupt_processing -> comfy.model_management.interrupt_current_processing; POST /free sets unload_models/free_memory flags consumed by the worker loop.
- File endpoints: POST /upload/image and /upload/mask write into input/temp/output dirs with subfolder confinement checks and duplicate detection via hashing; GET /view serves files (including blake3: hash resolution to asset paths) and GET /view_metadata/{folder} exposes safetensors metadata.
- Introspection endpoints: GET /object_info and /object_info/{node_class} serialize each node class's INPUT_TYPES/RETURN_TYPES/CATEGORY for the frontend; GET /models and /models/{folder} list folder_paths categories; GET /embeddings lists embedding names; GET /system_stats and /features report device and capability info.
- The /ws WebSocket negotiates per-client feature_flags as the first message, then streams JSON events (status, executing, executed, progress, execution_start/cached/success/error) and binary frames for preview images (PREVIEW_IMAGE, UNENCODED_PREVIEW_IMAGE, PREVIEW_IMAGE_WITH_METADATA from protocol.BinaryEventTypes).
- Core node set in nodes.py covers the SD1.x/SDXL workflow: CheckpointLoaderSimple, CLIPTextEncode, KSampler/KSamplerAdvanced, VAEEncode/VAEDecode(+Tiled), LoraLoader, ControlNetLoader/Apply, EmptyLatentImage, SaveImage/PreviewImage, LoadImage, and conditioning/latent/image transform nodes.
- comfy_extras/ contributes ~130 node modules loaded by init_builtin_extra_nodes: upscale models, mask/compositing, model merging, SD3/Flux/Hunyuan/Wan/Qwen video+audio model support, 3D (load/save/mesh/gaussian splat), GLSL shaders, logic/loop/math utility nodes, and training nodes (nodes_train, nodes_dataset).
- comfy_api_nodes/ contains API nodes that call remote paid services (OpenAI, Anthropic, Gemini, Grok, Kling, Luma, ByteDance, ElevenLabs, Stability, etc.) authenticated through hidden AUTH_TOKEN_COMFY_ORG/API_KEY_COMFY_ORG extra_data keys; --disable-api-nodes blocks them and adds a restrictive CSP middleware.
- User/file management features: UserManager adds /users CRUD and /userdata file endpoints (GET/POST/DELETE/move) gated by --multi-user; get_public_user_directory blocks '__'-prefixed system user dirs from HTTP access.
- ModelFileManager adds experimental /experiment/models routes including a preview endpoint that extracts embedded preview images from model files; CustomNodeManager serves /workflow_templates and /i18n translation JSON built from loaded custom nodes.
- The assets system (--enable-assets) registers uploads and generated outputs into a SQLite catalog with blake3 content hashes, runs background filesystem scans, and emits events through the server's send_sync sink.
- Latent previews during sampling are produced by latent_preview.py with methods none/auto/latent2rgb/taesd chosen by --preview-method/--preview-size, streamed to the client as binary preview frames via the hijacked progress hook.
- Internal (frontend-only, unstable) endpoints are mounted as the /internal sub-app: /internal/logs, /internal/logs/raw and log-subscription handled by TerminalService.