⌘K

Wan 2.6 - Image to Image

wan26_i2i

Wan 2.6 - Image to Image transforms and edits images with AI-powered style transfer and modification capabilities.

Authentication

authorization string required

All APIs require authentication via Bearer Token.

Get API Key:

Visit API Key Management Page to get your API Key

Usage:

Add to request header:

Authorization: Bearer YOUR_API_KEY

Parameters

model string required

Model ID to use for the request

Value: wan26_i2i


input object required

Input data for the generation request

messages array required

Request content array. Currently only supports single-turn conversation, i.e., passing one set of role and content parameters. Multi-turn conversations are not supported. Array length must be 1.

role string required

The role of the message

Value: user

content array required

Content array, must contain one text object and 0-4 image objects

text string required

Positive prompt used to describe the image content, style, and composition you expect to generate. Supports Chinese and English. Each Chinese character, letter, number, or symbol counts as one character. Content exceeding the limit will be automatically truncated.

Maximum length: 2000 characters

image string

Image input (optional)

Basic Limitations:
Supported formats: JPEG, JPG, PNG (no transparency), BMP, WEBP
Resolution requirements: Width and height must be between 384 and 5000 pixels
File size: Maximum 10MB

Image Quantity Rules:
Image quantity depends on the parameters.enable_interleave parameter:
When enable_interleave=true (interleaved output): Can input 0-1 images
When enable_interleave=false (image editing): Must input 1-4 images

Multi-image input: When inputting multiple images, pass multiple image objects in the content array. Image order is defined by array order.

Input Formats:
Method 1: Publicly accessible URL
Supports HTTP or HTTPS protocol
Example: http://wanx.alicdn.com/material/xxx.jpeg

Method 2: Base64 encoding
Format: data:{MIME_type};base64,{base64_data}
Example: data:image/jpeg;base64,GDU7MtCZzEbTbmRZ...


parameters object

Image processing parameters

negative_prompt string

Negative prompt used to describe content you don’t want to appear in the image, to constrain the output. Supports Chinese and English. Content exceeding the limit will be automatically truncated.

Maximum length: 500 characters

Example: Low resolution, low quality, deformed limbs, deformed fingers, oversaturated, waxy appearance, faceless details, overly smooth, AI-generated look, chaotic composition, blurred text, distorted.

size string

Output image resolution in the format width*height.

For wan2.6-image: Total pixels must be between [768×768, 1280×1280] (i.e., 589824 to 1638400 pixels), and aspect ratio must be in the range [1:4, 4:1]. For example, 1024×1536 meets the requirements.

Recommended resolutions for common aspect ratios:
1:1: 1280×1280 or 1024×1024
2:3: 800×1200
3:2: 1200×800
3:4: 960×1280
4:3: 1280×960
9:16: 720×1280
16:9: 1280×720
21:9: 1344×576

enable_interleave boolean

Controls the image generation mode. When set to false, it’s image editing mode which supports multi-image input and subject consistency generation, allowing editing, style transfer, or subject consistency generation based on 1-4 input images with at least 1 reference image required, outputting 1 to 4 result images. When set to true, it’s interleaved text-image output mode which only supports passing one image or no image, enabling mixed text and image content generation or pure text-to-image generation.

Options: false, true

Default: false

n integer

Specifies the number of images to generate. This parameter directly affects billing costs (Cost = Unit price × Number of successfully generated images), please confirm model pricing before calling.

The value range and meaning depend on enable_interleave state: when enable_interleave=false (image editing mode), it directly controls the number of generated images and is recommended to set to 1 during testing for low-cost verification; when enable_interleave=true (interleaved mode), this parameter must be fixed at 1 or an API error will occur, use max_images parameter instead to control the maximum number of generated images.

Range: 1 - 4

Default: 1

max_images integer

Specifies the maximum number of images the model generates in a single response, only effective in interleaved mode (i.e., enable_interleave=true). This parameter affects billing costs (Cost = Unit price × Number of successfully generated images), please confirm model pricing before calling.

Note this parameter only represents the “upper limit” and actual generated images are determined by model inference, which may be less than the set value (e.g., if set to 5, the model may only generate 3 images based on content).

Range: 1 - 5

Default: 5

prompt_extend boolean

Whether to enable intelligent Prompt rewriting, only effective in image editing mode (i.e., enable_interleave=false). This feature only optimizes and refines positive prompts and does not change negative prompts.

Options: true, false

Default: true

watermark boolean

Whether to add a watermark identifier. The watermark is located in the lower right corner of the image with fixed text “AI Generated”.

Options: false, true

Default: false

seed integer

Random seed for generation. Using the same seed value can keep the generated content relatively stable, if not provided the algorithm will automatically use a random seed.

Note: The model generation process is probabilistic and even with the same seed it cannot guarantee completely consistent results every time.

Range: 0 - 2147483647


Polling

Since image generation takes time, you need to poll the task status after creation.

The initial response returns the task ID and initial status. The actual generation results must be obtained through polling the task status endpoint.


Response Format

error object

Error information. Only present when status is failed.

code string

Error code

message string

Detailed error message


output array

Generation results. Only present when status is completed.

content array

List of generated content

type string

Resource type

Options: image, text

url string

Generated image URL. Only present when type is image

text string

Generated text content. Only present when type is text (interleaved mode)

jobId string

Remote task ID


usage object

Usage statistics. Only present when status is completed.

cost string

Total cost in USD

discount number

Discount amount

image_count integer

Number of images generated


metadata object

Metadata information.


Error Codes

Error CodeDescription
001021001Missing required field input
001021002input.messages must contain one message
001021003message.role must be user
001021004message.content must be array
001021005message.content must contain one text object
001021006Text length must be between 1-2000 characters
001021007When enable_interleave=true, can only input 0-1 images
001021008When enable_interleave=false, must input 1-4 images
001021009negative_prompt cannot exceed 500 characters
001021010When enable_interleave=true, n must be 1
001021011n must be an integer between 1 and 4
001021012max_images is only valid when enable_interleave=true
001021013max_images must be an integer between 1 and 5
001021014seed must be an integer between 0 and 2147483647
001021015size format must be ‘width*height’
001021016size must be between 768*768 and 1280*1280 pixels
001021017Aspect ratio must be between 1:4 and 4:1
001021018Invalid size format, must be ‘width*height’ with integers
001021095Internal generation error
001021096Result parsing error
001021097HTTP error response
001021098Status check error
001021099Task creation error