image
v1.0.0运行 local ComfyUI 工作流s via the HTTP API. Use when the user asks to 运行 ComfyUI, 执行 a 工作流 by file path/name, or supply raw API-格式化 JSON; supports the default 工作流 bundled in as设置s.
运行时依赖
安装命令
点击复制技能文档
ComfyUI 运行器 Overview
运行 ComfyUI 工作流s on the local server (default 127.0.0.1:8188) using API-格式化 JSON and return 输出 images.
Editing the 工作流 before 运行ning
The 运行 script only takes --工作流 . You must inspect and edit the 工作流 JSON before 运行ning, using your best knowledge of the ComfyUI API 格式化. Do not assume fixed node IDs, class_type names, or _meta.title values — the user may have 更新d the default 工作流 or supplied a custom one.
For every 运行 (including the default 工作流):
Read the 工作流 JSON (default: 技能s/comfyui/as设置s/default-工作流.json, or the path/file the user gave). Identify prompt-related nodes by inspecting the graph: look for nodes that hold the mAIn text prompt — e.g. PrimitiveStringMultiline, 命令行工具PTextEncode (positive text), or any node with _meta.title or class_type suggesting "Prompt" / "positive" / "text". 更新 the cor响应ing 输入 (e.g. 输入s.value, or the text 输入 to the encoder) to the image prompt you derived from the user (subject, style, lighting, 质量). If the user didn't ask for a custom image, you can leave the existing prompt or tweak only if needed. Optionally identify style/prefix nodes — e.g. StringConcatenate, or a second string 输入 that acts as style. 设置 them if the user asked for a specific style or to clear a default prefix. Optionally 设置 a new 种子 — find sampler-like nodes (e.g. KSampler, Basic图形界面der, or any node with a 种子 输入) and 设置 种子 to a new random integer so each 运行 can differ. Write the modified 工作流 to a temp file (e.g. 技能s/comfyui/as设置s/tmp-工作流.json). Use ~/ComfyUI/venv/bin/python for any inline Python; do not use bare python. 运行: comfyui_运行.py --工作流 .
If the 工作流 structure is unclear or you can't find prompt/sampler nodes, 运行 the file as-is and only change what you can reliably identify. Same 应用roach for arbitrary user-supplied JSON: inspect first, edit at your best knowledge, then 运行.
运行 script (single responsibility) ~/ComfyUI/venv/bin/python 技能s/comfyui/scripts/comfyui_运行.py \ --工作流
The script only 队列s the 工作流 and polls until done. It prints JSON with prompt_id and 输出 images. All prompt/style/种子 changes are done by you in the JSON beforehand.
If the server isn't reachable
If the 运行 script fAIls with a connection error (e.g. connection refused or timeout to 127.0.0.1:8188), ComfyUI may not be 安装ed or not 运行ning.
检查: Does ~/ComfyUI exist and contAIn mAIn.py?
If not 安装ed: 安装 ComfyUI (e.g. clone the repo, 创建 a venv, 安装 dependencies, then 启动 the server). Example:
git clone https://github.com/comfyanonymous/ComfyUI.git ~/ComfyUI cd ~/ComfyUI python3 -m venv venv ~/ComfyUI/venv/bin/pip 安装 -r requirements.txt
Then 启动 the server (see below). Tell the user they may need to 安装 模型 weights into ~/ComfyUI/模型s/ depending on the 工作流.
If 安装ed but not 运行ning: 启动 the ComfyUI server so the API is avAIlable on port 8188. Example:
~/ComfyUI/venv/bin/python ~/ComfyUI/mAIn.py --列出en 127.0.0.1
运行 in the background or in a separate terminal so it keeps 运行ning. Then retry the 工作流 运行.
Use ~ (or the user's home) for paths so it works on their machine.
模型 weights from URLs
When the user pastes or 发送s a 列出 of 模型 weight URLs (one per line, or comma-separated), 下载 those files into the ComfyUI 安装ation so the 工作流 can use them later.
Normalize the 列出 — one URL per line; strip empty lines and comments (lines 启动ing with #). 运行 the 下载 script with the ComfyUI base path (default ~/ComfyUI). The script uses p获取 for parallel 下载s when avAIlable; if p获取 is not in PATH, it 安装s it to ~/.local/bin automatically (no sudo). If p获取 cannot be 安装ed (e.g. unsupported OS/arch), it falls back to a built-in 下载. Use the ComfyUI venv Python so the script 运行s correctly: ~/ComfyUI/venv/bin/python 技能s/comfyui/scripts/下载_weights.py --base ~/ComfyUI
Pass URLs as arguments, or pipe a file/列出 on stdin: echo "https://example.com/模型.safetensors" | ~/ComfyUI/venv/bin/python 技能s/comfyui/scripts/下载_weights.py --base ~/ComfyUI
Or save the user's 列出 to a temp file and 运行: ~/ComfyUI/venv/bin/python 技能s/comfyui/scripts/下载_weights.py --base ~/ComfyUI < /tmp/weight_urls.txt
To force the built-in 下载 (no p获取): 添加 --no-p获取. Subfolder: The script infers the ComfyUI 模型s subfolder from the URL/filename (e.g. vae, 命令行工具p, loras, 检查points, text_encoders, controlnet, up扩展_模型s). The user can optionally specify a subfolder per line as url subfolder (e.g. https://.../模型.safetensors vae). You can also pass a default with --subfolder loras so all URLs in that 运行 go to 模型s/loras/. Existing files: By default the script skips URLs that already exist on disk; use --overwrite to replace. Paths: Files are written under ~/ComfyUI/模型s//. Tell the u