Skip to main content
Image editing

Qwen

Edit images via text

POST
/services/aigc/multimodal-generation/generation
curl --location 'https://maas.qwencloudapi.com/api/v1/services/aigc/multimodal-generation/generation' \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer $DASHSCOPE_API_KEY" \
--data '{
  "model": "qwen-image-3.0-pro",
  "input": {
    "messages": [
      {
        "role": "user",
        "content": [
          {
            "image": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/fpakfo/image36.webp"
          },
          {
            "text": "Generate an image that matches the depth map, following this description: A dilapidated red bicycle is parked on a muddy path with a dense primeval forest in the background."
          }
        ]
      }
    ]
  },
  "parameters": {
    "n": 2,
    "negative_prompt": " ",
    "prompt_extend": true,
    "watermark": false,
    "size": "1536*1024"
  }
}'
{
  "output": {
    "rewrite_status": "not_use",
    "choices": [
      {
        "finish_reason": "stop",
        "message": {
          "content": [
            {
              "image": "https://dashscope-result-sz.oss-cn-shenzhen.aliyuncs.com/xxx.png?Expires=xxx"
            },
            {
              "image": "https://dashscope-result-sz.oss-cn-shenzhen.aliyuncs.com/xxx.png?Expires=xxx"
            }
          ],
          "role": "assistant"
        }
      }
    ]
  },
  "usage": {
    "output_height": 1024,
    "output_width": 1536,
    "input_image_count": 1,
    "input_image_type": "qima_input_1k",
    "output_image_count": 2,
    "output_image_type": "qima_output_1k"
  },
  "request_id": "bf37ca26-0abe-98e4-8065-xxxxxx"
}

Download the result image

The image URL in the response is valid for 24 hours. Download it promptly after the task succeeds.
Download an image from a URL
# You need to install requests to download the image: pip install requests
import requests

def download_image(image_url, save_path='output.png'):
    try:
        response = requests.get(image_url, stream=True, timeout=300)  # Set a timeout.
        response.raise_for_status()  # Raise an exception if the HTTP status code is not 200.
        with open(save_path, 'wb') as f:
            for chunk in response.iter_content(chunk_size=8192):
                f.write(chunk)
        print(f"Image successfully downloaded to: {save_path}")

    except requests.exceptions.RequestException as e:
        print(f"Image download failed: {e}")

image_url = "https://dashscope-result-sz.oss-cn-shenzhen.aliyuncs.com/xxx.png?Expires=xxx"
download_image(image_url, save_path='output.png')
ImageDownloader
import java.io.FileOutputStream;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;

public class ImageDownloader {
    public static void downloadImage(String imageUrl, String savePath) {
        try {
            URL url = new URL(imageUrl);
            HttpURLConnection connection = (HttpURLConnection) url.openConnection();
            connection.setConnectTimeout(5000);
            connection.setReadTimeout(300000);
            connection.setRequestMethod("GET");
            InputStream inputStream = connection.getInputStream();
            FileOutputStream outputStream = new FileOutputStream(savePath);
            byte[] buffer = new byte[8192];
            int bytesRead;
            while ((bytesRead = inputStream.read(buffer)) != -1) {
                outputStream.write(buffer, 0, bytesRead);
            }
            inputStream.close();
            outputStream.close();

            System.out.println("Image downloaded successfully to: " + savePath);
        } catch (Exception e) {
            System.err.println("Image download failed: " + e.getMessage());
        }
    }

    public static void main(String[] args) {
        String imageUrl = "http://dashscope-result-bj.oss-cn-beijing.aliyuncs.com/xxx?Expires=xxx";
        String savePath = "output.png";
        downloadImage(imageUrl, savePath);
    }
}

Authorizations

string
header
required

DashScope API Key. Create one in the QwenCloud console.

Body

application/json
enum<string>
required

Model name.

qwen-image-3.0-pro,qwen-image-3.0,qwen-image-2.0-pro,qwen-image-2.0-pro-2026-06-22,qwen-image-2.0-pro-2026-04-22,qwen-image-2.0-pro-2026-03-03,qwen-image-2.0,qwen-image-2.0-2026-03-03,qwen-image-edit-max,qwen-image-edit-max-2026-01-16,qwen-image-edit-plus,qwen-image-edit-plus-2025-12-15,qwen-image-edit-plus-2025-10-30,qwen-image-edit
qwen-image-3.0-pro
object
required

Input data containing the messages array.

object

Image editing parameters.

Response

200-application/json
object
object

Usage statistics (successful results only). Fields vary by model series: the qwen-image-3.0 series returns the output_* / input_* fields; other series return image_count / width / height.

string
default"bf37ca26-0abe-98e4-8065-xxxxxx"

Unique request identifier for tracing and troubleshooting.

bf37ca26-0abe-98e4-8065-xxxxxx
Qwen - QwenCloud