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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file comfyui_api_client-0.1.0.tar.gz.
File metadata
- Download URL: comfyui_api_client-0.1.0.tar.gz
- Upload date:
- Size: 8.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
818e499e6003e48166e302d8a82f76c2673b8297e54e11916ab6b5391dace4e2
|
|
| MD5 |
96cc70b29948e4992179d851704fb6ee
|
|
| BLAKE2b-256 |
65b1dd910ab9e911c701ef4c09f89ef9b51f0276867d75d1c3e4d04e7971b921
|
File details
Details for the file comfyui_api_client-0.1.0-py3-none-any.whl.
File metadata
- Download URL: comfyui_api_client-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9463f35f2dd79c0480f790439f75622262427770d377d82406c3b1e8a6b7cb03
|
|
| MD5 |
513f0d6876ec3fdf9934395f1c443301
|
|
| BLAKE2b-256 |
b20a9d04a0c2f0a1c62d61bb3f15dcc6a1dd530dd8b48dec5420fa6f850af2d8
|