Skip to content

Qwen / Wan ​

Qwen image generation and editing models support both text-to-image (T2I) and image-to-image/image editing (I2I). They can generate images directly from text prompts or combine reference images with editing instructions. Qwen and Wan models share the same endpoint and are distinguished by the model parameter. The parameter descriptions below apply to Qwen image models.

Endpoint ​

http
POST /v1/images/generations

Authentication ​

MethodDescription
Bearer TokenInclude Authorization: Bearer <API_key> in the request header to authenticate your account.

Request Headers ​

ParameterTypeRequiredDescription
Content-TypestringYesThe media type of the request body. Set it to application/json
AuthorizationstringYesBearer API_key, used to authenticate your account

Supported Model IDs ​

  • qwen-image-3.0-pro: The 3.0 Pro model. Supports text-to-image and image-to-image, with up to 3 reference images for image-to-image
  • qwen-image-3.0: The 3.0 standard model, balancing quality and speed. Supports up to 3 reference images for image-to-image
  • qwen-image-2.1-pro: The 2.1 Pro model. Supports up to 10 reference images and can generate standard images or images with a transparent channel based on the prompt
  • qwen-image-2.1-turbo: The 2.1 Turbo model, balancing overall performance and cost efficiency. Supports up to 10 reference images and can generate standard images or images with a transparent channel based on the prompt

Available models, resolutions, and reference image limits depend on the platform.

Request Body ​

ParameterTypeRequiredDefaultDescription
modelstringYes-Model ID. See "Supported Model IDs" above
inputobjectYes-Input object containing the message content. See the subtable below
parametersobjectNo-Additional image generation parameters. See the subtable below

input Parameters ​

ParameterTypeRequiredDescription
input.messagesarrayYesRequest messages. Only single-turn conversations are supported, so the array must contain exactly one message object
input.messages[].rolestringYesMessage sender role. Must be set to user
input.messages[].contentarrayYesMessage content consisting of text and optional reference images. See the subtable below

content Parameters ​

ParameterTypeRequiredDescription
input.messages[].content[].textstringYesPositive prompt describing the desired image content, style, composition, or editing instruction. Chinese and English are supported; no more than 4,500 tokens is recommended. Exactly one text object is required
input.messages[].content[].imagestringConditionalPublic URL or Base64-encoded data of a reference image. Omit for text-to-image and required for image-to-image. Multiple image objects are allowed; array order defines image order

For text-to-image, content contains only one text object. For image-to-image, it contains one text object and the reference image objects. The qwen-image-2.1 series supports 1–10 reference images, while the qwen-image-3.0 series supports 1–3.

Reference image requirements:

  • Formats: JPG, JPEG, PNG, BMP, TIFF, WEBP, and GIF
  • Dimensions: Both width and height must be between 1 and 8,000 pixels; 384–2,048 pixels is recommended for best results
  • Aspect ratio: The ratio of the longest side to the shortest side must not exceed 10:1
  • File size: No more than 10 MB
  • Public URL: HTTP and HTTPS are supported
  • Base64: Use data:{MIME_type};base64,{base64_data}, for example, data:image/png;base64,<Base64 Code>

parameters Parameters ​

ParameterTypeRequiredDefaultDescription
parameters.prompt_extendbooleanNotrueWhether to enable intelligent prompt rewriting. Recommended. When enabled, the positive prompt is optimized using the method specified by prompt_extend_mode
parameters.prompt_extend_modestringNodirectPrompt rewriting method: direct (Direct Prompt Enhancement, supported for both text-to-image and image-to-image); agent (Agent Prompt Enhancement, only supported for text-to-image; using it for image-to-image returns a 400 error)
parameters.enable_thinkingbooleanNotrueWhether to enable thinking mode. It enhances reasoning but increases generation time. Only takes effect when prompt_extend=true; not supported for I2I Agent
parameters.nintegerNo1Number of images to generate, from 1 to 6. Must be an integer
parameters.sizestringNoAutomatically recommendedOutput image resolution in width*height format, for example, 1024*1024. If omitted, the model recommends a resolution based on the prompt
parameters.negative_promptstringNo-Negative prompt describing content that should not appear in the image. Only supported by the qwen-image-3.0 series
parameters.seedintegerNoRandomRandom seed in the range [0, 2147483647]. A fixed seed makes results relatively stable
parameters.watermarkbooleanNofalseWhether to add a watermark to the image

Output image dimensions:

  • For both text-to-image and image-to-image, the total pixel area must be between 512*512 and 2048*2048.
  • The output aspect ratio must be between 1:8 and 8:1.
  • The output image format is PNG.
  • Use an asterisk *, not the letter x, to separate width and height in size.

Image generation can take a long time. Configure a sufficiently long client timeout. For multiple output images or concurrent requests, a timeout of 600 seconds or more is recommended.

Request Examples ​

Text-to-Image ​

Pass only a text prompt in content to generate an image.

bash
curl --location --request POST 'https://neolink.com/api/v1/images/generations' \
     --header 'Content-Type: application/json' \
     --header 'Authorization: Bearer <API Key>' \
     --data-raw '{
         "model": "<Model ID>",
         "input": {
             "messages": [
                 {
                     "role": "user",
                     "content": [
                         {
                             "text": "A cute orange cat wearing round-framed glasses, sitting by the windowsill reading a newspaper in warm afternoon sunlight"
                         }
                     ]
                 }
             ]
         },
         "parameters": {
             "n": 1,
             "size": "1024*1024",
             "prompt_extend": true,
             "watermark": false
         }
     }'
