Introduction
The ComfyUI REST API allows you to programmatically interact with ComfyUI to queue prompts, monitor execution, and manage workflows. The API uses JSON for request and response payloads.Base URL
The default base URL for the ComfyUI API is:/api prefix for easier routing:
/prompt and /api/prompt).
Authentication
API Nodes Authentication
If your workflow contains API nodes, you can include a Comfy API key in theextra_data field of your request payload:
Generate your API key at https://platform.comfy.org/login
Request Format
All POST requests should:- Use
Content-Type: application/jsonheader - Send data as JSON-encoded request body
Response Format
All successful responses return JSON with appropriate HTTP status codes:200- Success400- Bad request (invalid prompt or parameters)403- Forbidden (security violation)404- Resource not found
CORS Support
CORS can be enabled using the--enable-cors-header command-line argument when starting ComfyUI. When running locally without CORS enabled, the server includes Origin validation for security.
WebSocket API
In addition to the REST API, ComfyUI provides a WebSocket endpoint for real-time updates:- Execution status updates
- Preview images during generation
- Queue status changes
- Error notifications
Rate Limiting
There are no built-in rate limits, but be mindful of:- Server processing capacity
- Queue size limits
- Maximum upload size (configurable via
--max-upload-sizeargument)
Common Workflow
- Export your workflow: Use “File → Export (API)” in the ComfyUI interface
- Queue the prompt: POST to
/promptendpoint - Monitor execution: Connect to WebSocket or poll
/history/{prompt_id} - Retrieve results: GET images from
/viewendpoint using history data
Example: Basic API Usage
Next Steps
Queue Prompts
Learn how to submit workflows for execution
View History
Retrieve execution results and outputs
Manage Queue
Control the execution queue