Skip to main content

comfyui-python-client

ComfyUI REST/WebSocket API를 Python에서 다루기 쉽게 감싼 경량 클라이언트입니다.

  • 기본 서버: 127.0.0.1:8188
  • 지원 기능: 프롬프트 실행/대기, 히스토리, 큐 제어, 이미지 업/다운로드, 시스템/모델/템플릿/사용자 API
  • 클라이언트 구성: 동기(ComfyClient/SyncComfyClient) + 비동기(AsyncComfyClient)

요구사항

  • Python >= 3.12
  • 실행 중인 ComfyUI 서버

설치

패키지 루트(packages/comfyui-python-client)에서:

pip install -e .

빠른 시작

from comfy_sdk import ComfyUI
import json

client = ComfyUI(host="127.0.0.1", port=8188)

# 1) 연결 확인
stats = client.system.stats()
print(stats)

# 2) 워크플로우 전송
with open("workflow_api.json", "r", encoding="utf-8") as f:
    workflow = json.load(f)

res = client.prompt.send(workflow)
print("prompt_id:", res.prompt_id)

# 3) 완료 대기 후 히스토리 조회
history = client.prompt.wait(res.prompt_id)
print(history)

비동기 클라이언트 예시

import asyncio
from comfy_sdk import AsyncComfyClient

async def main():
    client = AsyncComfyClient(host="127.0.0.1", port=8188)

    stats = await client.get_system_stats()
    print(stats)

    # 필요 시 워크플로우 실행/대기
    # res = await client.queue_prompt(workflow)
    # history = await client.wait_for_completion(res.prompt_id)

    await client.close()

asyncio.run(main())

API 개요

ComfyUI 인스턴스는 아래 리소스를 제공합니다.

  • client.prompt
    • send(workflow)
    • retrieve(prompt_id)
    • wait(prompt_id)
    • history(), delete(prompt_id), clear()
  • client.images
    • upload(data, name, overwrite=False)
    • download(filename, subfolder="", folder_type="output")
    • upload_mask(data, name, original_ref, overwrite=False, mask_type="mask")
    • metadata(filename, subfolder="", folder_type="output")
  • client.system
    • stats(), extensions(), embeddings(), features()
    • free(unload_models=False, free_memory=False)
  • client.queue
    • status(), interrupt(), clear()
  • client.models
    • list(folder=None) (checkpoints, loras 등)
  • client.templates
    • list()
  • client.users
    • list(), create(username)
  • client.userdata
    • get(file), move(file, dest)

이미지 업로드 예시

from comfy_sdk import ComfyUI

client = ComfyUI()

with open("input.png", "rb") as f:
    image_bytes = f.read()

result = client.images.upload(image_bytes, "input.png", overwrite=True)
print(result)

참고

  • prompt.wait(prompt_id)는 내부적으로 WebSocket(ws://<host>:<port>/ws)을 사용합니다.
  • ComfyUI가 실행 중이 아니면 요청이 실패하므로 먼저 서버 상태를 확인하세요.

Metadata

Release files for comfyui-python-client 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for comfyui-python-client 0.1.3
File Size Uploaded Provenance Actions
comfyui_python_client-0.1.3.tar.gz 8.1 kB Without provenance Details for comfyui_python_client-0.1.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for comfyui-python-client 0.1.3
File Interpreter ABI Platform Actions
comfyui_python_client-0.1.3-py3-none-any.whl Python 3 none any Details for comfyui_python_client-0.1.3-py3-none-any.whl

Total release size: 18.3 kB

Release files / comfyui_python_client-0.1.3.tar.gz

Download URL comfyui_python_client-0.1.3.tar.gz
Size 8.1 kB
Tags Source
SHA-256 checksum
How to use checksums
d9b1d4b5b8a7b021e2b1f6ea99857d2664c274dd9cc564229278997be2e93cf2
BLAKE2b-256 checksum
How to use checksums
db8f6d1e208007fc7d501f15240b91ad10b4d26f88eceaff680b402624ae7f97
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.25 {"installer":{"name":"uv","version":"0.11.25","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / comfyui_python_client-0.1.3-py3-none-any.whl

Download URL comfyui_python_client-0.1.3-py3-none-any.whl
Size 10.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9b653973b83a018d7744f3a82e21f055756d8269c399e96e9dcef8876b4096e9
BLAKE2b-256 checksum
How to use checksums
f550d46cbad9b9fce3b67bf09af5865430c97b6de903f71dffb1a747e65c20c7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.25 {"installer":{"name":"uv","version":"0.11.25","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for comfyui-python-client 0.1.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page