export function getFluxWorkflow(params) {
const {
prompt,
negative_prompt = '',
width = 1024,
height = 1024,
steps = 20,
cfg_scale = 7.0,
seed = -1,
sampler_name = 'euler',
scheduler = 'normal',
} = params;
// This is a basic Flux workflow structure
// You may need to adjust node IDs and model names based on your ComfyUI setup
const workflow = {
"3": {
"inputs": {
"seed": seed === -1 ? Math.floor(Math.random() * 1000000000) : seed,
"steps": steps,
"cfg": cfg_scale,
"sampler_name": sampler_name,
"scheduler": scheduler,
"denoise": 1,
"model": ["4", 0],
"positive": ["6", 0],
"negative": ["7", 0],
"latent_image": ["5", 0]
},
"class_type": "KSampler"
},
"4": {
"inputs": {
"ckpt_name": "flux1-dev.safetensors" // Adjust this to match your Flux model filename
},
"class_type": "CheckpointLoaderSimple"
},
"5": {
"inputs": {
"width": width,
"height": height,
"batch_size": 1
},
"class_type": "EmptyLatentImage"
},
"6": {
"inputs": {
"text": prompt,
"clip": ["4", 1]
},
"class_type": "CLIPTextEncode"
},
"7": {
"inputs": {
"text": negative_prompt,
"clip": ["4", 1]
},
"class_type": "CLIPTextEncode"
},
"8": {
"inputs": {
"samples": ["3", 0],
"vae": ["4", 2]
},
"class_type": "VAEDecode"
},
"9": {
"inputs": {
"filename_prefix": "flux_output",
"images": ["8", 0]
},
"class_type": "SaveImage"
}
};
return workflow;
}
// Alternative workflow for Flux with UNET loader (if using diffusers format)
export function getFluxDiffusersWorkflow(params) {
const {
prompt,
negative_prompt = '',
width = 1024,
height = 1024,
steps = 20,
cfg_scale = 7.0,
seed = -1,
sampler_name = 'euler',
scheduler = 'normal',
batch_size = 1,
} = params;
const workflow = {
"1": {
"inputs": {
"unet_name": "flux1-schnell-fp8-e4m3fn.safetensors", // FP8 model
"weight_dtype": "default"
},
"class_type": "UNETLoader"
},
"2": {
"inputs": {
"clip_name1": "t5xxl_fp8_e4m3fn_scaled.safetensors", // T5 encoder FP8
"clip_name2": "clip_l.safetensors", // CLIP encoder
"type": "flux"
},
"class_type": "DualCLIPLoader"
},
"3": {
"inputs": {
"vae_name": "ae.safetensors" // Flux VAE
},
"class_type": "VAELoader"
},
"4": {
"inputs": {
"width": width,
"height": height,
"batch_size": batch_size
},
"class_type": "EmptyLatentImage"
},
"5": {
"inputs": {
"text": prompt,
"clip": ["2", 0]
},
"class_type": "CLIPTextEncode"
},
"6": {
"inputs": {
"text": negative_prompt,
"clip": ["2", 0]
},
"class_type": "CLIPTextEncode"
},
"7": {
"inputs": {
"seed": seed === -1 ? Math.floor(Math.random() * 1000000000) : seed,
"steps": steps,
"cfg": cfg_scale,
"sampler_name": sampler_name,
"scheduler": scheduler,
"denoise": 1,
"model": ["1", 0],
"positive": ["5", 0],
"negative": ["6", 0],
"latent_image": ["4", 0]
},
"class_type": "KSampler"
},
"8": {
"inputs": {
"samples": ["7", 0],
"vae": ["3", 0]
},
"class_type": "VAEDecode"
},
"9": {
"inputs": {
"filename_prefix": "flux_output",
"images": ["8", 0]
},
"class_type": "SaveImage"
}
};
return workflow;
}
// Flux workflow with guidance support
export function getFluxGuidanceWorkflow(params) {
const {
prompt,
width = 1024,
height = 1024,
steps = 20,
guidance = 3.5,
seed = -1,
sampler_name = 'euler',
scheduler = 'simple',
} = params;
const workflow = {
"1": {
"inputs": {
"unet_name": "flux1-dev.safetensors",
"weight_dtype": "fp8_e4m3fn"
},
"class_type": "UNETLoader"
},
"2": {
"inputs": {
"clip_name1": "t5xxl_fp8_e4m3fn.safetensors",
"clip_name2": "clip_l.safetensors",
"type": "flux"
},
"class_type": "DualCLIPLoader"
},
"3": {
"inputs": {
"vae_name": "ae.safetensors"
},
"class_type": "VAELoader"
},
"4": {
"inputs": {
"conditioning": ["6", 0],
"guidance": guidance,
"model": ["1", 0]
},
"class_type": "FluxGuidance"
},
"5": {
"inputs": {
"width": width,
"height": height,
"batch_size": 1
},
"class_type": "EmptyLatentImage"
},
"6": {
"inputs": {
"text": prompt,
"clip": ["2", 0]
},
"class_type": "CLIPTextEncode"
},
"7": {
"inputs": {
"noise": ["10", 0],
"guider": ["9", 0],
"sampler": ["8", 0],
"sigmas": ["11", 0],
"latent_image": ["5", 0]
},
"class_type": "SamplerCustomAdvanced"
},
"8": {
"inputs": {
"sampler_name": sampler_name
},
"class_type": "KSamplerSelect"
},
"9": {
"inputs": {
"model": ["4", 0],
"conditioning": ["4", 1]
},
"class_type": "BasicGuider"
},
"10": {
"inputs": {
"noise_seed": seed === -1 ? Math.floor(Math.random() * 1000000000) : seed
},
"class_type": "RandomNoise"
},
"11": {
"inputs": {
"scheduler": scheduler,
"steps": steps,
"denoise": 1,
"model": ["4", 0]
},
"class_type": "BasicScheduler"
},
"12": {
"inputs": {
"samples": ["7", 0],
"vae": ["3", 0]
},
"class_type": "VAEDecode"
},
"13": {
"inputs": {
"filename_prefix": "flux_output",
"images": ["12", 0]
},
"class_type": "SaveImage"
}
};
return workflow;
}