{"id":19024170,"url":"https://github.com/raykitajima/comfybridge","last_synced_at":"2025-04-23T12:11:49.751Z","repository":{"id":236792875,"uuid":"793139588","full_name":"RayKitajima/ComfyBridge","owner":"RayKitajima","description":"ComfyBridge is a synchronous-style API wrapper for ComfyUI, efficiently managing image generation requests and delivering results as base64-encoded images.","archived":false,"fork":false,"pushed_at":"2024-05-18T12:12:10.000Z","size":22,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-23T12:03:39.019Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RayKitajima.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-04-28T14:41:05.000Z","updated_at":"2025-04-23T03:22:23.000Z","dependencies_parsed_at":"2024-04-28T16:45:33.520Z","dependency_job_id":"44aebba1-24d5-4aa3-8cdf-0c4a5bf12d75","html_url":"https://github.com/RayKitajima/ComfyBridge","commit_stats":null,"previous_names":["raykitajima/comfybridge"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RayKitajima%2FComfyBridge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RayKitajima%2FComfyBridge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RayKitajima%2FComfyBridge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RayKitajima%2FComfyBridge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RayKitajima","download_url":"https://codeload.github.com/RayKitajima/ComfyBridge/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250430585,"owners_count":21429324,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-08T20:35:24.563Z","updated_at":"2025-04-23T12:11:49.722Z","avatar_url":"https://github.com/RayKitajima.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ComfyBridge\n\nComfyBridge is a Python-based service that acts as a bridge to the ComfyUI API, facilitating image generation requests. It manages the lifecycle of image generation requests, polls for their completion, and returns the final image as a base64-encoded string. This wrapper is designed to simplify integration with ComfyUI for developers needing a synchronous-like behavior over an inherently asynchronous operation.\n\n## Features\n\n- **Asynchronous Handling**: Manages asynchronous image generation tasks and provides a synchronous HTTP interface to clients.\n- **Base64 Encoding**: Returns images in a base64-encoded format, ready for use in web applications or for further processing.\n- **Polling with Timeout**: Implements efficient polling with customizable timeouts to check for image generation completion.\n\n## Getting Started\n\n### Prerequisites\n\n- Python 3.6+\n- Flask\n- Requests\n- Pillow\n\n### Installation and Running\n\nClone the repository:\n\n```bash\ngit clone https://github.com/RayKitajima/ComfyBridge.git\ncd ComfyBridge\n```\n\nInstall the required packages and run the Flask application:\n\n```bash\n$ python -m venv sandbox\n$ cd sandbox/\n$ source bin/activate\n(sandbox) $ pip3 install flask requests pillow\n(sandbox) $ cd ..\n(sandbox) $ sandbox/bin/python app.py\n```\n\nTo run the Flask application with a custom timeout, use the `--timeout` option:\n\n```bash\n(sandbox) $ sandbox/bin/python app.py --timeout 30\n```\n\nThis will set the polling timeout to 30 seconds.\n\n### Running the ComfyUI API\n\nYou also need to have the ComfyUI API running on your local machine:\n\n```bash\n$ python main.py --listen\n```\n\n### Usage\n\nSend a POST request to `/generate` with the appropriate JSON payload:\n\n(Replace `\u003cseed\u003e`, `\u003cpositive prompt\u003e`, and `\u003cnegative prompt\u003e` with the desired values.)\n\n```bash\ncurl --location --request POST 'http://localhost:8189/generate' \\\n--header 'Content-Type: application/json' \\\n--data '{\n    \"prompt\": {\n        \"3\": {\n            \"inputs\": {\n                \"seed\": \u003cseed\u003e,\n                \"steps\": 20,\n                \"cfg\": 8,\n                \"sampler_name\": \"euler\",\n                \"scheduler\": \"normal\",\n                \"denoise\": 1,\n                \"model\": [\n                    \"4\",\n                    0\n                ],\n                \"positive\": [\n                    \"6\",\n                    0\n                ],\n                \"negative\": [\n                    \"7\",\n                    0\n                ],\n                \"latent_image\": [\n                    \"5\",\n                    0\n                ]\n            },\n            \"class_type\": \"KSampler\",\n            \"_meta\": {\n                \"title\": \"KSampler\"\n            }\n        },\n        \"4\": {\n            \"inputs\": {\n                \"ckpt_name\": \"\u003cmodel\u003e\"\n            },\n            \"class_type\": \"CheckpointLoaderSimple\",\n            \"_meta\": {\n                \"title\": \"Load Checkpoint\"\n            }\n        },\n        \"5\": {\n            \"inputs\": {\n                \"width\": 512,\n                \"height\": 512,\n                \"batch_size\": 1\n            },\n            \"class_type\": \"EmptyLatentImage\",\n            \"_meta\": {\n                \"title\": \"Empty Latent Image\"\n            }\n        },\n        \"6\": {\n            \"inputs\": {\n                \"text\": \"\u003cpositive prompt\u003e\",\n                \"clip\": [\n                    \"4\",\n                    1\n                ]\n            },\n            \"class_type\": \"CLIPTextEncode\",\n            \"_meta\": {\n                \"title\": \"CLIP Text Encode (Prompt)\"\n            }\n        },\n        \"7\": {\n            \"inputs\": {\n                \"text\": \"\u003cnegative prompt\u003e\",\n                \"clip\": [\n                    \"4\",\n                    1\n                ]\n            },\n            \"class_type\": \"CLIPTextEncode\",\n            \"_meta\": {\n                \"title\": \"CLIP Text Encode (Prompt)\"\n            }\n        },\n        \"8\": {\n            \"inputs\": {\n                \"samples\": [\n                    \"3\",\n                    0\n                ],\n                \"vae\": [\n                    \"4\",\n                    2\n                ]\n            },\n            \"class_type\": \"VAEDecode\",\n            \"_meta\": {\n                \"title\": \"VAE Decode\"\n            }\n        },\n        \"9\": {\n            \"inputs\": {\n                \"filename_prefix\": \"ComfyUI\",\n                \"images\": [\n                    \"8\",\n                    0\n                ]\n            },\n            \"class_type\": \"SaveImage\",\n            \"_meta\": {\n                \"title\": \"Save Image\"\n            }\n        }\n    }\n}'\n```\n\n## API Reference\n\n### POST `/generate`\n\nAccepts a JSON payload with the generation request details and returns a base64-encoded image.\n\n#### Input\n\n- `prompt`: JSON object representing the image generation prompt and configuration.\n\n#### Output\n\n- `image`: Base64-encoded string of the generated image.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraykitajima%2Fcomfybridge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fraykitajima%2Fcomfybridge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraykitajima%2Fcomfybridge/lists"}