fabricatio_comfyui.client
Stateful ComfyUI HTTP client.
Owns the httpx.AsyncClient lifecycle (connection pool, timeout,
close) and every API method. The capability mixin delegates here.
Classes
Stateful async ComfyUI client with persistent connection pooling. |
Module Contents
- class fabricatio_comfyui.client.ComfyuiClient
Stateful async ComfyUI client with persistent connection pooling.
Use as an async context manager:
async with ComfyuiClient.create() as client: result = await client.generate(workflow)
Or manage the lifecycle manually:
client = ComfyuiClient.create() try: result = await client.generate(workflow) finally: await client.close()
- classmethod create() ComfyuiClient
Create a client with the connection pool already open.
- classmethod cached(base_url: str = comfyui_config.base_url) ComfyuiClient
Return a shared client for base_url, creating on first access.
- async __aenter__() Self
Open the connection pool and return
self.
- async queue_prompt(workflow: Dict[str, Any], *, client_id: str | None = None, front: bool = False) fabricatio_comfyui.models.comfyui.PromptResponse
Submit a workflow for execution.
- async get_queue_info() fabricatio_comfyui.models.comfyui.QueueInfo
Get current queue status.
- async get_history(prompt_id: str) fabricatio_comfyui.models.comfyui.HistoryEntry | None
Get execution history for a prompt.
- async wait_for_completion(prompt_id: str, *, poll_interval: float = 1.0, timeout: float | None = None) fabricatio_comfyui.models.comfyui.ComfyuiExecutionResult
Poll until a prompt completes or fails.
- Raises:
TimeoutError – If the prompt does not complete within the timeout.
- async get_image(filename: str, *, subfolder: str = '', image_type: str = 'output') bytes
Download a generated image.
- async upload_image(image_path: str | pathlib.Path, *, image_type: str = 'input', overwrite: bool = True) fabricatio_comfyui.models.comfyui.UploadResponse
Upload an image to the server.
- async generate(workflow: Dict[str, Any], *, download_dir: str | pathlib.Path | None = None, client_id: str | None = None, poll_interval: float = 1.0, timeout: float | None = None) fabricatio_comfyui.models.comfyui.ComfyuiExecutionResult
Queue a workflow, wait for completion, optionally download images.