fabricatio_comfyui.http_client
HTTP-only ComfyUI client.
Owns the httpx.AsyncClient lifecycle and all REST endpoints.
Classes
Async HTTP client for the ComfyUI REST API. |
Module Contents
- class fabricatio_comfyui.http_client.ComfyuiHTTPClient
Async HTTP client for the ComfyUI REST API.
Manages an
httpx.AsyncClientconnection pool. Use as an async context manager or callopen()/close()manually.Always instantiate via
create(); direct construction is internal.- source: httpx.AsyncClient
- static create(base_url: str | None = None) ComfyuiHTTPClient
Build a client from the global
comfyui_config.
- async post(path: str, *, json_data: Dict[str, Any] | None = None, data: bytes | None = None, files: Dict[str, Any] | None = None, timeout: float | None = None) Dict[str, Any]
Send a POST request and return the JSON response.
- async get(path: str, *, params: Dict[str, str] | None = None, timeout: float | None = None) Any
Send a GET request; return bytes for binary content, JSON otherwise.
- async upload(path: str, *, files: Dict[str, Any], data: Dict[str, str] | None = None, timeout: float | None = None) Dict[str, Any]
Upload files via multipart POST and return the JSON response.
- async queue_prompt(workflow: Dict[str, Any] | fabricatio_comfyui.models.workflow.Workflow, **kwargs: Unpack[fabricatio_comfyui.models.kwargs_types.QueueKwargs]) fabricatio_comfyui.models.comfyui.PromptResponse
Submit a workflow for execution via
POST /prompt.
- async get_queue_info() fabricatio_comfyui.models.comfyui.QueueInfo
Get current queue status via
GET /queue.
- async get_history(prompt_id: str) fabricatio_comfyui.models.comfyui.HistoryEntry | None
Get execution history via
GET /history/{prompt_id}.
- async get_image(filename: str, **kwargs: Unpack[fabricatio_comfyui.models.kwargs_types.ViewImageKwargs]) bytes
Download a generated image via
GET /view.
- async upload_image(image_path: str | pathlib.Path, **kwargs: Unpack[fabricatio_comfyui.models.kwargs_types.UploadKwargs]) fabricatio_comfyui.models.comfyui.UploadResponse
Upload an image via
POST /upload/image.
- async wait_for_completion(prompt_id: str, **kwargs: Unpack[fabricatio_comfyui.models.kwargs_types.PollKwargs]) fabricatio_comfyui.models.comfyui.ComfyuiExecutionResult
Poll
GET /history/{prompt_id}until completion.
- async generate(workflow: Dict[str, Any] | fabricatio_comfyui.models.workflow.Workflow, **kwargs: Unpack[fabricatio_comfyui.models.kwargs_types.GenerateKwargs]) fabricatio_comfyui.models.comfyui.ComfyuiExecutionResult
Queue a workflow and poll until completion, optionally downloading images.
- Parameters:
workflow – A workflow graph dict or
Workflow.**kwargs – See
GenerateKwargs.
- async download_images(result: fabricatio_comfyui.models.comfyui.ComfyuiExecutionResult, download_dir: str | pathlib.Path) None
Download all output images to download_dir concurrently.