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
modelparameter. The parameter descriptions below apply to Qwen image models.
Endpoint
POST /v1/images/generationsAuthentication
| Method | Description |
|---|---|
| Bearer Token | Include Authorization: Bearer <API_key> in the request header to authenticate your account. |
Request Headers
| Parameter | Type | Required | Description |
|---|---|---|---|
Content-Type | string | Yes | The media type of the request body. Set it to application/json |
Authorization | string | Yes | Bearer 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-imageqwen-image-3.0: The 3.0 standard model, balancing quality and speed. Supports up to 3 reference images for image-to-imageqwen-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 promptqwen-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
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
model | string | Yes | - | Model ID. See "Supported Model IDs" above |
input | object | Yes | - | Input object containing the message content. See the subtable below |
parameters | object | No | - | Additional image generation parameters. See the subtable below |
input Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
input.messages | array | Yes | Request messages. Only single-turn conversations are supported, so the array must contain exactly one message object |
input.messages[].role | string | Yes | Message sender role. Must be set to user |
input.messages[].content | array | Yes | Message content consisting of text and optional reference images. See the subtable below |
content Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
input.messages[].content[].text | string | Yes | Positive 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[].image | string | Conditional | Public 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
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
parameters.prompt_extend | boolean | No | true | Whether to enable intelligent prompt rewriting. Recommended. When enabled, the positive prompt is optimized using the method specified by prompt_extend_mode |
parameters.prompt_extend_mode | string | No | direct | Prompt 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_thinking | boolean | No | true | Whether to enable thinking mode. It enhances reasoning but increases generation time. Only takes effect when prompt_extend=true; not supported for I2I Agent |
parameters.n | integer | No | 1 | Number of images to generate, from 1 to 6. Must be an integer |
parameters.size | string | No | Automatically recommended | Output image resolution in width*height format, for example, 1024*1024. If omitted, the model recommends a resolution based on the prompt |
parameters.negative_prompt | string | No | - | Negative prompt describing content that should not appear in the image. Only supported by the qwen-image-3.0 series |
parameters.seed | integer | No | Random | Random seed in the range [0, 2147483647]. A fixed seed makes results relatively stable |
parameters.watermark | boolean | No | false | Whether 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*512and2048*2048. - The output aspect ratio must be between 1:8 and 8:1.
- The output image format is PNG.
- Use an asterisk
*, not the letterx, to separate width and height insize.
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.
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
}
}'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.
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
}
}'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
| Parameter | Type | Description |
|---|---|---|
output | object | Model generation results |
output.rewrite_status | string | Prompt rewriting status, determined by whether rewriting is enabled and its execution result |
output.choices | array | Result choices |
output.choices[].finish_reason | string | Reason the task stopped; stop for natural completion |
output.choices[].message | object | Message returned by the model |
output.choices[].message.role | string | Message role, always assistant |
output.choices[].message.content | array | Message content containing generated image information |
output.choices[].message.content[].image | string | URL of the generated PNG image. The link is valid for 24 hours |
usage | object | Image input/output metering information for this call, not token usage. Returned only on success |
usage.output_width | integer | Final output image width in pixels. Only returned by the qwen-image-3.0 series |
usage.output_height | integer | Final output image height in pixels. Only returned by the qwen-image-3.0 series |
usage.input_image_count | integer | Number 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_type | string | Input 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_count | integer | Actual number of output images returned. Only returned by the qwen-image-3.0 series |
usage.output_image_type | string | Output 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_count | integer | Number of images generated by the model. Only returned by the qwen-image-2.1 series |
usage.width | integer | Generated image width in pixels. Only returned by the qwen-image-2.1 series |
usage.height | integer | Generated image height in pixels. Only returned by the qwen-image-2.1 series |
request_id | string | Unique request identifier for tracing and troubleshooting |
code | string | Error code for a failed request. Not returned on success |
message | string | Detailed 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.
{
"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"
}{
"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"
}{
"request_id": "31f808fd-8eef-9004-xxxxx",
"code": "InvalidApiKey",
"message": "Invalid API-key provided."
}