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가 실행 중이 아니면 요청이 실패하므로 먼저 서버 상태를 확인하세요.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

comfyui_python_client-0.1.3.tar.gz (8.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

comfyui_python_client-0.1.3-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file comfyui_python_client-0.1.3.tar.gz.

File metadata

  • Download URL: comfyui_python_client-0.1.3.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using 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}

File hashes

Hashes for comfyui_python_client-0.1.3.tar.gz
Algorithm Hash digest
SHA256 d9b1d4b5b8a7b021e2b1f6ea99857d2664c274dd9cc564229278997be2e93cf2
MD5 8012de030578d4410c6363b9a0d26444
BLAKE2b-256 db8f6d1e208007fc7d501f15240b91ad10b4d26f88eceaff680b402624ae7f97

See more details on using hashes here.

File details

Details for the file comfyui_python_client-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: comfyui_python_client-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 10.2 kB
  • Tags: Python 3
  • Uploaded using 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}

File hashes

Hashes for comfyui_python_client-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 9b653973b83a018d7744f3a82e21f055756d8269c399e96e9dcef8876b4096e9
MD5 b952701525c58cf2ecb7c2bcca4ed027
BLAKE2b-256 f550d46cbad9b9fce3b67bf09af5865430c97b6de903f71dffb1a747e65c20c7

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

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