ComfyUI Extension: ComfyUI-Flux2proReplicate
Set of custom nodes for ComfyUI that generates images using the Flux 2 Pro model via Replicate API with flexible aspect ratios and secure API key management. (Description by CC)
Custom Nodes (0)
README
ComfyUI-Flux2proReplicate
A set of custom nodes for ComfyUI that allows you to generate images using the Flux 2 Pro model via the Replicate API.
Features
- Flux 2 Pro Generation: Access the powerful Flux 2 Pro model directly within ComfyUI.
- Flexible Aspect Ratios: Choose from standard aspect ratios (16:9, 1:1, 9:16, etc.) or define custom dimensions.
- Secure API Key Management: Loads your Replicate API key from a local file to avoid hardcoding it in workflows.
- Image Input Support: Supports up to 10 input images for workflows that require image guidance.
- Debug Output: Returns the JSON payload sent to Replicate for easy debugging.
Installation
-
Clone the repository: Navigate to your ComfyUI
custom_nodesdirectory and clone this repository:cd ComfyUI/custom_nodes git clone https://github.com/yourusername/ComfyUI-Flux2proReplicate.git -
Install dependencies: Install the required Python packages:
cd ComfyUI-Flux2proReplicate pip install -r requirements.txt
Configuration
To use these nodes, you need a Replicate API token.
- Get your API token from replicate.com/account/api-tokens.
- Create a file named
replicate_api_key.txtinside theComfyUI-Flux2proReplicatefolder. - Paste your API key into that file (just the key, no extra spaces or newlines).
Note: The
replicate_api_key.txtfile is ignored by git to keep your key secure.
Nodes
1. Flux Replicate Auth (File)
Category: FluxReplicate
Reads the API key from the replicate_api_key.txt file.
- Outputs:
api_key: The loaded API key string.
2. Flux 2 Pro Generator
Category: FluxReplicate
The main node for generating images.
-
Inputs:
api_key: Connect the output from the Flux Replicate Auth node.prompt: The text prompt for image generation.aspect_ratio: Select from presets (e.g.,1:1,16:9) or choosecustom.width/height: Active only whenaspect_ratiois set tocustom.resolution: Target resolution (e.g.,1 MP,4 MP). Ignored if using custom dimensions.seed: Seed for reproducibility.safety_tolerance: Adjust safety filter strictness (1-5).output_quality: JPEG quality of the output (1-100).image_1...image_10(Optional): Input images for image-to-image or structural guidance.
-
Outputs:
IMAGE: The generated image tensor.DEBUG_PAYLOAD: A string containing the JSON payload sent to the API (useful for debugging).
Usage Example
- Add the Flux Replicate Auth (File) node.
- Add the Flux 2 Pro Generator node.
- Connect the
api_keyoutput of the Auth node to theapi_keyinput of the Generator node. - Connect your prompt and configure parameters.
- (Optional) Connect input images if needed.
- Connect the
IMAGEoutput to a Save Image or Preview Image node.
License
MIT