Skip to main content

Add your description here

Project description

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

Project details


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.2.tar.gz (8.0 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.2-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: comfyui_python_client-0.1.2.tar.gz
  • Upload date:
  • Size: 8.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","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.2.tar.gz
Algorithm Hash digest
SHA256 c7894cf44fea8217218c11bf98e4b40a6a5f9ca2c57e4a455eb2816dcc31f404
MD5 38fbdde05eb81d23987448dd825c21d6
BLAKE2b-256 89fc6467e9aa03e20ca311dfdd833bacf6b1b6de2ae140548c955d79cbb85d3e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: comfyui_python_client-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 10.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 bb245e62bb20545092253103089f4a81ac5eca4bb467ce48816045933e88703e
MD5 b76948b11bcf54f7e85429ae3805e017
BLAKE2b-256 9d16498fa4f4fbe2bc01399466793a76afbf3233c83bfd121e58e41b11dadd3f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page