ComfyUI Extension: Flux Context ComfyUI Node
ComfyUI node for Flux Context (Kontext) image editing
Custom Nodes (0)
README
Flux Context ComfyUI Node
A ComfyUI custom node for Flux Context (Kontext) - advanced image editing and transformation using text prompts via the Replicate API.
What is Flux Context?
Flux Context (Kontext) is Black Forest Labs' state-of-the-art image editing model that allows you to transform existing images using natural language descriptions. Unlike image generation models, Flux Context specializes in:
- Style Transfer: Convert photos to different art styles (watercolor, oil painting, sketches)
- Object/Clothing Changes: Modify hairstyles, add accessories, change colors
- Text Editing: Replace text in signs, posters, and labels
- Background Swapping: Change environments while preserving subjects
- Character Consistency: Maintain identity across multiple edits
Features
- ✅ Text-based image editing using natural language prompts
- ✅ Two image inputs ("image 1" required, "image 2" optional for reference)
- ✅ Professional models: Flux Kontext Pro and Max
- ✅ API token input built into the node interface
- ✅ Multiple output formats (JPG/PNG)
- ✅ Smart image compression for API compatibility
- ✅ Error handling with automatic retry logic
Available Models
- black-forest-labs/flux-kontext-pro: State-of-the-art performance with high-quality outputs
- black-forest-labs/flux-kontext-max: Premium model with maximum performance and improved typography
Installation
Method 1: ComfyUI Manager (Recommended)
- Install ComfyUI Manager
- Search for "Flux Context" in the manager
- Install and restart ComfyUI
Method 2: Manual Installation
-
Find your ComfyUI installation directory:
# Common locations: # Windows: C:\ComfyUI\ or C:\Users\[username]\ComfyUI\ # Mac: /Applications/ComfyUI/ or ~/ComfyUI/ # Linux: ~/ComfyUI/ or /opt/ComfyUI/
-
Navigate to custom nodes directory:
cd [your-comfyui-path]/custom_nodes/
-
Clone this repository:
git clone https://github.com/leonardomiramondi/flux-context-comfyui.git
-
Install dependencies:
cd flux-context-comfyui pip install -r requirements.txt
-
Restart ComfyUI completely
Setup
-
Get a Replicate API token:
- Go to replicate.com/account/api-tokens
- Create a new token
- Copy the token (starts with
r8_
)
-
Add the node to your workflow:
- In ComfyUI, add the Flux Context Node (found under
image/editing
) - Paste your API token in the "api_token" field
- In ComfyUI, add the Flux Context Node (found under
Usage
Basic Image Editing
- Connect an image to "image 1" (required)
- Enter your editing prompt describing the desired changes
- Choose your model (Pro or Max)
- Select output format (JPG or PNG)
- Run the workflow
Reference-Style Editing
- Connect your main image to "image 1"
- Connect a reference/style image to "image 2" (optional)
- Describe the transformation in the editing prompt
- The model will use image 2 as a style reference
Example Prompts
Style Transfer:
- "Transform this into a watercolor painting"
- "Make this look like a Renaissance oil painting"
- "Convert to a pencil sketch with detailed shading"
Object Changes:
- "Change the red car to a blue motorcycle"
- "Replace the person's outfit with a business suit"
- "Add sunglasses and a hat to the person"
Background Edits:
- "Change the background to a beach scene while keeping the person"
- "Replace the indoor setting with a forest"
- "Add falling snow to this winter scene"
Text Editing:
- "Change the sign text from 'OPEN' to 'CLOSED'"
- "Replace the billboard text with 'SALE 50% OFF'"
API Requirements
- Replicate account with available credits
- Valid API token (get from replicate.com)
- Internet connection for API calls
Troubleshooting
"Invalid API token"
- Verify your token starts with
r8_
- Check you have credits in your Replicate account
- Ensure the token has proper permissions
"Image too large" errors
- The node automatically compresses large images
- Try reducing your input image resolution if issues persist
- Maximum recommended size: 2048x2048 pixels
Node not appearing
- Ensure you've restarted ComfyUI completely after installation
- Check that
requirements.txt
packages installed successfully - Verify the node files are in the correct custom_nodes directory
"Model not found" errors
- Only use the supported models (flux-kontext-pro or flux-kontext-max)
- Ensure your Replicate account has access to these models
Contributing
Feel free to submit issues, feature requests, or pull requests on the GitHub repository.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Credits
- Black Forest Labs for the Flux Context models
- Replicate for API infrastructure
- ComfyUI community for the amazing framework