Skip to main content

A Python API client for ComfyUI to generate images through WebSocket and HTTP requests.

Project description

comfyui-api-client

A Python API client for ComfyUI, allowing image generation via WebSocket and HTTP requests.

Installation

You can install comfyui-api-client using pip:

pip install comfyui-api-client

This will install the package and its dependencies: Pillow, websocket-client, and requests-toolbelt.

Usage

This API client interacts with a running ComfyUI server. Ensure your server is running and accessible, usually at 127.0.0.1:8188 if running locally. You may need to adjust the server_address within the client code if your server is running at a different address. The client communicates with the /ws endpoint of your ComfyUI server.

Basic Example (Text to Image)

This example demonstrates basic text-to-image generation using the text2img function. More detailed examples and usage instructions will be added in future updates. This assumes you have a basic understanding of ComfyUI workflows and how to structure prompts and parameters. For more advanced usage, refer to the basic_api.py example provided in the repository.

from comfyui_api_client import text2img

# Example usage (replace with your actual prompt and parameters)
prompt = "A majestic dragon flying through the clouds."
parameters = {
    # ... your ComfyUI parameters ...
}

try:
    images = text2img(prompt, parameters, server_address="127.0.0.1:8188")  # Adjust server address if needed
    if images:
        for i, image in enumerate(images):
            image.save(f"output_{i}.png")
        print("Images generated successfully!")
    else:
        print("Image generation failed or returned no images.")
except Exception as e:
    print(f"An error occurred: {e}")

Development

For development and contribution, clone the repository and install the dependencies:

git clone https://github.com/yourusername/comfyui-api-client  # Replace with your repository URL
cd comfyui-api-client
pip install -r requirements.txt

Contributing

Contributions are welcome! Please open an issue or submit a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for details.

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_api_client-0.1.1a0.tar.gz (8.8 kB view details)

Uploaded Source

Built Distribution

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

comfyui_api_client-0.1.1a0-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file comfyui_api_client-0.1.1a0.tar.gz.

File metadata

  • Download URL: comfyui_api_client-0.1.1a0.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.14

File hashes

Hashes for comfyui_api_client-0.1.1a0.tar.gz
Algorithm Hash digest
SHA256 8fd37760379bbc8370edea43de4ef2b39e4b88cd55628cf31d3230c24a004880
MD5 385f4561bb10c68617af95260b3bde6b
BLAKE2b-256 25d31eb56bdf3ed8ebb5ba8ad15cbcbda533171aedc312383cbf490412bbc017

See more details on using hashes here.

File details

Details for the file comfyui_api_client-0.1.1a0-py3-none-any.whl.

File metadata

File hashes

Hashes for comfyui_api_client-0.1.1a0-py3-none-any.whl
Algorithm Hash digest
SHA256 2c4bd8fb5406aa3ed78cebd8947c278b7cc780c6466fc8f264b23909f11067e3
MD5 4eebba1aec4525fbd22b032534520ad3
BLAKE2b-256 f7928c5b4400dd39246b6e263d053afb8bb93968cf2abced1152f1efd7819633

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