26a8afd0ddc10ac347e274cc8a23cf209a3665fb
ComfyUI-OneAPI
ComfyUI-OneAPI is a plugin that provides simple REST API interfaces for ComfyUI, allowing you to execute ComfyUI workflows through a single API request.
Features
- Simple Interface: Execute complex ComfyUI workflows through a single API endpoint
- Parameter Mapping: Support for dynamically replacing parameters in workflows
- Asynchronous Execution: Support for both synchronous and asynchronous execution modes
- No WebSocket Dependency: Uses HTTP polling to get results, no need to handle WebSocket connections
Installation
- Download or clone this repository to the
custom_nodesdirectory of ComfyUI - Restart ComfyUI
API Usage
Execute Workflow
POST /oneapi/v1/execute
Request Body:
{
"workflow": {Workflow JSON},
"params": {
"paramName": "paramValue"
},
"wait_for_result": true,
"timeout": 300
}
Workflow Parameter Mapping
To use dynamic parameters in your workflow, you need to use special markers in the node titles:
- LoadImage node: Use
$image_paramformat - Other nodes: Use
$param.field_nameformat
Examples:
- A LoadImage node marked with
$input_imagewill use the input_image parameter from params as the image filename - A CLIPTextEncode node marked with
$prompt.textwill replace the text field with the prompt parameter from params
Examples
curl Examples
Text-to-Image Example
curl -X POST "http://localhost:8188/oneapi/v1/execute" \
-H "Content-Type: application/json" \
-d '{
"workflow": '"$(cat workflows/example_workflow.json)"',
"params": {
"prompt": "a cute dog with a red hat"
},
"wait_for_result": true
}'
Image-to-Image Example
# Execute image-to-image workflow
curl -X POST "http://localhost:8188/oneapi/v1/execute" \
-H "Content-Type: application/json" \
-d '{
"workflow": '"$(cat workflows/example_img2img_workflow.json)"',
"params": {
"prompt": "a cute dog with a red hat",
"image": "https://example.com/input.jpg"
},
"wait_for_result": true
}'
Notes
- This plugin is designed to simplify API calls, and does not provide WebSocket real-time progress information
- Long-running workflows may cause request timeouts, consider setting appropriate timeout values
- Parameter mapping in workflows depends on special markers in node titles
Languages
Python
66.1%
JavaScript
33.9%