fabricatio_comfyui.models.comfyui

Typed Pydantic models for the ComfyUI HTTP API.

Every response from the ComfyUI server is deserialized into one of these models, eliminating raw Dict[str, Any] propagation.

Classes

ComfyuiNodeRef

Reference to another node's output in a workflow graph.

PromptRequest

Request body for POST /prompt.

ViewImageParams

Query parameters for GET /view.

PromptResponse

Response from POST /prompt.

QueueEntry

A single item in the execution queue.

QueueInfo

Response from GET /queue.

HistoryStatus

Execution status within a history entry.

ComfyuiOutputImage

Metadata for a single generated output image.

HistoryNodeOutput

Output from a single node in the execution history.

HistoryEntry

A single entry from GET /history/{prompt_id}.

ComfyuiExecutionResult

Final result of a workflow execution.

UploadResponse

Response from POST /upload/image.

SystemStats

Response from GET /system_stats.

Module Contents

class fabricatio_comfyui.models.comfyui.ComfyuiNodeRef(/, **data: Any)

Bases: pydantic.BaseModel

Reference to another node’s output in a workflow graph.

Used as a value in node inputs to wire nodes together. Serialized to the ComfyUI API list format [node_id, output_index].

model_config

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

node_id: str

The source node ID.

output_index: int = 0

The output index on the source node (default 0).

to_list() list[str | int]

Serialize to [node_id, output_index].

class fabricatio_comfyui.models.comfyui.PromptRequest(/, **data: Any)

Bases: pydantic.BaseModel

Request body for POST /prompt.

model_config

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

prompt: Dict[str, Any]

The ComfyUI workflow graph (node_id -> class_type + inputs).

client_id: str | None = None

WebSocket client ID for progress tracking.

front: bool = False

If True, enqueue at the front of the queue.

class fabricatio_comfyui.models.comfyui.ViewImageParams(/, **data: Any)

Bases: pydantic.BaseModel

Query parameters for GET /view.

model_config

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

filename: str

Image filename on the server.

subfolder: str = ''

Subfolder within the output directory.

type: str = 'output'

output, input, or temp.

Type:

Directory type

to_params() Dict[str, str]

Serialize to query parameter dict.

class fabricatio_comfyui.models.comfyui.PromptResponse(/, **data: Any)

Bases: pydantic.BaseModel

Response from POST /prompt.

model_config

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

prompt_id: str

UUID assigned to the queued prompt.

number: int = 0

Queue position number.

node_errors: Dict[str, Any] = None

Per-node validation errors (empty when valid).

classmethod from_raw(data: Dict[str, Any]) Self

Deserialize from the raw POST /prompt response.

class fabricatio_comfyui.models.comfyui.QueueEntry(/, **data: Any)

Bases: pydantic.BaseModel

A single item in the execution queue.

ComfyUI returns queue entries as tuples: [number, prompt_id, prompt, extra_data, outputs_to_execute]. This model deserializes that tuple.

model_config

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

number: int

Queue position.

prompt_id: str

Prompt UUID.

prompt: Dict[str, Any] = None

The workflow graph submitted.

extra_data: Dict[str, Any] = None

Extra metadata submitted with the prompt.

outputs_to_execute: List[str] = None

Node IDs that will be executed.

classmethod from_tuple(entry: list[Any]) Self

Deserialize from the ComfyUI queue tuple format.

class fabricatio_comfyui.models.comfyui.QueueInfo(/, **data: Any)

Bases: pydantic.BaseModel

Response from GET /queue.

model_config

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

queue_running: List[QueueEntry] = None

Currently executing prompts.

queue_pending: List[QueueEntry] = None

Prompts waiting to execute.

classmethod from_raw(data: Dict[str, Any]) Self

Deserialize from the raw API response.

class fabricatio_comfyui.models.comfyui.HistoryStatus(/, **data: Any)

Bases: pydantic.BaseModel

Execution status within a history entry.

model_config

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

status_str: str = 'unknown'

completed, failed, error, etc.

Type:

Human-readable status

completed: bool = False

Whether execution finished (success or failure).

exception: str | None = None

Exception message if execution failed.

class fabricatio_comfyui.models.comfyui.ComfyuiOutputImage(/, **data: Any)

Bases: pydantic.BaseModel

Metadata for a single generated output image.

model_config

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

filename: str

Image filename on the server.

subfolder: str = ''

Subfolder within the output directory.

type: str = 'output'

output, input, or temp.

Type:

Directory type

property url_path: str

Query string for the /view endpoint.

class fabricatio_comfyui.models.comfyui.HistoryNodeOutput(/, **data: Any)

Bases: pydantic.BaseModel

Output from a single node in the execution history.

model_config

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

images: List[ComfyuiOutputImage] = None

Images produced by this node.

class fabricatio_comfyui.models.comfyui.HistoryEntry(/, **data: Any)

Bases: pydantic.BaseModel

A single entry from GET /history/{prompt_id}.

model_config

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

status: HistoryStatus = None

Execution status.

outputs: Dict[str, HistoryNodeOutput] = None

Per-node outputs keyed by node ID.

classmethod from_raw(data: Dict[str, Any]) Self

Deserialize from a single history entry dict.

classmethod from_history_response(response: Dict[str, Any], prompt_id: str) Self | None

Look up a prompt_id in a GET /history/{prompt_id} response.

Returns:

A HistoryEntry if found, None otherwise.

class fabricatio_comfyui.models.comfyui.ComfyuiExecutionResult(/, **data: Any)

Bases: pydantic.BaseModel

Final result of a workflow execution.

model_config

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

prompt_id: str

UUID of the executed prompt.

outputs: Dict[str, List[ComfyuiOutputImage]] = None

Output images keyed by node ID.

status: str | None = None

Execution status string.

error: str | None = None

Error message if execution failed.

property all_images: list[ComfyuiOutputImage]

Flatten all output images across all nodes.

property succeeded: bool

Whether the execution completed without error.

class fabricatio_comfyui.models.comfyui.UploadResponse(/, **data: Any)

Bases: pydantic.BaseModel

Response from POST /upload/image.

model_config

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

name: str

Uploaded filename.

subfolder: str = ''

Subfolder where the file was stored.

type: str = 'input'

Directory type.

classmethod from_raw(data: Dict[str, Any]) Self

Deserialize from the raw API response.

class fabricatio_comfyui.models.comfyui.SystemStats(/, **data: Any)

Bases: pydantic.BaseModel

Response from GET /system_stats.

model_config

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

system: Dict[str, Any] = None

OS, RAM, Python/PyTorch versions, etc.

Type:

System info

devices: List[Dict[str, Any]] = None

GPU/device information.