ComfyUI doesn't support WebSocket in CLI context. Use REST polling:
Queue workflow via
POST /prompt
→ get
prompt_id
Poll
GET /history/{prompt_id}
every
5 seconds
On empty response: generation in progress, continue polling
On populated response: check
status.completed
If
completed: true
, extract outputs
If error in status, route to
comfyui-troubleshooter
Timeout
Warn user after 10 minutes of polling. Video generation (Wan 14B) can take 15-30 minutes.
Workflow Validation
Before queuing any workflow:
Read
state/inventory.json
(via
comfyui-inventory
)
For each node in workflow: verify
class_type
exists in installed nodes
For each model reference: verify file exists in installed models
Flag missing items with:
Node: suggest
ComfyUI-Manager
install command
Model: provide download link from
references/models.md
Version mismatch: suggest update
Error Handling
Error
Cause
Action
Connection refused
ComfyUI not running
Switch to offline mode, save JSON
400 Bad Request
Invalid workflow JSON
Validate node connections
500 Internal Error
ComfyUI crash
Suggest restart, check logs
Timeout (no response)
Server overloaded
Wait and retry once
Reference
Full API documentation:
foundation/api-quick-ref.md