Extensions/comfyui-fal-flux-2-John
ComfyUI Extension

comfyui-fal-flux-2-John

Custom nodes for ComfyUI that integrate with fal.ai's FLUX 2 and FLUX 1 LoRA APIs for text-to-image generation.

By johninthewinter·Created 8 months ago·Updated 8 months ago· 0
johninthewinter/comfyui-fal-flux-2-John
Nodes
On cloudLocal install
Stars0
Updated8 months ago
Readme

ComfyUI fal.ai FLUX 2 Custom Nodes

Custom nodes for ComfyUI/RunComfy that integrate with fal.ai's FLUX 2 and FLUX 1 LoRA APIs.

🚀 Features

Standard Nodes

| Node | Description | Endpoint | |------|-------------|----------| | FLUX.2 [dev] | Text-to-image with FLUX.2 | fal-ai/flux-2 | | FLUX.2 PRO | Premium quality FLUX.2 | fal-ai/flux-2-pro | | FLUX.2 [dev] + LoRA | Text-to-image with LoRA support | fal-ai/flux-2/lora | | FLUX.2 LoRA Weight | Helper to chain multiple LoRAs | - | | FLUX.1 [dev] + LoRA | Original FLUX.1 with LoRA | fal-ai/flux-lora |

📝 JSON Structured Prompting Nodes (NEW!)

| Node | Description | Endpoint | |------|-------------|----------| | FLUX.2 [dev] JSON | Structured prompting with intuitive fields | fal-ai/flux-2 | | FLUX.2 PRO JSON | Premium with structured prompting | fal-ai/flux-2-pro | | FLUX.2 [dev] + LoRA JSON | LoRA + structured prompting | fal-ai/flux-2/lora | | FLUX.1 [dev] + LoRA JSON | FLUX.1 with structured prompting | fal-ai/flux-lora |

FLUX.2 Capabilities

  • 🎨 Enhanced realism and crisper text generation
  • 📐 Supports resolutions up to 2048x2048
  • 🎯 JSON structured prompts for precise control
  • 🎨 HEX color code control
  • 🖼️ Multi-image referencing with @ syntax
  • ⚡ Acceleration modes (regular, high)
  • 🔧 LoRA fine-tuning support

📦 Installation

Method 1: ComfyUI Manager (Recommended)

  1. Open ComfyUI Manager
  2. Search for "fal flux" or install from Git URL:
    https://github.com/YOUR_USERNAME/comfyui-fal-flux2
    

Method 2: Manual Installation

# Navigate to ComfyUI custom nodes directory
cd ComfyUI/custom_nodes

# Clone this repository
git clone https://github.com/YOUR_USERNAME/comfyui-fal-flux2.git

# Install dependencies
cd comfyui-fal-flux2
pip install -r requirements.txt

# Restart ComfyUI

Method 3: Direct Copy

  1. Download/copy the entire comfyui-fal-flux2 folder
  2. Place it in ComfyUI/custom_nodes/
  3. Install dependencies:
    pip install requests Pillow numpy torch
    
  4. Restart ComfyUI

🔑 API Key Setup

You need a fal.ai API key. Get one at: https://fal.ai/dashboard/keys

Option A: Environment Variable (Recommended)

Linux/Mac:

export FAL_KEY="your-api-key-here"

Add to your .bashrc or .zshrc for persistence:

echo 'export FAL_KEY="your-api-key-here"' >> ~/.bashrc
source ~/.bashrc

Windows (Command Prompt):

setx FAL_KEY "your-api-key-here"

Windows (PowerShell):

[Environment]::SetEnvironmentVariable("FAL_KEY", "your-api-key-here", "User")

Option B: Direct Input

Enter your API key directly in the node's api_key field. ⚠️ Less secure - your key will be visible in saved workflows.


🎛️ Node Parameters

FLUX.2 [dev] (FalFlux2)

| Parameter | Type | Default | Description | |-----------|------|---------|-------------| | prompt | string | - | Your text prompt (required) | | api_key | string | env | fal.ai API key | | image_size | enum | landscape_4_3 | Preset sizes or "custom" | | custom_width | int | 1024 | Width when size is "custom" (512-2048) | | custom_height | int | 768 | Height when size is "custom" (512-2048) | | guidance_scale | float | 2.5 | Prompt adherence (0-20) | | num_inference_steps | int | 28 | Denoising steps (1-100) | | seed | int | -1 | Random seed (-1 for random) | | num_images | int | 1 | Batch size (1-4) | | acceleration | enum | regular | Speed mode: none/regular/high | | enable_prompt_expansion | bool | false | Auto-enhance prompts | | enable_safety_checker | bool | true | NSFW filter | | output_format | enum | png | png/jpeg/webp |

