Skip to content

Commit 2cf8119

Browse files
andCo songgitbook-bot
andCo song
authored andcommittedDec 27, 2024··
GITBOOK-62: ComfyUI API Documentation
1 parent ef9fabf commit 2cf8119

File tree

3 files changed

+399
-0
lines changed

3 files changed

+399
-0
lines changed
 
36.3 KB
Loading

‎SUMMARY.md

+4
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,7 @@
4646
## Java
4747

4848
* [记一次库版本升级引起程序自动停止](java/ji-yi-ci-ku-ban-ben-sheng-ji-yin-qi-cheng-xu-zi-dong-ting-zhi.md)
49+
50+
## 🖼️ ComfyUi
51+
52+
* [ComfyUI API Documentation](comfyui/comfyui-api-documentation.md)

‎comfyui/comfyui-api-documentation.md

+395
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,395 @@
1+
# ComfyUI API Documentation
2+
3+
## ComfyUI API Documentation
4+
5+
### 获取prompt queue\_remaining
6+
7+
**GET** `/api/prompt`
8+
9+
_**返回**_: 提示队列的剩余信息
10+
11+
| 参数 | 类型 | 描述 |
12+
| ---------------- | ------ | ------ |
13+
| queue\_remaining | number | 队列剩余信息 |
14+
15+
_**例子**_:
16+
17+
```json
18+
{
19+
   "exec_info": {
20+
       "queue_remaining": 0
21+
  }
22+
}
23+
```
24+
25+
### 提交prompt
26+
27+
**POST** `/api/prompt`
28+
29+
| 参数 | 类型 | 描述 |
30+
| ----------- | ------ | --------------- |
31+
| client\_id | string | 客户端ID【必填】 |
32+
| prompt | object | 提交的prompt对象【必填】 |
33+
| extra\_data | object | 额外的数据 |
34+
35+
_**tips**_: prompt为comfyui页面通过`导出 api`按钮导出的json。
36+
37+
<figure><img src="../.gitbook/assets/image-20241227112603528.png" alt=""><figcaption></figcaption></figure>
38+
39+
请求示例:
40+
41+
```json
42+
{
43+
   "client_id": "ff4e1f1eb0294c559126fddbfb4df8fa",
44+
   "prompt": {
45+
       "3": {
46+
           "inputs": {
47+
               "seed": 215851134236677,
48+
               "steps": 20,
49+
               "cfg": 8,
50+
               "sampler_name": "euler",
51+
               "scheduler": "normal",
52+
               "denoise": 1,
53+
               "model": [
54+
                   "4",
55+
                   0
56+
              ],
57+
               "positive": [
58+
                   "6",
59+
                   0
60+
              ],
61+
               "negative": [
62+
                   "7",
63+
                   0
64+
              ],
65+
               "latent_image": [
66+
                   "5",
67+
                   0
68+
              ]
69+
          },
70+
           "class_type": "KSampler"
71+
      },
72+
       "4": {
73+
           "inputs": {
74+
               "ckpt_name": "XL\\Dream Tech XL _ 筑梦工业XL_v6.0 - 寄语星河.safetensors"
75+
          },
76+
           "class_type": "CheckpointLoaderSimple"
77+
      },
78+
       "5": {
79+
           "inputs": {
80+
               "width": 512,
81+
               "height": 512,
82+
               "batch_size": 1
83+
          },
84+
           "class_type": "EmptyLatentImage"
85+
      },
86+
       "6": {
87+
           "inputs": {
88+
               "text": "beautiful scenery nature glass bottle landscape, , purple galaxy bottle,",
89+
               "speak_and_recognation": true,
90+
               "clip": [
91+
                   "4",
92+
                   1
93+
              ]
94+
          },
95+
           "class_type": "CLIPTextEncode"
96+
      },
97+
       "7": {
98+
           "inputs": {
99+
               "text": "text, watermark",
100+
               "speak_and_recognation": true,
101+
               "clip": [
102+
                   "4",
103+
                   1
104+
              ]
105+
          },
106+
           "class_type": "CLIPTextEncode"
107+
      },
108+
       "8": {
109+
           "inputs": {
110+
               "samples": [
111+
                   "3",
112+
                   0
113+
              ],
114+
               "vae": [
115+
                   "4",
116+
                   2
117+
              ]
118+
          },
119+
           "class_type": "VAEDecode"
120+
      },
121+
       "9": {
122+
           "inputs": {
123+
               "filename_prefix": "ComfyUI",
124+
               "images": [
125+
                   "8",
126+
                   0
127+
              ]
128+
          },
129+
           "class_type": "SaveImage"
130+
      }
131+
  }
132+
}
133+
```
134+
135+
_返回_: 提交prompt请求的结果
136+
137+
| 参数 | 类型 | 描述 |
138+
| ------------ | ------ | ------------- |
139+
| prompt\_id | string | 此次prompt生成的id |
140+
| number | number | 第几个prompt |
141+
| node\_errors | json | 错误信息 |
142+
143+
例子:
144+
145+
```json
146+
{
147+
   "prompt_id": "2730a344-0043-4cb3-a73d-0a9c35e81a26",
148+
   "number": 10,
149+
   "node_errors": {}
150+
}
151+
```
152+
153+
### 结果view
154+
155+
**GET** `/view`
156+
157+
| 参数 | 类型 | 描述 |
158+
| -------- | ------ | --- |
159+
| filename | string | 文件名 |
160+
161+
_返回_: 查看结果
162+
163+
例子:
164+
165+
[http://127.0.0.1:8188/view?filename=ComfyUI\_03600\_.png](http://127.0.0.1:8188/view?filename=ComfyUI_03600_.png)
166+
167+
### 历史history list
168+
169+
**GET** `/api/history`
170+
171+
| 参数 | 类型 | 描述 |
172+
| ---------- | ------- | ----- |
173+
| max\_items | integer | 最大项目数 |
174+
175+
_返回_: 历史记录json map
176+
177+
格式如下
178+
179+
```json
180+
{
181+
"{prompt_id}": {
182+
"prompt": [],
183+
"outputs": {},
184+
"status": {},
185+
"meta": {}
186+
}
187+
}
188+
```
189+
190+
### 历史history\_single
191+
192+
**GET** `/api/history/{prompt_id}`
193+
194+
| 参数 | 类型 | 描述 |
195+
| ----------- | ------ | ------ |
196+
| history\_id | string | 历史记录ID |
197+
198+
_返回_: 单个历史记录的详细信息
199+
200+
### 队列queue
201+
202+
**GET** `/api/queue`
203+
204+
_返回_: 队列信息
205+
206+
```json
207+
{
208+
  "queue_running": [],
209+
  "queue_pending": []
210+
}
211+
```
212+
213+
### 获取embeddings
214+
215+
**GET** `/api/embeddings`
216+
217+
_返回_: 嵌入信息
218+
219+
### 获取模块目录models
220+
221+
**GET** `/api/models`
222+
223+
_返回_: 模块目录
224+
225+
```json
226+
[
227+
   "checkpoints",
228+
   "configs",
229+
   "loras",
230+
   "vae",
231+
   "text_encoders",
232+
   "diffusion_models",
233+
   "clip_vision",
234+
   "style_models",
235+
   "embeddings",
236+
   "diffusers",
237+
   ...
238+
]
239+
```
240+
241+
### 获取具体模块目录文件
242+
243+
**GET** `/api/models/{model}`
244+
245+
_返回_: 模块目录配置
246+
247+
例子:`/api/models/checkpoints`
248+
249+
返回
250+
251+
```json
252+
[
253+
  "v1-5-pruned-emaonly.safetensors"
254+
]
255+
```
256+
257+
### 获取扩展文件
258+
259+
**GET** `/api/extensions`
260+
261+
_返回_: 扩展文件
262+
263+
### 上传文件
264+
265+
**POST** `/api/upload/image`
266+
267+
| 参数 | 类型 | 描述 |
268+
| ----- | ---- | -------- |
269+
| image | file | 要上传的图片文件 |
270+
271+
_返回_: 文件上传结果
272+
273+
```json
274+
{
275+
   "name": "image-20240722194828969.png",
276+
   "subfolder": "",
277+
   "type": "input"
278+
}
279+
```
280+
281+
### 上传 mask
282+
283+
**POST** `/api/upload/mask`
284+
285+
| 参数 | 类型 | 描述 |
286+
| ------------- | ------ | -------- |
287+
| image | file | 要上传的图片文件 |
288+
| type | string | 类型 |
289+
| subfolder | string | 子文件夹 |
290+
| original\_ref | string | 原始引用 |
291+
292+
_返回_: 掩码文件上传结果
293+
294+
```json
295+
{
296+
  "name": "image-20240722194828969.png",
297+
  "subfolder": "clipspace",
298+
  "type": "input"
299+
}
300+
```
301+
302+
### system\_stats
303+
304+
**GET** `/api/system_stats`
305+
306+
_返回_: 系统状态信息
307+
308+
```json
309+
{
310+
   "system": {
311+
       "os": "nt",
312+
       "ram_total": 34187878400,
313+
       "ram_free": 21487468544,
314+
       "comfyui_version": "v0.3.5",
315+
       "python_version": "3.11.6 | packaged by conda-forge | (main, Oct 3 2023, 10:29:11) [MSC v.1935 64 bit (AMD64)]",
316+
       "pytorch_version": "2.4.1+cu124",
317+
       "embedded_python": false,
318+
  },
319+
   "devices": [
320+
      {
321+
           "name": "cuda:0 NVIDIA GeForce RTX 4070 : cudaMallocAsync",
322+
           "type": "cuda",
323+
           "index": 0,
324+
           "vram_total": 12878086144,
325+
           "vram_free": 4595430366,
326+
           "torch_vram_total": 6979321856,
327+
           "torch_vram_free": 6861790
328+
      }
329+
  ]
330+
}
331+
```
332+
333+
### 获取模型 view\_metadata
334+
335+
**GET** `/api/view_metadata/{folder_name}`
336+
337+
| 参数 | 类型 | 描述 |
338+
| -------- | ------ | --- |
339+
| filename | string | 文件名 |
340+
341+
_返回_: 模型元数据
342+
343+
例子: `/api/view_metadata/checkpoints?filename=v1-5-pruned-emaonly.safetensors`
344+
345+
```json
346+
{
347+
  "format": "pt"
348+
}
349+
```
350+
351+
### 所有node object\_info
352+
353+
**GET** `/api/object_info`
354+
355+
_返回_: 所有节点对象信息
356+
357+
### 所有具体node object\_info
358+
359+
**GET** `/api/object_info/{node_type}`
360+
361+
| 参数 | 类型 | 描述 |
362+
| ---------- | ------ | ---- |
363+
| node\_type | string | 节点类型 |
364+
365+
_返回_: 特定节点对象信息
366+
367+
例子:`api/object_info/KSampler` 获取 KSampler 节点的所有信息
368+
369+
### clear或delete queue
370+
371+
**POST** `/api/queue`
372+
373+
| 参数 | 类型 | 描述 |
374+
| ------ | ------- | ---- |
375+
| clear | boolean | 是否清除 |
376+
| delete | array | 删除项 |
377+
378+
_返回_: 清除或删除队列项的结果
379+
380+
### clear或delete history
381+
382+
**POST** `/api/history`
383+
384+
| 参数 | 类型 | 描述 |
385+
| ------ | ------- | ---- |
386+
| clear | boolean | 是否清除 |
387+
| delete | array | 删除项 |
388+
389+
_返回_: 清除或删除历史记录的结果
390+
391+
### interrupt 中断当前的运行
392+
393+
**POST** `/api/interrupt`
394+
395+
_返回_: 中断当前运行的结果

0 commit comments

Comments
 (0)
Please sign in to comment.