典名词元DMTOKENSHome
API DocumentationThird-Party Tools Tutorial
AI Model APIImageWanxiang

Synchronous and Asynchronous Calls for Image Generation and Editing 2.6

POST/api/v1/image/generation

Header Parameters

Authorization*string

Use Bearer Token authentication. Format: Authorization: Bearer sk-xxxxxx

X-DashScope-Sse?string

Used to enable streaming output; this field must be set to enable only when parameters.enable_interleave=true.

X-DashScope-Async?string

Asynchronous processing configuration parameter, must be set to enable.

Request Body

application/json

model*string

Model name. Fixed value: wan2.6-image

Value in"wan2.6-image"
input*object

Basic input information.

messages*array<object>

Request content array. Currently, only single-turn conversations are supported, i.e., passing a single set of role and content parameters, while multi-turn conversations are not supported.

[]?object
role*string

The role of the message. This parameter is always set to user.

content*array<object>

Message content array.

[]?object
text*string

Positive prompts are used to describe the desired content, style, and composition of the generated image. Both Chinese and English are supported, with a maximum length of 2000 characters. Each Chinese character, letter, number, or symbol counts as one character, and any excess will be automatically truncated. Example value: Generate scrambled eggs with tomatoes referencing the style of this image. Note: The content array must contain one and only one object with a text field.

image?string

Enter the URL or Base64-encoded string of the input image. Image constraints: Image formats: JPEG, JPG, PNG (alpha channel not supported), BMP, and WEBP. Image resolution: Both width and height must be within the range of [240, 8000] pixels. File size: Up to 10MB. Image count limit: The number of input images depends on the parameters.enable_interleave parameter. When enable_interleave=true (interleaved text and image output), 0 to 1 image can be input. When enable_interleave=false (image editing), 1 to 4 images must be input. When inputting multiple images, pass multiple image objects in the content array and define the image sequence according to the array order.

parameters?object

Image processing parameters.

negative_prompt?string

Negative prompt, used to describe unwanted elements in the image and constrain the visual output. Supports both Chinese and English, with a maximum length of 500 characters; any excess will be automatically truncated.

size?string

Output image resolution parameter, supporting two methods: referencing the input image aspect ratio and direct specification. When enable_interleave=false (i.e., image editing mode): Method 1: Reference input image aspect ratio (recommended). Available output resolution tiers: 1K (default) and 2K. 1K: Total output pixels close to 12801280, with the aspect ratio matching the last input image. 2K: Total output pixels close to 20482048, with the aspect ratio matching the last input image. Method 2: Specify the width and height pixel values of the generated image. Total pixels within [768768, 20482048], and aspect ratio within [1:4, 4:1]. The actual output image pixel values are multiples of 16 closest to the specified values. When enable_interleave=true (i.e., interleaved text and image output mode): Method 1: Reference input image aspect ratio (default). If the total input image pixels ≤ 12801280, the total output pixels and aspect ratio match the input image. If the total input image pixels > 12801280, the total output pixels are close to 12801280, with the aspect ratio matching the input image. Method 2: Specify the width and height pixel values of the generated image. Total pixels within [768768, 12801280], and aspect ratio within [1:4, 4:1]. The actual output image pixel values are multiples of 16 closest to the specified values. Recommended resolutions for common aspect ratios: 1:1: 12801280, 2:3: 8001200, 3:2: 1200800, 3:4: 9601280, 4:3: 1280960, 9:16: 7201280, 16:9: 1280720, 21:9: 1344*576.

enable_interleave?boolean

Control image generation mode: false: Default value, indicating image editing mode (supports multi-image input and subject-consistent generation). Usage: Editing, style transfer, or subject-consistent generation based on 1 to 4 input images. Input: At least one reference image must be provided. Output: Can generate 1 to 4 resulting images. true: Indicates enabling the mixed text-and-image output mode (supports passing only one image or no image). Usage: Generating content with both text and images based on text descriptions, or text-to-image generation. Input: No image required (text-to-image), or up to 1 reference image can be provided. Output: Generates mixed content containing text and images.

n?integer

Specifies the number of images to generate. The value range and meaning of this parameter depend on the state of enable_interleave (mode switch): When enable_interleave=false (image editing mode): Function: Directly controls the number of generated images. Value range: 1 to 4, with a default value of 4. It is recommended to set this value to 1 during the testing phase to verify the effects at a low cost. When enable_interleave=true (text-image interleaved mode): Restriction: This parameter defaults to 1 and must be fixed at 1. If set to any other value, the API will return an error. Note: In this mode, to control the maximum number of generated images, please use the max_images parameter.

max_images?integer

Takes effect only in text-image interleaved mode (i.e., enable_interleave=true). Purpose: Specifies the maximum number of images the model can generate in a single response. Value range: 1 to 5, default is 5. Note: This parameter only represents the upper limit. The actual number of images generated is determined by model inference and may be less than the specified value (e.g., if set to 5, the model may generate only 3 images depending on the content).

prompt_extend?boolean

Takes effect only in image editing mode (i.e., enable_interleave = false). Whether to enable the intelligent Prompt rewriting feature. This feature only optimizes and polishes positive prompts without altering negative prompts. true: Default value, enables intelligent rewriting. false: Disables intelligent rewriting and uses the original prompts.

stream?boolean

Controls whether the response is streamed. In image interleaving mode (i.e., enable_interleave = true), it must be set to true. false: Default value, non-streaming output. true: Streaming output.

watermark?boolean

Whether to add a watermark. The watermark is located in the bottom right corner of the image with the fixed text "AI-generated". false: Default value, no watermark is added. true: Add a watermark.

seed?integer

Random seed, value range [0, 2147483647]. Using the same seed parameter value keeps 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, completely identical results cannot be guaranteed every time.

Response Body

application/json

Success

TypeScript Definitions

Use the response body type in TypeScript.

code*integer

Status Code

data*object

Data Object

urls*array<string>

Result Set

[]?string
usage*object

Usage Information

images*integer

Number of Images

seconds*integer

Video Duration in Seconds

input_tokens*integer

Input Token Count

total_tokens*integer

Total Tokens

output_tokens*integer

Output Token Count

expired*string

Validity Period

task_id*string

Task ID

task_status*string

Task Status

message*string

Status Information

request_id*string

Request ID

curl -X POST "https://api.ygw.ai/api/v1/image/generation" \  -H "Authorization: string" \  -H "Content-Type: application/json" \  -d '{    "model": "wan2.6-image",    "input": {      "messages": [        {          "role": "string",          "content": [            {              "text": "string"            }          ]        }      ]    }  }'
{
  "code": 0,
  "data": {
    "urls": [
      "string"
    ],
    "usage": {
      "images": 0,
      "seconds": 0,
      "input_tokens": 0,
      "total_tokens": 0,
      "output_tokens": 0
    },
    "expired": "string",
    "task_id": "string",
    "task_status": "string"
  },
  "message": "string",
  "request_id": "string"
}