A custom node for ComfyUI that integrates with Black Forest Labs FLUX API, providing access to FLUX's image generation and finetuning capabilities.
Core Features:
- Support for FLUX 1.1 [pro] regular and Ultra modes
- Optional Raw mode for more natural-looking images
- Multiple aspect ratios support
- Configurable safety tolerance
- Support for both JPEG and PNG output formats
- Seed support for reproducible results
Additional Capabilities:
- Complete finetuning system integration
- Model customization options
- Training mode selection (character/product/style/general)
- Inference with adjustable strength
- Comprehensive error handling
- ComfyUI
- Black Forest Labs API key
- Python packages:
- requests
- Pillow
- numpy
- torch
- Create a folder in your
ComfyUI/custom_nodes/
directory namedComfyUI_Flux_1.1_RAW_API
- Copy the files from this repository into that folder
- Create a
config.ini
file in the same directory with your FLUX API key
Example config.ini
:
[API]
X_KEY=your_api_key_here
BASE_URL=https://api.bfl.ai/
- Main Website: Black Forest Labs
- API Portal: https://api.us1.bfl.ai/auth/login
- Create an account on the API Portal
- Generate your API key from the dashboard
- Create a
config.ini
file in your node directory with your API key (see Installation section)
- Short ($2): < 150 steps - For fast exploration
- Medium ($4): 150-500 steps - For standard use cases
- Long ($6): > 500 steps - For difficult tasks and extreme precision
- FLUX 1.1 Pro Ultra Finetuned: $0.07 per image
- FLUX 1.1 Pro Ultra: $0.06 per image - Best for photo-realistic images at 2k resolution
- FLUX 1.1 Pro: $0.04 per image - Efficient for large-scale generation
- FLUX.1 Pro: $0.05 per image - Original pro model
- FLUX.1 Dev: $0.025 per image - Distilled model
- prompt: Text prompt describing the desired image
- ultra_mode: Enable Ultra mode for higher resolution output
- aspect_ratio: Choose from multiple aspect ratios:
- 21:9 (Ultrawide)
- 16:9 (Widescreen)
- 4:3 (Standard)
- 1:1 (Square)
- 3:4 (Portrait)
- 9:16 (Vertical)
- 9:21 (Tall)
- safety_tolerance: 0-6 (0 being most strict, 6 being least strict)
- output_format: Choose between JPEG and PNG
- raw: Enable Raw mode for less processed, more natural-looking images
- seed: Optional seed for reproducible results (-1 for random)
Regular Mode
- Resolution based on aspect ratio (up to 1440px)
- Standard image processing
Ultra Mode
- Higher resolution output (up to 4MP)
- Support for Raw mode
- Advanced image processing
- Add the "Flux Pro 1.1 Ultra & Raw with Finetuning" node to your workflow
- Set mode to "generate"
- Enter your prompt
- Configure desired settings (aspect ratio, safety tolerance, etc.)
- Connect to a Preview Image node to see results
-
Prepare your training data:
- Create a folder with 5-20 images (JPG, JPEG, PNG, or WebP)
- Optionally add text descriptions (same filename but .txt extension)
- Compress the folder into a ZIP file
-
Training:
- Set mode to "finetune"
- Provide path to your ZIP file
- Set finetune parameters:
finetune_comment
: Description of your modelfinetune_mode
: character/product/style/generaltrigger_word
: Word to reference your concept (default: "TOK")- Adjust other parameters as needed
-
Using Finetuned Models:
- Set mode to "inference"
- Input your finetune_id
- Use the trigger word in your prompt
- Adjust finetune_strength if needed (default: 1.2)
mode
: generate/finetune/inferenceprompt
: Text description of desired imageultra_mode
: Enable/disable ultra modeaspect_ratio
: 21:9, 16:9, 4:3, 1:1, 3:4, 9:16, 9:21safety_tolerance
: 0-6output_format
: jpeg/pngraw
: Enable raw mode for extra realismseed
: Set specific seed (-1 for random)
finetune_zip
: Path to training data ZIPfinetune_comment
: Model descriptionfinetune_id
: ID for inference modetrigger_word
: Concept reference wordfinetune_mode
: character/product/style/generaliterations
: Training steps (min: 100)learning_rate
: Training rate (default: 0.00001)captioning
: Auto-caption imagespriority
: speed/qualityfinetune_type
: full/loralora_rank
: 16 or 32finetune_strength
: 0-2 (default: 1.2)
- Use high-quality training images
- For character training, avoid multiple characters in single images
- For style training, try higher finetune_strength values
- If concept isn't showing strongly, increase finetune_strength
- If seeing artifacts, decrease finetune_strength
- Be specific in your prompts
- Use raw mode for more photorealistic results
- Adjust safety_tolerance based on your needs
- Consider aspect ratio for your use case
Common issues:
-
"Error: X_KEY not found in section API of config file"
- Check if your
config.ini
file exists and is properly formatted - Verify the API key is correctly copied without extra spaces
- Make sure the file is in the correct directory
- Check if your
-
"404 Not Found" error
- Verify your API key is valid and active
- Check if you have access to the FLUX 1.1 API
- Make sure your account is in good standing
The node includes comprehensive error handling:
- Network errors return a blank image
- Invalid API keys are caught and reported
- Missing files generate appropriate errors
- Training/inference errors are logged with details
Feel free to submit issues and enhancement requests!
- FLUX API team for their powerful image generation capabilities
- ComfyUI community for the node framework