qwen-image-2.0-pro
Before use, press Access Basics to set
SHANHAI_BASE_URL(this site’s root address) andSHANHAI_API_KEY(this site’s token). The following command is suitable for Bash; the material example address must be replaced with a real address that can be downloaded directly.
Support text-generated pictures, picture-generated pictures and multi-picture reference. Use POST /v1/images/generations for text generation; use POST /v1/images/edits for image editing. Both can use the JSON structures of input.messages and parameters below.
request parameters
| Parameter | Type | Required | Value and behavior |
|---|---|---|---|
model |
The string | is | qwen-image-2.0-pro. |
input.messages |
array | is | exactly one role: "user" message; multiple rounds of messages are not accepted. |
input.messages[0].content[].text |
The string | is | . It is exactly one text command; the text diagram describes the screen, and the diagram describes the modification requirements. |
input.messages[0].content[].image |
String | Required when editing | Public network picture direct link or picture data address with format prefix; up to 3 pictures. Vincent Picture does not upload pictures. |
parameters.n |
Integer | No | 1~6, default 1. |
parameters.size |
String | No | 宽*高; The total pixels are in 512*512 ~ 2048*2048, the aspect ratio does not exceed 8:1 or 1:8. For example 1024*1024. |
parameters.watermark |
Boolean value | No | Whether to add a visible watermark, the default is false. |
parameters.seed |
Integer | No | 0~2147483647; random when omitted. Identical seeds are not guaranteed to be identical. |
parameters.negative_prompt |
String | No | Unwanted content, such as "blurred, text distortion"; 2.0 The length should not exceed 500 characters. |
parameters.prompt_extend |
Boolean value | No | Whether to rewrite the prompt word. 2.0 Default is true; fill in false if you want to strictly follow the original prompt word. |
Image input and output size
The reference picture can use the public network address or the image data address. For the form writing method for uploading local files, see General Description of Image Interface. When editing multiple pictures, explain the respective uses of "Picture 1" and "Picture 2" in array order. Don't treat web page addresses as image file addresses.
The default sizes of Vincent diagrams and editors may be different; fill in parameters.size explicitly when a fixed delivery size is required. Use half-width asterisks for width and height; do not use 2K string.
Request Example
Text generated image
curl --fail-with-body "$SHANHAI_BASE_URL/v1/images/generations" \
-H "Authorization: Bearer $SHANHAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen-image-2.0-pro",
"input": {
"messages": [
{
"role": "user",
"content": [
{
"text": "一只红色陶瓷杯,米色背景,柔和摄影棚灯光。"
}
]
}
]
},
"parameters": {
"n": 1,
"size": "1024*1024",
"watermark": false
}
}'
Single picture editing
curl --fail-with-body "$SHANHAI_BASE_URL/v1/images/edits" \
-H "Authorization: Bearer $SHANHAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen-image-2.0-pro",
"input": {
"messages": [
{
"role": "user",
"content": [
{
"image": "https://example.com/reference.png"
},
{
"text": "保留主体,把背景改成海边日落。"
}
]
}
]
},
"parameters": {
"n": 1,
"size": "1024*1024",
"watermark": false,
"seed": 42
}
}'
Multiple pictures for reference
{
"model": "qwen-image-2.0-pro",
"input": {
"messages": [
{
"role": "user",
"content": [
{
"image": "https://example.com/person.png"
},
{
"image": "https://example.com/scene.png"
},
{
"text": "保留图1的人物外观,让人物置于图2的场景中。"
}
]
}
]
},
"parameters": {
"n": 1,
"size": "1024*1024"
}
}
Return results
Successfully returns the picture result object and reads all pictures in the data array instead of only saving the first one. Each item usually has url; if b64_json is returned, it must be decoded first and then saved. The direct link to the picture has a time limit and should be downloaded in time. The actual number of pictures in the group may be less than n. If the request fails, check the HTTP status code and error.message first, and do not save the error JSON as an image.
encountered a problem
If you encounter problems with calling or configuration, please contact the site customer service and provide the model name, task number, error time and error message. Do not provide the complete token.