qwen-image-3.0
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-3.0. |
input.messages |
array | is | exactly one role: "user" message; multiple rounds of messages are not accepted. |
input.messages[0].content[].text |
The string | is exactly one text command | ; it is recommended not to exceed 4500 Token (the unit of the model processing text, not equal to the number of Chinese characters). The Vincent diagram describes the scene, and the Picture 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"; it is recommended to use a short description. |
parameters.prompt_extend |
Boolean value | No | Whether to rewrite the prompt word, the default is true; it can be filled in when strictly following the original prompt word false. |
parameters.prompt_extend_mode |
String | No | Prompt word optimization method: direct (default) supports venison diagrams and editing; agent uses more complete planning and only supports Vincentian diagrams. An error will be reported when editing. Need to open prompt_extend. |
parameters.enable_thinking |
Boolean | No | Default true. prompt_extend needs to be turned on at the same time; analyzing the semantics and composition first will increase the generation time. |
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 reference image supports JPG/JPEG, PNG, BMP, WebP, and GIF; GIF only takes the first frame. Each image should not exceed 10 MB, with width and height ranging from 1 to 8000 pixels respectively; it is recommended to use 384 to 2048 pixels for better results. The aspect ratio is between 1:10 and 10:1.
When the size is not specified, the model selects the appropriate output size; when the delivery size needs to be fixed, fill in parameters.size explicitly. Use half-width asterisks for width and height; do not use 2K string. Plain text generation recommends specifying dimensions to control output specifications.
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-3.0",
"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-3.0",
"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-3.0",
"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"
}
}
Adjust prompt word optimization
When creating a Vincent diagram, you can change the parameters of the example to the following settings. Direct rewrite is suitable for simple tasks; agent and think mode are suitable for complex compositions, but are usually slower. When prompt_extend is turned off, the other two switches have no effect.
{
"n": 1,
"size": "1024*1024",
"prompt_extend": true,
"prompt_extend_mode": "agent",
"enable_thinking": true,
"watermark": false
}
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 returned sheets is subject to the data array. If the request fails, check the HTTP status code and error.message first. 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.