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

Synchronous and Asynchronous Calls for Image Generation and Editing 2.7

POST/api/v1/image/generation

Header Parameters

Authorization*string

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

X-DashScope-Async?string

The asynchronous processing configuration parameter must be set to enable.

Request Body

application/json

model*string

Model name. Fixed values: wan2.7-image, wan2.7-image-pro

Value in"wan2.7-image" | "wan2.7-image-pro"
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 fixed to user.

content*array<object>

Message content array.

[]?object
text*string

Positive prompts are used to describe the content, style, and composition of the image you expect to generate. 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: Refer to the style of this image to generate scrambled eggs with tomatoes. 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 limits: Image formats: JPEG, JPG, PNG (alpha channel not supported), BMP, WEBP. Image resolution: The width and height of the image are in the range of [240, 8000] pixels, and the aspect ratio is in the range of [1:8, 8:1]. File size: Maximum 20MB. Image count limit: 0-9 images can be provided. When inputting multiple images, multiple image objects must be passed in the content array, and the image order is defined by the array order.

parameters?object

Image processing parameters.

bbox_list?array<string>

Regions selected via bounding boxes for interactive editing. Correspondence: The list length must match the number of input images. If an image does not require editing, pass an empty list [] at the corresponding position. Coordinate format: [x1, y1, x2, y2] (top-left x, top-left y, bottom-right x, bottom-right y), using absolute pixel coordinates of the original image, with the top-left coordinate being (0, 0). Constraints: A single image supports a maximum of 2 bounding boxes.

[]?string
enable_sequential?boolean

Controls the image generation mode: false: Default value. true: Enables multi-image output mode.

size?string

Regarding the output image resolution parameter, the following two methods are supported and cannot be mixed: Model: wan2.7-image-pro Method 1: Specify the resolution of the output image (recommended) Supports three specifications: 1K, 2K (default), and 4K Applicable scope: Text-to-image (no image input, not multi-image generation): supports 1K, 2K, and 4K. Other scenarios: supports 1K and 2K. Total pixels for each specification: 1K: 10241024, 2K: 20482048, 4K: 40964096 Image aspect ratio: When there is image input: the output aspect ratio is consistent with the input image (the last one in case of multi-image input) and scaled to the selected resolution. When there is no image input: the output is a square. Method 2: Specify the width and height pixel values of the generated image Text-to-image: total pixels between [768768, 40964096], aspect ratio range [1:8, 8:1]. Other scenarios: total pixels between [768768, 20482048], aspect ratio range [1:8, 8:1]. Model: wan2.7-image Method 1: Specify the resolution of the output image (recommended) Supports two specifications: 1K and 2K (default); 4K is not supported. Method 2: Specify the width and height pixel values of the generated image In all scenarios, total pixels are between [768768, 2048*2048], with an aspect ratio range of [1:8, 8:1]. The pixel values of the output image may have slight differences from the specified pixel values.

n?integer

When multi-image mode is disabled, this value represents the number of images to generate, with a range of 1-4 and a default of 1; when multi-image mode is enabled, this value represents the maximum number of images to generate, with a range of 1-12 and a default of 12. The actual number is determined by the model and does not exceed n.

thinking_mode?boolean

Whether to enable thinking mode. Defaults to true (enabled). Takes effect only when multi-image mode is disabled and no image input is provided. When enabled, the model enhances reasoning capabilities to improve image generation quality, but increases generation time.

color_palette?array<object>

Custom color theme, an array of objects containing color (hex) and ratio, requiring 3 to 10 colors, with 8 recommended. Available only when sequential mode is disabled (enable_sequential=false).

[]?object
hex?string

Color value in hexadecimal (HEX) format.

ratio?string

The color percentage must be accurate to two decimal places (e.g., "25.00%"). The sum of all ratio values must equal 100.00%.

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 helps 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, identical generation 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.7-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"
}