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
arrayrequiredRequest 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
stringrequiredThe role of the message
Value:
usercontent
arrayrequiredContent array, must contain one text object and 0-4 image objects
text
stringrequiredPositive 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:
2000charactersimage
stringImage input (optional)
Basic Limitations:
Supported formats: JPEG, JPG, PNG (no transparency), BMP, WEBP
Resolution requirements: Width and height must be between384and5000pixels
File size: Maximum10MBImage Quantity Rules:
Image quantity depends on theparameters.enable_interleaveparameter:
Whenenable_interleave=true(interleaved output): Can input 0-1 images
Whenenable_interleave=false(image editing): Must input 1-4 imagesMulti-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.jpegMethod 2: Base64 encoding
Format:data:{MIME_type};base64,{base64_data}
Example:data:image/jpeg;base64,GDU7MtCZzEbTbmRZ...
parameters object
Image processing parameters
negative_prompt
stringNegative 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:
500charactersExample:
Low resolution, low quality, deformed limbs, deformed fingers, oversaturated, waxy appearance, faceless details, overly smooth, AI-generated look, chaotic composition, blurred text, distorted.
size
stringOutput 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×1536meets the requirements.Recommended resolutions for common aspect ratios:
1:1:1280×1280or1024×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
booleanControls 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 totrue, 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,trueDefault:
false
n
integerSpecifies 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_interleavestate: whenenable_interleave=false(image editing mode), it directly controls the number of generated images and is recommended to set to1during testing for low-cost verification; whenenable_interleave=true(interleaved mode), this parameter must be fixed at1or an API error will occur, usemax_imagesparameter instead to control the maximum number of generated images.Range:
1-4Default:
1
max_images
integerSpecifies 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 generate3images based on content).Range:
1-5Default:
5
prompt_extend
booleanWhether 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,falseDefault:
true
watermark
booleanWhether to add a watermark identifier. The watermark is located in the lower right corner of the image with fixed text “AI Generated”.
Options:
false,trueDefault:
false
seed
integerRandom 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
stringError code
message
stringDetailed error message
output array
Generation results. Only present when status is completed.
content
arrayList of generated content
type
stringResource type
Options:
image,texturl
stringGenerated image URL. Only present when type is
imagetext
stringGenerated text content. Only present when type is
text(interleaved mode)jobId
stringRemote task ID
usage object
Usage statistics. Only present when status is completed.
cost
stringTotal cost in USD
discount
numberDiscount amount
image_count
integerNumber of images generated
metadata object
Metadata information.
Error Codes
| Error Code | Description |
|---|---|
| 001021001 | Missing required field input |
| 001021002 | input.messages must contain one message |
| 001021003 | message.role must be user |
| 001021004 | message.content must be array |
| 001021005 | message.content must contain one text object |
| 001021006 | Text length must be between 1-2000 characters |
| 001021007 | When enable_interleave=true, can only input 0-1 images |
| 001021008 | When enable_interleave=false, must input 1-4 images |
| 001021009 | negative_prompt cannot exceed 500 characters |
| 001021010 | When enable_interleave=true, n must be 1 |
| 001021011 | n must be an integer between 1 and 4 |
| 001021012 | max_images is only valid when enable_interleave=true |
| 001021013 | max_images must be an integer between 1 and 5 |
| 001021014 | seed must be an integer between 0 and 2147483647 |
| 001021015 | size format must be ‘width*height’ |
| 001021016 | size must be between 768*768 and 1280*1280 pixels |
| 001021017 | Aspect ratio must be between 1:4 and 4:1 |
| 001021018 | Invalid size format, must be ‘width*height’ with integers |
| 001021095 | Internal generation error |
| 001021096 | Result parsing error |
| 001021097 | HTTP error response |
| 001021098 | Status check error |
| 001021099 | Task creation error |