WAN Image 2.2 Generation
Generate images using the WAN Image 2.2 workflow with dual LoRA support for enhanced control over image generation.
Overview
The WAN Image 2.2 workflow allows you to use two separate LoRA models simultaneously with different strength settings, providing fine-grained control over the generation process. This is particularly useful for combining different style or subject LoRAs to achieve specific artistic effects.
Important: When using
model_type: "wan-image-2.2", bothlora_low_nameandlora_high_nameparameters are required. The SDK will throw an error if either is missing.Note: The
workflow_typeparameter is deprecated. Usemodel_type: "wan-image-2.2"instead.
Method Signature
client.images.generate(params: GenerateImageInput)
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
prompt | string | Yes | The text prompt for image generation |
width | number | Yes | Image width (64-2048) |
height | number | Yes | Image height (64-2048) |
model_id | string | Yes | UUID of the model to use |
model_type | "wan-image-2.2" | Yes | Must be set to "wan-image-2.2" |
lora_low_name | string | Yes | Path to the low-strength LoRA model (required for WAN Image 2.2) |
lora_low_strength | number | No | Strength for low LoRA (0-2, default: 0.5) |
lora_high_name | string | Yes | Path to the high-strength LoRA model (required for WAN Image 2.2) |
lora_high_strength | number | No | Strength for high LoRA (0-2, default: 1.0) |
batch_size | number | No | Number of images to generate (1-4, default: 1) |
guidance | number | No | Guidance scale (0-100) |
model_weight | number | No | Model weight (0-1) |
webhook_url | string | No | URL for webhook notifications |
Example Usage
Basic Generation with Dual LoRAs (Required)
// WAN Image 2.2 requires both LoRA parameters
const result = await client.images.generate({
prompt: "A female model in vintage fashion, natural lighting",
width: 1200,
height: 1500,
model_id: "your-model-uuid",
model_type: "wan-image-2.2",
lora_low_name: "wan2.2/wan2.2-lora-instagirl-2.0/Instagirlv2.0_lownoise.safetensors", // Required
lora_low_strength: 0.5,
lora_high_name: "wan2.2/wan2.2-lora-instagirl-2.0/Instagirlv2.0_hinoise.safetensors", // Required
lora_high_strength: 1.0,
batch_size: 1
});
console.log("Generated image:", result.image_url);
Error Handling for Missing LoRAs
The SDK will throw an error if you don't provide both LoRA names:
try {
const result = await client.images.generate({
prompt: "Professional portrait photography",
width: 1024,
height: 1024,
model_id: "your-model-uuid",
model_type: "wan-image-2.2"
// Missing lora_low_name and lora_high_name - will throw error
});
} catch (error) {
console.error(error.message);
// "WAN Image 2.2 workflow requires both lora_low_name and lora_high_name parameters"
}
With Webhook for Progress Updates
const result = await client.images.generate({
prompt: "Artistic fashion photography",
width: 1200,
height: 1500,
model_id: "your-model-uuid",
model_type: "wan-image-2.2",
lora_low_name: "path/to/style-lora.safetensors",
lora_low_strength: 0.4,
lora_high_name: "path/to/subject-lora.safetensors",
lora_high_strength: 0.9,
webhook_url: "https://your-webhook-endpoint.com/progress"
});
Response
The method returns a GenerateImageOutput object:
{
runId: string;
status: string;
progress: number;
liveStatus: string;
run_type: string;
image_url?: string;
}
Notes
- The WAN Image 2.2 workflow uses a predefined negative prompt optimized for high-quality generation
- The dual LoRA system allows for complex style mixing not possible with single LoRA workflows
- LoRA strengths can be fine-tuned to balance between different styles or subjects
- The workflow is particularly effective for fashion, portrait, and artistic photography
Comparison with Other Workflows
| Feature | Default | WAN | WAN Image 2.2 |
|---|---|---|---|
| Single LoRA | ✓ | ✓ | ✓ |
| Dual LoRA | ✗ | ✗ | ✓ |
| Custom LoRA Strength | ✓ | ✓ | ✓ (per LoRA) |
| Optimized Negative Prompt | ✗ | ✗ | ✓ |
| Batch Generation | ✓ | ✓ | ✓ |
Error Handling
try {
const result = await client.images.generate({
// ... parameters
workflow_type: "wan-image-2.2"
});
} catch (error) {
console.error("Generation failed:", error.message);
// Handle specific error cases
}