This bridge connects your local ComfyUI installation to the AI Power Grid, allowing it to work as an image generation worker on the distributed AI network.
The ComfyUI Bridge acts as a worker for the AI Power Grid network, receiving image generation jobs, processing them with your local ComfyUI installation, and returning the results to the network.
- Python 3.9+
- A running ComfyUI instance
- An API key from AI Power Grid
- Clone this repository or download the files
- Create a Python virtual environment (recommended):
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
- Install required packages:
pip install -r requirements.txt
Edit the .env
file to set your configuration:
# Required: Your API key from AI Power Grid
GRID_API_KEY=your_api_key_here
# Optional: Your worker name (default: ComfyUI-Bridge-Worker)
GRID_WORKER_NAME=your_worker_name
# Optional: ComfyUI URL (default: http://127.0.0.1:8000)
COMFYUI_URL=http://127.0.0.1:8000
# Optional: AI Power Grid API URL (default: https://api.aipowergrid.io/api)
GRID_API_URL=https://api.aipowergrid.io/api
# Optional: Allow NSFW content (default: false)
GRID_NSFW=true
# Optional: Number of concurrent jobs to process (default: 1)
GRID_THREADS=1
# Optional: Maximum image size in pixels (default: 1048576 = 1024x1024)
GRID_MAX_PIXELS=1048576
# Optional: Model to advertise to the grid (default: auto-detected)
GRID_MODEL=stable_diffusion_1.5
# Optional: Workflow file to use (default: api_ready_workflow.json)
WORKFLOW_FILE=api_ready_workflow.json
The GRID_MODEL
setting specifies which model your worker advertises to the AI Power Grid. This determines what types of jobs your worker will receive. Common model values include:
stable_diffusion_1.5
: Standard SD 1.5 modelstable_diffusion_2.1
: SD 2.1 modelsdxl
: SDXL 1.0 base modelsdxl-turbo
: SDXL Turbo modeljuggernaut_xl
: Juggernaut XL modelplayground_v2
: Playground v2 modeldreamshaper_8
: Dreamshaper 8 model
The bridge automatically maps these model names to your local checkpoint files. If you don't specify a model, the bridge will try to auto-detect an appropriate model from your ComfyUI installation.
- Make sure your ComfyUI instance is running
- Start the bridge:
python start_bridge.py
The bridge will connect to the AI Power Grid, register as a worker, and start processing jobs.
- The bridge registers with the AI Power Grid as a worker
- It periodically polls for available jobs
- When a job is received, it:
- Converts the job parameters to a ComfyUI workflow
- Submits the workflow to your local ComfyUI instance
- Waits for the image generation to complete
- Returns the generated image to the AI Power Grid
- The process repeats for new jobs
- ComfyUI Connection Issues: Ensure your ComfyUI instance is running and accessible at the URL specified in your
.env
file. - API Key Issues: Verify your GRID_API_KEY is correct and has sufficient permissions.
- Model Mapping Issues: The bridge maps AI Power Grid model names to your local ComfyUI models. Check the logs for any mapping errors.
- If you see "Unknown grid model" warnings, verify that you have the corresponding checkpoint file in your ComfyUI models directory.
- The bridge attempts to find a matching checkpoint even if names don't match exactly.
This project is licensed under the MIT License - see the LICENSE file for details.
- AI Power Grid for the API
- ComfyUI for the local image generation backend