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

Asynchronous Image Editing Call 2.5

POST/api/v1/image/generation

Header Parameters

Authorization?string

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

X-DashScope-Async?string

Configuration parameters for asynchronous processing. HTTP requests only support asynchronous processing and must be set to enable.

Request Body

application/json

model*string

Model name. Fixed value: wan2.5-i2i-preview

Value in"wan2.5-i2i-preview"
input*object

Basic input information, such as prompts.

prompt*string

Positive prompt, used to describe the desired elements and visual features to be included in the generated image. Supports Chinese and English, with a maximum length of 2000 characters, where each Chinese character or letter counts as one character, and any excess will be automatically truncated.

images*array<string>

Array of image URLs. Enter URL or Base64. The array length must not exceed 3, meaning a maximum of 3 images can be input. When inputting multiple images, the image order is defined by the array order. Image restrictions: Image formats: JPEG, JPG, PNG (alpha channel not supported), BMP, WEBP. Image resolution: Both width and height must be within the range of [384, 5000] pixels. File size: Maximum 10MB.

[]?string
negative_prompt?string

Negative prompt, used to describe unwanted content in the image to constrain the generation. Supports both Chinese and English, with a maximum length of 500 characters; any excess will be automatically truncated. Example values: low resolution, errors, worst quality, low quality, deformed, extra fingers, bad proportions, etc.

parameters?object

Image processing parameters, such as setting image resolution, enabling intelligent prompt rewriting, and adding watermarks.

size?string

Set the resolution of the output image in the format of widthheight. The default value is 12801280. Image resolution: total pixels must be within [768768, 12801280], and the aspect ratio must be within [1:4, 4:1]. Example value: 12801280. Recommended resolutions and corresponding aspect ratios: 12801280: 1:1, 10241024: 1:1, 8001200: 2:3, 1200800: 3:2, 9601280: 3:4, 1280960: 4:3, 7201280: 9:16, 1280720: 16:9, 1344576: 21:9. If size is not specified, the system will default to generating an image with a total of 1280*1280 pixels and maintain the aspect ratio (approximate) according to the following rules: Single-image input: the aspect ratio matches the input image; Multi-image input: the aspect ratio matches the last input image.

n?integer

The number of images to generate. Valid values range from 1 to 4, with a default of 4. To control costs, it is recommended to explicitly set this to 1 during testing.

watermark?boolean

Specifies 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: Watermark is added.

prompt_extend?boolean

Whether to enable intelligent prompt rewriting. When enabled, a large model intelligently rewrites the input prompt to improve overall performance, but it increases latency. true: Default value, enables intelligent rewriting. false: Disables intelligent rewriting.

seed?integer

The random seed, with a value range of [0, 2147483647]. If not provided, the algorithm automatically generates a random number as the seed. If provided, the seed parameter is generated for each of the n images based on the value of n; for example, if n=4, the algorithm will generate images using seed, seed+1, seed+2, and seed+3 as parameters, respectively. To improve the reproducibility of the generated results, it is recommended to use a fixed seed value. Please note that due to the probabilistic nature of model generation, identical results cannot be guaranteed every time even with the same seed.

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 Token Count

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 "Content-Type: application/json" \  -d '{    "model": "wan2.5-i2i-preview",    "input": {      "prompt": "string",      "images": [        "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"
}