Synchronous Image Generation Call
/api/v1/image/generationHeader Parameters
Use Bearer Token authentication. Format: Authorization: Bearer sk-xxxxxx
Request Body
application/json
Model name, fixed values: qwen-image-plus, qwen-image-max, qwen-image-2.0, qwen-image-2.0-pro
"qwen-image-plus" | "qwen-image-max" | "qwen-image-2.0" | "qwen-image-2.0-pro"Basic input information, such as prompts.
Request content array. Currently, only single-turn conversations are supported, and the array must contain exactly one element.
The role of the message. This parameter must be set to user.
Message content array.
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.
Image processing parameters.
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.
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.
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.
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.
Whether to add a "Qwen-Image" watermark to the bottom-right corner of the image. The default value is false.
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.
Status Code
Data Object
Result Set
Usage Information
Number of Images
Video Duration in Seconds
Input Token Count
Total Tokens
Output Tokens
Validity Period
Task ID
Task Status
Status Information
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"
}