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

Asynchronous Image Generation 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-t2i-preview

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

Basic input information.

prompt*string

Positive prompt, used to describe the desired elements and visual characteristics to be included in the generated image. Supports Chinese and English. Each Chinese character, letter, or punctuation mark counts as one character, and any excess will be automatically truncated. The length must not exceed 2000 characters. Example value: A sitting orange cat with a cheerful expression, lively and adorable, realistic and accurate.

negative_prompt*string

Negative prompt, used to describe unwanted elements in the image to restrict the generated content. 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.

size?string

The resolution of the output image, in the format of widthheight. The default value is 12801280. The total pixels must be within [12801280, 14401440] and the aspect ratio must be in the range of [1:4, 4:1]. For example, 7682700 meets the requirements. Example value: 12801280. The following resolutions are applicable to wan2.5-t2i-preview: 1:1: 12801280 3:4: 11041472 4:3: 14721104 9:16: 9601696 16:9: 1696960 1:1: 12801280 3:4: 11041472 4:3: 14721104 9:16: 9601696 16:9: 1696960.

n?integer

The number of images to generate. The value ranges from 1 to 4, with a default of 4. Note: Billed per image; it is recommended to set this to 1 for testing.

prompt_extend?boolean

Whether to enable intelligent prompt rewriting. When enabled, a large model will be used to optimize positive prompts, which significantly enhances the output for shorter prompts but adds 3-4 seconds of latency. true: Default value, enables intelligent rewriting. false: Disables intelligent rewriting.

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: 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 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 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-t2i-preview",    "input": {      "prompt": "string",      "negative_prompt": "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"
}