Synchronous Image Editing Call
/api/v1/image/generationHeader Parameters
Use Bearer Token authentication. Format: Authorization: Bearer sk-xxxxxx
Request Body
application/json
Model Name
"qwen-image-edit" | "qwen-image-edit-plus" | "qwen-image-edit-max" | "qwen-image-2.0" | "qwen-image-2.0-pro"Input Parameter Object
Request content array. Currently, only single-turn conversations are supported, so the array must contain exactly one object, which includes the role and content properties.
The message sender role must be set to user.
Message content containing 1-3 images in the format {"image": "..."}, and a single edit instruction in the format {"text": "..."}.
Enter the URL or Base64-encoded data for the input images. Supports 1 to 3 images. For multiple image inputs, the image sequence follows the array order, and the aspect ratio of the output image is determined by the last image. Image requirements: Image formats: JPG, JPEG, PNG, BMP, TIFF, WEBP, and GIF. Output images are in PNG format. For animated GIFs, only the first frame is processed. Image resolution: For best results, it is recommended that the image width and height be between 384 and 3072 pixels. A resolution that is too low may cause blurry generation results, while one that is too high will increase processing time. Image size: Maximum 10MB.
Positive prompts are used to describe the content, style, and composition of the image you wish to generate. Both Chinese and English are supported, with a maximum length of 800 tokens, and any excess will be automatically truncated. Note: Only one text parameter is supported; passing none or multiple will result in an error.
Additional parameters for controlling image generation.
The number of output images, with a default value of 1. For the qwen0image-2.0 series, qwen-image-edit-max, and qwen-image-edit-plus series models, you can choose to output 1 to 6 images. For qwen-image-edit, only 1 image output is supported.
Negative prompts are used to describe elements you do not want to see in the image, allowing you to restrict the generation. It supports both Chinese and English with a maximum length of 500 characters, where each Chinese character, letter, number, or symbol counts as one character, and any excess is automatically truncated. Example values: low resolution, errors, worst quality, low quality, deformed, extra fingers, bad proportions, etc.
Set the resolution of the output image in the format of widthheight, such as "10241536". Supported models: all models except qwen-image-edit. The resolution size for qwen-image-edit is automatically determined by the model. qwen-image-2.0 series models: The total number of pixels in the image must be between 512512 and 20482048. The default total pixel count is close to 10241024, with an aspect ratio similar to the input image (or the last image for multiple inputs). qwen-image-edit-max and qwen-image-edit-plus series models: The value ranges for both width and height are [512, 2048] pixels. The default total pixel count is close to 10241024, with an aspect ratio similar to the input image (or the last image for multiple inputs). When the size parameter is specified, the system targets the width and height specified by size and adjusts the actual output image dimensions to the nearest multiple of 16. For example, if 10331032 is set, the output image size will be 10401024.
Specifies whether to enable intelligent prompt rewriting, with the default value set to true. When enabled, the model optimizes positive prompts (text), significantly improving results for prompts with simpler descriptions. Supported models: All models except qwen-image-edit.
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, so even with the same seed, completely identical results cannot be guaranteed every time.
Response Body
application/json
Success
TypeScript Definitions
Use the response body type in TypeScript.
Status Code
Data Object
Result Set
Usage Information
Image Count
Video Seconds
Input Tokens
Total Token Count
Output token count
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-edit", "input": { "messages ": [ { "role": "string", "content": [ { "image": "string", "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"
}