FLUX.2 [dev] + LoRA (FalFlux2LoRA)

Same as above, plus:

| Parameter | Type | Default | Description | |-----------|------|---------|-------------| | loras | FAL_LORA_LIST | - | Connect LoRA Weight nodes | | lora_url_1 | string | "" | Direct LoRA URL | | lora_scale_1 | float | 1.0 | LoRA 1 strength (0-2) | | lora_url_2 | string | "" | Second LoRA URL | | lora_scale_2 | float | 1.0 | LoRA 2 strength (0-2) |

FLUX.2 LoRA Weight (FalFlux2LoRAWeight)

| Parameter | Type | Default | Description | |-----------|------|---------|-------------| | lora_url | string | "" | URL to .safetensors file | | scale | float | 1.0 | Weight scale (0-2) | | previous_loras | FAL_LORA_LIST | - | Chain input for multiple LoRAs |


📐 Image Size Presets

| Preset | Resolution | |--------|------------| | square_hd | 1024×1024 | | square | 512×512 | | portrait_4_3 | 768×1024 | | portrait_16_9 | 576×1024 | | landscape_4_3 | 1024×768 | | landscape_16_9 | 1024×576 | | custom | User-defined (512-2048) |


💡 Usage Examples

Basic Text-to-Image

Prompt: "A majestic lion in the African savanna at golden hour, 
         dramatic lighting, wildlife photography, 8K resolution"

Using LoRAs

Method 1: Direct URLs

  • Set lora_url_1 to your LoRA safetensors URL
  • Adjust lora_scale_1 (default 1.0)

Method 2: Chained LoRA Nodes

  1. Add multiple FLUX.2 LoRA Weight nodes
  2. Connect them in series via previous_loras
  3. Connect final output to FLUX.2 + LoRA node's loras input

JSON Structured Prompts (NEW! 📝)

The new JSON nodes provide an intuitive, field-based approach to building prompts:

Two Modes:

  1. Text Mode - Traditional text prompt (same as standard nodes)
  2. JSON Structured Mode - Fill in individual fields that get intelligently combined

Structured Fields:

| Field | Description | Example | |-------|-------------|---------| | subject | Main subject/scene | "a majestic knight in full armor" | | style | Artistic style | "cinematic photography" | | lighting | Lighting setup | "dramatic sunset lighting" | | camera | Camera settings | "50mm lens, f/1.8" | | composition | Framing | "close-up shot" | | colors | Color palette | "warm golden and orange tones" | | mood | Atmosphere | "epic and heroic" | | details | Quality terms | "highly detailed, 8k, sharp focus" |

How It Works:

The node automatically builds a well-structured prompt from your inputs:

Input Fields:

  • Subject: "a vintage red sports car"
  • Style: "professional automotive photography"
  • Lighting: "golden hour sunlight"
  • Camera: "35mm lens, wide angle"
  • Colors: "vibrant reds and warm tones"
  • Details: "4K, highly detailed"

Generated Prompt:

a vintage red sports car, in professional automotive photography style, 35mm lens, wide angle, with golden hour sunlight, vibrant reds and warm tones color palette, 4K, highly detailed

Benefits:

Intuitive - No need to write complex prompts manually ✅ Consistent - Fields ensure proper structure every time ✅ Flexible - Leave any field empty, only use what you need ✅ Switchable - Toggle to text mode for traditional prompting ✅ Learnable - Great for beginners learning prompt structure

HEX Color Control

Include HEX codes in your prompt:

"A sports car in color #FF4500 with accents in hex #1A1A1A"

💰 Pricing (fal.ai)

| Endpoint | Price | |----------|-------| | FLUX.2 [dev] | $0.012/megapixel | | FLUX.2 [dev] + LoRA | $0.021/megapixel | | FLUX.1 + LoRA | $0.035/megapixel |

1 megapixel ≈ 1024×1024 image


🔧 Troubleshooting

"FAL_KEY not found"

  • Set the FAL_KEY environment variable, OR
  • Enter your API key in the node's api_key field

"Request failed" / Timeout

  • Check your internet connection
  • Verify your API key is valid at https://fal.ai/dashboard
  • fal.ai may have temporary service issues

Images not loading

  • Ensure you have requests and Pillow installed
  • Check if the returned URLs are accessible

"No module named 'nodes'"

  • Ensure the folder structure is correct:
    ComfyUI/custom_nodes/comfyui-fal-flux2/
    ├── __init__.py
    ├── nodes.py
    └── requirements.txt
    

📚 API Reference


📄 License

MIT License - Use freely in personal and commercial projects.


🙏 Credits