Starting the Server
When you launch ComfyUI, it automatically starts an HTTP server athttp://127.0.0.1:8188.
To run ComfyUI as a headless server (no browser):
Key Pages in This Section
Startup Flags
Complete reference for all main.py command-line arguments.
API Routes
Available HTTP endpoints for submitting workflows, uploading files, and querying status.
API Examples
Code examples for calling the API: HTTP-only, WebSocket + History, and SaveImageWebsocket.
Server Messages
WebSocket message types the server sends to the client during execution.
Execution Model Inversion
Advanced: invert execution for custom control flows.
Using Partner Nodes
If your workflow contains paid Partner Nodes, you can include your API key in the payload. See the Partner Node API Integration guide for details.How the Server Works
The Comfy server runs on top of the aiohttp framework, which in turn uses asyncio. Messages from the server to the client are sent by socket messages through thesend_sync method of the server, which is an instance of PromptServer (defined in server.py). They are processed by a socket event listener registered in api.js. See messages.
Messages from the client to the server are sent by the api.fetchApi() method defined in api.js, and are handled by HTTP routes defined by the server. See routes.