Routes
The server defines a series ofget and post methods
which can be found by searching for @routes in server.py. When you submit a workflow
in the web client, it is posted to /prompt which validates the prompt and adds it to an execution queue,
returning either a prompt_id and number (the position in the queue), or error and node_errors if validation fails.
The prompt queue is defined in execution.py, which also defines the PromptExecutor class.
Built in routes
server.py defines the following routes:
Core API Routes
Assets API
The Assets API (/api/assets) provides a unified, tag-based system for managing files (images, models, outputs) with content-addressed storage and metadata support. It is the recommended way to upload, organize, and retrieve files.
List Assets
GET /api/assets returns a paginated list of assets with optional filtering:
Response:
Upload Asset
POST /api/assets uploads a new asset (multipart/form-data):
Get Asset Details
GET /api/assets/{id} returns full details for a specific asset.
Download Asset Content
GET /api/assets/{id}/content downloads the asset file with appropriate Content-Type and Content-Disposition headers.
The Assets API uses content-addressed storage with Blake3 hashes, meaning identical files are automatically deduplicated. Tags provide flexible organization without rigid folder hierarchies.
WebSocket Communication
The/ws endpoint provides real-time bidirectional communication between the client and server. This is used for:
- Receiving execution progress updates
- Getting node execution status in real-time
- Receiving error messages and debugging information
- Live updates when queue status changes
status- Overall system status updatesexecution_start- When a prompt execution beginsexecution_cached- When cached results are usedexecuting- Updates during node executionprogress- Progress updates for long-running operationsexecuted- When a node completes execution
Custom routes
If you want to send a message from the client to the server during execution, you will need to add a custom route to the server. For anything complicated, you will need to dive into the aiohttp framework docs, but most cases can be handled as follows:FormData object with code something like this,
which would result in the_data, in the above code, containing message and node_id keys: