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

Synchronous Image Editing 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

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

Input Parameter Object

messages *array<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.

[]?object
role*string

The message sender role must be set to user.

content*array<object>

Message content containing 1-3 images in the format {"image": "..."}, and a single edit instruction in the format {"text": "..."}.

[]?object
image*string

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.

text*string

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.

parameters?object

Additional parameters for controlling image generation.

n?integer

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_prompt?string

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.

size?string

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.

prompt_extend?boolean

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.

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, 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.

code*integer

Status Code

data*object

Data Object

urls*array<string>

Result Set

[]?string
usage*object

Usage Information

images*integer

Image Count

seconds*integer

Video Seconds

input_tokens*integer

Input Tokens

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": "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"
}