python
import requests

url = "https://neolink.com/api/v1/images/generations"

headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer <API Key>",
}

payload = {
    "model": "<Model ID>",
    "input": {
        "messages": [
            {
                "role": "user",
                "content": [
                    {
                        "text": "A cute orange cat wearing round-framed glasses, sitting by the windowsill reading a newspaper in warm afternoon sunlight"
                    }
                ],
            }
        ]
    },
    "parameters": {
        "n": 1,
        "size": "1024*1024",
        "prompt_extend": True,
        "watermark": False,
    },
}

response = requests.post(url, headers=headers, json=payload, timeout=600)
response.raise_for_status()
result = response.json()
print(result)

Image-to-Image (Image Editing) ​

Pass both a reference image and an editing instruction in content. The model generates an image based on the reference.

bash
curl --location --request POST 'https://neolink.com/api/v1/images/generations' \
     --header 'Content-Type: application/json' \
     --header 'Authorization: Bearer <API Key>' \
     --data-raw '{
         "model": "<Model ID>",
         "input": {
             "messages": [
                 {
                     "role": "user",
                     "content": [
                         {
                             "image": "https://example.com/reference-cat.png"
                         },
                         {
                             "text": "Place the cat from the reference image in a seaside sunset scene, keeping a photorealistic style"
                         }
                     ]
                 }
             ]
         },
         "parameters": {
             "n": 1,
             "size": "1024*1024",
             "prompt_extend": true,
             "watermark": false
         }
     }'
python
import requests

url = "https://neolink.com/api/v1/images/generations"

headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer <API Key>",
}

payload = {
    "model": "<Model ID>",
    "input": {
        "messages": [
            {
                "role": "user",
                "content": [
                    {"image": "https://example.com/reference-cat.png"},
                    {"text": "Place the cat from the reference image in a seaside sunset scene, keeping a photorealistic style"},
                ],
            }
        ]
    },
    "parameters": {
        "n": 1,
        "size": "1024*1024",
        "prompt_extend": True,
        "watermark": False,
    },
}

response = requests.post(url, headers=headers, json=payload, timeout=600)
response.raise_for_status()
result = response.json()

for choice in result["output"]["choices"]:
    for item in choice["message"]["content"]:
        if "image" in item:
            print(item["image"])

Response Body ​

ParameterTypeDescription
outputobjectModel generation results
output.rewrite_statusstringPrompt rewriting status, determined by whether rewriting is enabled and its execution result
output.choicesarrayResult choices
output.choices[].finish_reasonstringReason the task stopped; stop for natural completion
output.choices[].messageobjectMessage returned by the model
output.choices[].message.rolestringMessage role, always assistant
output.choices[].message.contentarrayMessage content containing generated image information
output.choices[].message.content[].imagestringURL of the generated PNG image. The link is valid for 24 hours
usageobjectImage input/output metering information for this call, not token usage. Returned only on success
usage.output_widthintegerFinal output image width in pixels. Only returned by the qwen-image-3.0 series
usage.output_heightintegerFinal output image height in pixels. Only returned by the qwen-image-3.0 series
usage.input_image_countintegerNumber of input images: 0 for text-to-image, or the actual count for image-to-image. Only returned by the qwen-image-3.0 series
usage.input_image_typestringInput image metering tier: qima_input_1k when the output pixel area is no more than 2,250,000, otherwise qima_input_2k. Only returned by the qwen-image-3.0 series
usage.output_image_countintegerActual number of output images returned. Only returned by the qwen-image-3.0 series
usage.output_image_typestringOutput image metering tier: qima_output_1k when the output pixel area is no more than 2,250,000, otherwise qima_output_2k. Only returned by the qwen-image-3.0 series
usage.image_countintegerNumber of images generated by the model. Only returned by the qwen-image-2.1 series
usage.widthintegerGenerated image width in pixels. Only returned by the qwen-image-2.1 series
usage.heightintegerGenerated image height in pixels. Only returned by the qwen-image-2.1 series
request_idstringUnique request identifier for tracing and troubleshooting
codestringError code for a failed request. Not returned on success
messagestringDetailed error message for a failed request. Not returned on success

Response Examples ​

Generated image URLs and task data are retained for only 24 hours. Download and save images promptly.

json
{
  "output": {
    "choices": [
      {
        "finish_reason": "stop",
        "message": {
          "role": "assistant",
          "content": [
            {
              "image": "https://.../generated.png"
            }
          ]
        }
      }
    ]
  },
  "usage": {
    "output_height": 1024,
    "output_width": 1024,
    "input_image_count": 0,
    "input_image_type": "qima_input_1k",
    "output_image_count": 1,
    "output_image_type": "qima_output_1k"
  },
  "request_id": "571ae02f-5c9d-436c-83c2-f221e6df0xxx"
}
json
{
  "output": {
    "choices": [
      {
        "finish_reason": "stop",
        "message": {
          "role": "assistant",
          "content": [
            {
              "image": "https://.../generated.png"
            }
          ]
        }
      }
    ]
  },
  "usage": {
    "image_count": 1,
    "width": 1024,
    "height": 1024
  },
  "request_id": "571ae02f-5c9d-436c-83c2-f221e6df0xxx"
}
json
{
  "request_id": "31f808fd-8eef-9004-xxxxx",
  "code": "InvalidApiKey",
  "message": "Invalid API-key provided."
}