generate_variations
Generate multiple versions of a text prompt by varying the seed to explore different outcomes and select the best result.
Instructions
Generate multiple variations of the same prompt by varying the seed. Useful for picking the best result or exploring a concept.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| prompt | Yes | Text prompt for the base image | |
| count | No | Number of variations to generate | |
| negative_prompt | No | ||
| width | No | ||
| height | No | ||
| steps | No | ||
| cfg | No | ||
| base_seed | No | Starting seed; subsequent variations use base_seed + i | |
| checkpoint | No |
Implementation Reference
- src/comfyui/client.ts:47-59 (helper)The ComfyUIClient.generate() helper that each variation call invokes. It creates a txt2img workflow and runs it via runWorkflow().
async generate(params: GenerateParams): Promise<GenerateResult> { const workflow = txt2img({ prompt: params.prompt, negativePrompt: params.negativePrompt ?? "", width: params.width ?? 1024, height: params.height ?? 1024, steps: params.steps ?? 25, cfg: params.cfg ?? 7, seed: params.seed ?? Math.floor(Math.random() * 2 ** 32), checkpoint: params.checkpoint ?? DEFAULT_CHECKPOINT, }); return this.runWorkflow(workflow); } - src/comfyui/workflows.ts:30-72 (helper)The txt2img() workflow builder that constructs the ComfyUI node graph used by generate_variations.
export function txt2img(params: Txt2ImgParams): Workflow { return { "3": { class_type: "KSampler", inputs: { seed: params.seed, steps: params.steps, cfg: params.cfg, sampler_name: "euler", scheduler: "normal", denoise: 1, model: ["4", 0], positive: ["6", 0], negative: ["7", 0], latent_image: ["5", 0], }, }, "4": { class_type: "CheckpointLoaderSimple", inputs: { ckpt_name: params.checkpoint }, }, "5": { class_type: "EmptyLatentImage", inputs: { width: params.width, height: params.height, batch_size: 1 }, }, "6": { class_type: "CLIPTextEncode", inputs: { text: params.prompt, clip: ["4", 1] }, }, "7": { class_type: "CLIPTextEncode", inputs: { text: params.negativePrompt, clip: ["4", 1] }, }, "8": { class_type: "VAEDecode", inputs: { samples: ["3", 0], vae: ["4", 2] }, }, "9": { class_type: "SaveImage", inputs: { filename_prefix: "comfyui-mcp", images: ["8", 0] }, }, }; }