comfyanonymous/ComfyUI
api_server/
The /internal/* HTTP route mount. Tiny (180 lines) but explicitly carved out from the main server.py because these routes are not part of the public ComfyUI API — they exist only to serve the official frontend.
Layout
api_server/
├── __init__.py
├── routes/
│ ├── __init__.py
│ └── internal/
│ ├── __init__.py
│ ├── README.md
│ └── internal_routes.py # Routes mounted at /internal/*
├── services/
│ └── ... (e.g., terminal_service.py, used by /internal/logs)
└── utils/Why "internal"?
The README inside the directory and the docstring on the InternalRoutes class say it plainly:
"The endpoints here should NOT be depended upon. It is for ComfyUI frontend use only."
The contract for these routes is "whatever the bundled frontend needs." They can change shape between releases without warning. Custom UIs and external integrations should consume the public routes mounted on PromptServer directly (/prompt, /queue, /history, /object_info, /system_stats, etc.).
What lives there
From api_server/routes/internal/internal_routes.py:
| Route | Method | What it does |
|---|---|---|
/internal/logs |
GET | Returns concatenated log text (used by the frontend log panel) |
/internal/logs/raw |
GET | Returns structured log entries + terminal size |
/internal/logs/subscribe |
PATCH | Subscribe/unsubscribe a clientId from log streaming |
/internal/folder_paths |
GET | Returns the model folder registry (folder_names_and_paths keys → paths) |
/internal/files/{directory_type} |
GET | Lists files in output, input, or temp, sorted by mtime descending |
How it mounts
server.PromptServer constructs an InternalRoutes and mounts its sub-app at /internal. The sub-app uses its own web.RouteTableDef so internal routes share no decorators or middleware with the public ones beyond the global stack.
Services
api_server/services/ holds helpers used by internal routes that aren't HTTP themselves. TerminalService for example tracks terminal width/height for the log streamer and relays log lines to subscribed WebSocket clients.
Integration points
- Imported and instantiated by
server.py. - Reads from
folder_paths.pyandapp/logger.py.
Where to start a change
- A new frontend-only route goes here. Define it on the
RouteTableDef, document the request/response shape inapi_server/routes/internal/README.md, and ensure the frontend has a corresponding consumer. - A route that should be part of the public API does not go here. Add it to
server.pyinstead, where it joins the documented surface and gets the standard middleware.
Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.