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

Synchronous Image Generation Call

POST/api/v1/image/generation

Header Parameters

Authorization?string

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

Request Body

application/json

model*string

Model name, fixed values: qwen-image-plus, qwen-image-max, qwen-image-2.0, qwen-image-2.0-pro

Value in"qwen-image-plus" | "qwen-image-max" | "qwen-image-2.0" | "qwen-image-2.0-pro"
input*object

Basic input information, such as prompts.

messages*array<object>

Request content array. Currently, only single-turn conversations are supported, and the array must contain exactly one element.

[]?object
role*string

The role of the message. This parameter must be set to user.

content*array<object>

Message content array.

[]?object
text*string

Positive prompts are used to describe the expected content, style, and composition of the generated image. Both Chinese and English are supported. The maximum length for the qwen-image-2.0 series models is 1300 Token, and for other models it is 800 Token; any excess will be automatically truncated. Note: Only one text input is supported; passing none or multiple will result in an error.

parameters?object

Image processing parameters.

negative_prompt?string

Negative prompt, used to describe unwanted content in the image to constrain the visual output. Supports both Chinese and English, with a maximum length of 500 characters; any excess will be automatically truncated. Example values: low resolution, low quality, deformed limbs, deformed fingers, oversaturated image, waxy appearance, lack of facial details, overly smooth, AI-generated look, messy composition, blurry and distorted text.

size?string

qwen-image-2.0 series models: the total number of pixels in the output image must be between 512512 and 20482048, with a default resolution of 20482048. Recommended resolutions: 26881536: 16:9; 15362688: 9:16; 20482048 (default): 1:1; 23681728: 4:3; 17282368: 3:4. qwen-image-max and qwen-image-plus series models: the default resolution is 1664928. Available resolutions and their corresponding aspect ratios are: 1664928 (default): 16:9; 14721104: 4:3; 13281328: 1:1; 11041472: 3:4; 9281664: 9:16.

n?integer

The number of output images, with a default value of 1. For the qwen-image-max and qwen-image-plus series models, this parameter is fixed at 1, and setting it to any other value will result in an error.

prompt_extend?boolean

Whether to enable the intelligent Prompt rewriting feature. When enabled, the model will optimize and refine positive prompts. This feature will not modify negative prompts. true: Default value, enables intelligent rewriting. Enable this option if you want more diverse image content and allow the model to add details. false: Disables intelligent rewriting. Disable this option if you prefer more controllable image details.

watermark?boolean

Whether to add a "Qwen-Image" watermark to the bottom-right corner of the image. The default value is false.

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; even with the same seed, it cannot guarantee exactly identical results 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 Tokens

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": "qwen-image-plus",    "input": {      "messages": [        {          "role": "user",          "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"
}