通义千问-图像编辑API参考

通义千问-图像编辑模型(qwen-image-edit)支持多图编辑,可精确修改图内文字、增删或移动物体、改变主体动作、迁移图片风格及增强画面细节。

快速入口:使用指南 | 技术博客 | 在线体验

效果展示

多图图像修改展示器
输入图1
输入图2
输入图3

HTTP调用

在调用前,您需要获取API Key,再配置API Key到环境变量

如需通过SDK进行调用,请安装DashScope SDK。目前,该SDK已支持PythonJava。

重要

北京和新加坡地域拥有独立的 API Key 请求地址,不可混用,跨地域调用将导致鉴权失败或服务报错。

北京地域POST https://dashscope.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation

新加坡地域POST https://dashscope-intl.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation

请求参数

单图编辑

以下为北京地域 URL ,若使用新加坡地域的模型,需将 URL 替换为:https://dashscope-intl.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation

curl --location 'https://dashscope.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation' \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer $DASHSCOPE_API_KEY" \
--data '{
    "model": "qwen-image-edit",
    "input": {
        "messages": [
            {
                "role": "user",
                "content": [
                    {
                        "image": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/fpakfo/image36.webp"
                    },
                    {
                        "text": "生成一张符合深度图的图像,遵循以下描述:一辆红色的破旧的自行车停在一条泥泞的小路上,背景是茂密的原始森林"
                    }
                ]
            }
        ]
    },
    "parameters": {
        "negative_prompt": " ",
        "watermark": false
    }
}'

多图融合

以下为北京地域 URL ,若使用新加坡地域的模型,需将 URL 替换为:https://dashscope-intl.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation

curl --location 'https://dashscope.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation' \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer $DASHSCOPE_API_KEY" \
--data '{
    "model": "qwen-image-edit",
    "input": {
        "messages": [
            {
                "role": "user",
                "content": [
                    {
                        "image": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/thtclx/input1.png"
                    },
                    {
                        "image": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/iclsnx/input2.png"
                    },
                    {
                        "image": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/gborgw/input3.png"
                    },
                    {
                        "text": "图1中的女生穿着图2中的黑色裙子按图3的姿势坐下"
                    }
                ]
            }
        ]
    },
    "parameters": {
        "negative_prompt": " ",
        "watermark": false
    }
}'
请求头(Headers)

Content-Type string (必选)

请求内容类型。此参数必须设置为application/json

Authorization string(必选)

请求身份认证。接口使用阿里云百炼API-Key进行身份认证。示例值:Bearer sk-xxxx。

请求体(Request Body)

model string (必选)

模型名称,固定为qwen-image-edit

input object (必选)

输入参数对象,包含以下字段:

属性

messages array (必选)

请求内容。为兼容多轮对话接口,采用数组格式。当前仅支持单轮对话,因此数组内有且只有一个对象,该对象包含rolecontent两个属性。

属性

role string (必选)

消息发送者角色,必须设置为user

content array (必选)

消息内容,包含1-3张图像,格式为 {"image": "..."};以及单个编辑指令,格式为 {"text": "..."}

属性

image string (必选)

输入图像的 URL 或 Base64 编码数据。支持传入1-3张图像。

图像要求:

  • 图像格式:JPG、JPEG、PNG、BMP、TIFF、WEBP。

  • 图像分辨率:图像的宽度和高度均需在384-3072像素范围内。

  • 图像大小:不超过10MB。

  • URL地址若包含中文等非ASCII字符,需进行URL编码后再传入。

    URL编码

    from urllib.parse import quote
    
    # 请替换下面的URL为需要编码的URL
    url = "https://example.com/搜索?q=测试&page=1"
    encoded_url = quote(url, safe=':/?#[]@!$&\'()*+,;=%')
    print(f"原始URL: {url}")
    print(f"编码后的URL: {encoded_url}")

传入方式1:公网URL:公网可访问的HTTPHTTPS图像地址。本地文件请参见上传文件获取临时 URL

  • 示例值:https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/fpakfo/image36.webp

传入方式2:Base64编码:字符串需遵循data:{mime_type};base64,{base64_data}格式。

  • {mime_type}:图像的媒体类型,需与文件格式对应。

  • {base64_data}:文件经过 Base64 编码后的字符串。

  • 图像格式与{mime_type}类型对应关系:

    • JPEG/JPG:image/jpeg

    • PNG:image/png

    • BMP:image/bmp

    • TIFF:image/tiff

    • WEBP:image/webp

  • 点击查看图片Base64编码代码示例

    import os
    import base64
    import mimetypes
    
    # 格式为 data:{mime_type};base64,{base64_data}
    def encode_file(file_path):
        mime_type, _ = mimetypes.guess_type(file_path)
        with open(file_path, "rb") as image_file:
            encoded_string = base64.b64encode(image_file.read()).decode('utf-8')
        return f"data:{mime_type};base64,{encoded_string}"
            
            
    # 调用编码函数,请将 "/path/to/your/image.png" 替换为您的本地图片文件路径,否则无法运行
    image = encode_file("/path/to/your/image.png")
  • 示例值:data:image/jpeg;base64,GDU7MtCZz...(示例已截断,仅做演示)

完整示例代码请参见Python SDK调用Java SDK调用

text string (必选)

图像编辑指令,即正向提示词,用来描述生成图像中期望包含的元素和视觉特点。

进行多图像编辑时,编辑指令中需要使用“图1”、“图2”、“图3”等描述来指代相应的图片,否则会出现不符合预期的编辑结果。

支持中英文,长度上限800个字符,每个汉字/字母占一个字符,超过部分会自动截断。

示例值:图1中的女生穿着图2中的黑色裙子按图3的姿势坐下,保持其服装、发型和表情不变,动作自然流畅。

parameters object (可选)

控制图像生成的附加参数。

属性

negative_prompt string (可选)

反向提示词,用来描述不希望在画面中看到的内容,可以对画面进行限制。

支持中英文,长度上限500个字符,每个汉字/字母占一个字符,超过部分会自动截断。

示例值:低分辨率、错误、最差质量、低质量、残缺、多余的手指、比例不良等。

watermark boolean (可选)

是否在图像右下角添加 "Qwen-Image" 水印1。默认为 false

seed integer (可选)

随机数种子,取值范围[0,2147483647]

使用相同的seed参数值可使生成内容保持相对稳定。若不提供,算法将自动使用随机数种子。

注意:模型生成过程具有概率性,即使使用相同的seed,也不能保证每次生成结果完全一致。

响应参数

任务执行成功

任务数据(如任务状态、图像URL等)仅保留24小时,超时后会被自动清除。请您务必及时保存生成的图像。

{
    "output": {
        "choices": [
            {
                "finish_reason": "stop",
                "message": {
                    "role": "assistant",
                    "content": [
                        {
                            "image": "https://dashscope-result-sz.oss-cn-shenzhen.aliyuncs.com/xxx.png?Expires=xxx"
                        }
                    ]
                }
            }
        ]
    },
    "usage": {
        "width": 1248,
        "image_count": 1,
        "height": 832
    },
    "request_id": "bf37ca26-0abe-98e4-8065-xxxxxx"
}

任务执行异常

如果因为某种原因导致任务执行失败,将返回相关信息,可以通过codemessage字段明确指示错误原因。请参见错误信息进行解决。

{
    "request_id": "31f808fd-8eef-9004-xxxxx",
    "code": "InvalidApiKey",
    "message": "Invalid API-key provided."
}

output object

包含模型生成结果。

属性

choices array

结果选项列表。

属性

finish_reason string

任务停止原因,自然停止时为stop

message object

模型返回的消息。

属性

role string

消息的角色,固定为assistant

content array

消息内容,包含生成的图像信息。

属性

image string

生成图像的 URL。链接有效期为24小时,请及时下载并保存图像。

图像格式为PNG,与原图的长宽比保持一致,接近1024*1024分辨率。

usage object

本次调用的资源使用情况,仅调用成功时返回。

属性

image_count integer

生成的图像数量,固定为1。

width integer

生成图像的宽度(像素)。

height integer

生成图像的高度(像素)。

request_id string

请求唯一标识。可用于请求明细溯源和问题排查。

code string

请求失败的错误码。请求成功时不会返回此参数,详情请参见错误信息

message string

请求失败的详细信息。请求成功时不会返回此参数,详情请参见错误信息

DashScope SDK调用

SDK 的参数命名与HTTP接口基本一致,参数结构根据语言特性进行封装,完整参数列表请参见通义千问 API 参考

Python SDK调用

说明
  • 推荐安装最新版DashScope Python SDK,否则可能运行报错:安装或升级SDK

  • 不支持异步接口。

请求示例

通过公网URL传入图片

import json
import os
from dashscope import MultiModalConversation
import dashscope

# 以下为中国(北京)地域url,若使用新加坡地域的模型,需将url替换为:https://dashscope-intl.aliyuncs.com/api/v1
dashscope.base_http_api_url = 'https://dashscope.aliyuncs.com/api/v1'

# 模型支持输入1-3张图片
messages = [
    {
        "role": "user",
        "content": [
            {"image": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/thtclx/input1.png"},
            {"image": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/iclsnx/input2.png"},
            {"image": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/gborgw/input3.png"},
            {"text": "图1中的女生穿着图2中的黑色裙子按图3的姿势坐下"}
        ]
    }
]

# 新加坡和北京地域的API Key不同。获取API Key:https://help.aliyun.com/zh/model-studio/get-api-key
# 若没有配置环境变量,请用百炼 API Key 将下行替换为:api_key="sk-xxx"
api_key = os.getenv("DASHSCOPE_API_KEY")

# 模型仅支持单轮对话,复用了多轮对话的接口
response = MultiModalConversation.call(
    api_key=api_key,
    model="qwen-image-edit",
    messages=messages,
    stream=False,
    watermark=False,
    negative_prompt=" "
)

if response.status_code == 200:
    # 如需查看完整响应,请取消下行注释
    # print(json.dumps(response, ensure_ascii=False))
    print("输出图像的URL:", response.output.choices[0].message.content[0]['image'])
else:
    print(f"HTTP返回码:{response.status_code}")
    print(f"错误码:{response.code}")
    print(f"错误信息:{response.message}")
    print("请参考文档:https://help.aliyun.com/zh/model-studio/developer-reference/error-code")

通过Base64编码传入图片

import json
import os
from dashscope import MultiModalConversation
import base64
import mimetypes
import dashscope

# 以下为中国(北京)地域url,若使用新加坡地域的模型,需将url替换为:https://dashscope-intl.aliyuncs.com/api/v1
dashscope.base_http_api_url = 'https://dashscope.aliyuncs.com/api/v1'

# ---用于 Base64 编码 ---
# 格式为 data:{mime_type};base64,{base64_data}
def encode_file(file_path):
    mime_type, _ = mimetypes.guess_type(file_path)
    if not mime_type or not mime_type.startswith("image/"):
        raise ValueError("不支持或无法识别的图像格式")

    try:
        with open(file_path, "rb") as image_file:
            encoded_string = base64.b64encode(
                image_file.read()).decode('utf-8')
        return f"data:{mime_type};base64,{encoded_string}"
    except IOError as e:
        raise IOError(f"读取文件时出错: {file_path}, 错误: {str(e)}")


# 获取图像的 Base64 编码
# 调用编码函数,请将 "/path/to/your/image.png" 替换为您的本地图片文件路径,否则无法运行
image = encode_file("/path/to/your/image.png")

messages = [
    {
        "role": "user",
        "content": [
            {"image": image},
            {"text": "生成一张符合深度图的图像,遵循以下描述:一辆红色的破旧的自行车停在一条泥泞的小路上,背景是茂密的原始森林"}
        ]
    }
]

# 新加坡和北京地域的API Key不同。获取API Key:https://help.aliyun.com/zh/model-studio/get-api-key
# 若没有配置环境变量,请用百炼 API Key 将下行替换为:api_key="sk-xxx"
api_key = os.getenv("DASHSCOPE_API_KEY")


# 模型仅支持单轮对话,复用了多轮对话的接口
response = MultiModalConversation.call(
    api_key=api_key,
    model="qwen-image-edit",
    messages=messages,
    stream=False,
    watermark=False,
    negative_prompt=" "
)

if response.status_code == 200:
    # 如需查看完整响应,请取消下行注释
    # print(json.dumps(response, ensure_ascii=False))
    print("输出图像的URL:", response.output.choices[0].message.content[0]['image'])
else:
    print(f"HTTP返回码:{response.status_code}")
    print(f"错误码:{response.code}")
    print(f"错误信息:{response.message}")
    print("请参考文档:https://help.aliyun.com/zh/model-studio/developer-reference/error-code")

通过URL下载图像

# 需要安装requests以下载图像: pip install requests
import requests


def download_image(image_url, save_path='output.png'):
    try:
        response = requests.get(image_url, stream=True, timeout=300)  # 设置超时
        response.raise_for_status()  # 如果HTTP状态码不是200,则引发异常
        with open(save_path, 'wb') as f:
            for chunk in response.iter_content(chunk_size=8192):
                f.write(chunk)
        print(f"图像已成功下载到: {save_path}")

    except requests.exceptions.RequestException as e:
        print(f"图像下载失败: {e}")


image_url = "https://dashscope-result-sz.oss-cn-shenzhen.aliyuncs.com/xxx.png?Expires=xxx"
download_image(image_url, save_path='output.png')

响应示例

图像链接的有效期为24小时,请及时下载图像。

input_tokensoutput_tokens为兼容字段,当前固定为0。
{
    "status_code": 200,
    "request_id": "3daccb10-10ca-9399-8b6a-xxxxxx",
    "code": "",
    "message": "",
    "output": {
        "text": null,
        "finish_reason": null,
        "choices": [
            {
                "finish_reason": "stop",
                "message": {
                    "role": "assistant",
                    "content": [
                        {
                            "image": "https://dashscope-result-sz.oss-cn-shenzhen.aliyuncs.com/xxx.png?Expires=xxx"
                        }
                    ]
                }
            }
        ]
    },
    "usage": {
        "input_tokens": 0,
        "output_tokens": 0,
        "width": 1248,
        "image_count": 1,
        "height": 832
    }
}

Java SDK调用

说明

推荐安装最新版DashScope Java SDK,否则可能运行报错:安装或升级SDK

请求示例

通过公网URL传入图片

import com.alibaba.dashscope.aigc.multimodalconversation.MultiModalConversation;
import com.alibaba.dashscope.aigc.multimodalconversation.MultiModalConversationParam;
import com.alibaba.dashscope.aigc.multimodalconversation.MultiModalConversationResult;
import com.alibaba.dashscope.common.MultiModalMessage;
import com.alibaba.dashscope.common.Role;
import com.alibaba.dashscope.exception.ApiException;
import com.alibaba.dashscope.exception.NoApiKeyException;
import com.alibaba.dashscope.exception.UploadFileException;
import com.alibaba.dashscope.utils.Constants;
import com.alibaba.dashscope.utils.JsonUtils;

import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

public class QwenImageEdit {

    static {
        // 以下为中国(北京)地域url,若使用新加坡地域的模型,需将url替换为:https://dashscope-intl.aliyuncs.com/api/v1
        Constants.baseHttpApiUrl = "https://dashscope.aliyuncs.com/api/v1";
    }
    
    // 新加坡和北京地域的API Key不同。获取API Key:https://help.aliyun.com/zh/model-studio/get-api-key
    // 若没有配置环境变量,请用百炼 API Key 将下行替换为:apiKey="sk-xxx"
    static String apiKey = System.getenv("DASHSCOPE_API_KEY");

    public static void call() throws ApiException, NoApiKeyException, UploadFileException, IOException {

        MultiModalConversation conv = new MultiModalConversation();

        // 模型支持输入1-3张图片
        MultiModalMessage userMessage = MultiModalMessage.builder().role(Role.USER.getValue())
                .content(Arrays.asList(
                        Collections.singletonMap("image", "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/thtclx/input1.png"),
                        Collections.singletonMap("image", "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/iclsnx/input2.png"),
                        Collections.singletonMap("image", "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/gborgw/input3.png"),
                        Collections.singletonMap("text", "图1中的女生穿着图2中的黑色裙子按图3的姿势坐下")
                )).build();

        Map<String, Object> parameters = new HashMap<>();
        parameters.put("watermark", false);
        parameters.put("negative_prompt", " ");

        MultiModalConversationParam param = MultiModalConversationParam.builder()
                .apiKey(apiKey)
                .model("qwen-image-edit")
                .messages(Collections.singletonList(userMessage))
                .parameters(parameters)
                .build();

        MultiModalConversationResult result = conv.call(param);
        // 如需查看完整响应,请取消下行注释
        // System.out.println(JsonUtils.toJson(result));
        System.out.println("输出图像的URL:" + result.getOutput().getChoices().get(0).getMessage().getContent().get(0).get("image"));
    }

    public static void main(String[] args) {
        try {
            call();
        } catch (ApiException | NoApiKeyException | UploadFileException | IOException e) {
            System.out.println(e.getMessage());
        }
    }
}

通过Base64编码传入图片

import com.alibaba.dashscope.aigc.multimodalconversation.MultiModalConversation;
import com.alibaba.dashscope.aigc.multimodalconversation.MultiModalConversationParam;
import com.alibaba.dashscope.aigc.multimodalconversation.MultiModalConversationResult;
import com.alibaba.dashscope.common.MultiModalMessage;
import com.alibaba.dashscope.common.Role;
import com.alibaba.dashscope.exception.ApiException;
import com.alibaba.dashscope.exception.NoApiKeyException;
import com.alibaba.dashscope.exception.UploadFileException;
import com.alibaba.dashscope.utils.Constants;
import com.alibaba.dashscope.utils.JsonUtils;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.Base64;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

public class QwenImageEdit {
     
    static {
        // 以下为中国(北京)地域url,若使用新加坡地域的模型,需将url替换为:https://dashscope-intl.aliyuncs.com/api/v1
        Constants.baseHttpApiUrl = "https://dashscope.aliyuncs.com/api/v1";
    }
    
    // 新加坡和北京地域的API Key不同。获取API Key:https://help.aliyun.com/zh/model-studio/get-api-key
    // 若没有配置环境变量,请用百炼 API Key 将下行替换为:apiKey="sk-xxx"
    static String apiKey = System.getenv("DASHSCOPE_API_KEY");

    public static void call() throws ApiException, NoApiKeyException, UploadFileException, IOException {

        // 请将 "/path/to/your/image.png" 替换为您的本地图片文件路径,否则无法运行
        String image = encodeFile("/path/to/your/image.png");

        MultiModalConversation conv = new MultiModalConversation();

        MultiModalMessage userMessage = MultiModalMessage.builder().role(Role.USER.getValue())
                .content(Arrays.asList(
                        Collections.singletonMap("image", image),
                        Collections.singletonMap("text", "生成一张符合深度图的图像,遵循以下描述:一辆红色的破旧的自行车停在一条泥泞的小路上,背景是茂密的原始森林")
                )).build();

        Map<String, Object> parameters = new HashMap<>();
        parameters.put("watermark", false);
        parameters.put("negative_prompt", " ");

        MultiModalConversationParam param = MultiModalConversationParam.builder()
                .apiKey(apiKey)
                .model("qwen-image-edit")
                .messages(Collections.singletonList(userMessage))
                .parameters(parameters)
                .build();

        MultiModalConversationResult result = conv.call(param);
        // 如需查看完整响应,请取消下行注释
        // System.out.println(JsonUtils.toJson(result));
        System.out.println("输出图像的URL:" + result.getOutput().getChoices().get(0).getMessage().getContent().get(0).get("image"));
    }

    /**
     * 将文件编码为Base64字符串
     * @param filePath 文件路径
     * @return Base64字符串,格式为 data:{mime_type};base64,{base64_data}
     */
    public static String encodeFile(String filePath) {
        Path path = Paths.get(filePath);
        if (!Files.exists(path)) {
            throw new IllegalArgumentException("文件不存在: " + filePath);
        }
        // 检测MIME类型
        String mimeType = null;
        try {
            mimeType = Files.probeContentType(path);
        } catch (IOException e) {
            throw new IllegalArgumentException("无法检测文件类型: " + filePath);
        }
        if (mimeType == null || !mimeType.startsWith("image/")) {
            throw new IllegalArgumentException("不支持或无法识别的图像格式");
        }
        // 读取文件内容并编码
        byte[] fileBytes = null;
        try{
            fileBytes = Files.readAllBytes(path);
        } catch (IOException e) {
            throw new IllegalArgumentException("无法读取文件内容: " + filePath);
        }

        String encodedString = Base64.getEncoder().encodeToString(fileBytes);
        return "data:" + mimeType + ";base64," + encodedString;
    }

    public static void main(String[] args) {
        try {
            call();
        } catch (ApiException | NoApiKeyException | UploadFileException | IOException e) {
            System.out.println(e.getMessage());
        }
    }
}

通过URL下载图像

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("图像已成功下载到: " + savePath);
        } catch (Exception e) {
            System.err.println("图像下载失败: " + 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);
    }
}

响应示例

图像链接的有效期为24小时,请及时下载图像。

{
    "requestId": "9e59e2da-28b0-9468-b356-5d2beea8a477",
    "usage": {},
    "output": {
        "choices": [
            {
                "finish_reason": "stop",
                "message": {
                    "role": "assistant",
                    "content": [
                        {
                            "image": "https://dashscope-result-sz.oss-cn-shenzhen.aliyuncs.com/xxx.png?Expires=xxxx"
                        }
                    ]
                }
            }
        ]
    }
}

计费与限流

北京地域

模型名称

计费单价

限流(主账号与RAM子账号共用)

免费额度(查看)

每秒请求数(RPS)限制

同时处理中任务数量

qwen-image-edit

0.3元/张

2

2

100

新加坡地域

模型名称

计费单价

限流(主账号与RAM子账号共用)

免费额度(查看)

每秒请求数(RPS)限制

同时处理中任务数量

qwen-image-edit

0.330266/张

2

2

无免费额度

计费说明:

  • 按成功生成的 图像张数 计费。仅当查询结果接口返回task_statusSUCCEEDED 并成功生成图像后,才会计费。

  • 模型调用失败或处理错误不产生任何费用,也不消耗免费额度

  • 您可开启“免费额度用完即停”功能,以避免免费额度耗尽后产生额外费用。详情请参见免费额度

图像访问权限配置

模型生成的图像存储于阿里云OSS,每张图像会被分配一个OSS链接,如https://dashscope-result-xx.oss-cn-xxxx.aliyuncs.com/xxx.png。OSS链接允许公开访问,可以使用此链接查看或者下载图片,链接仅在 24 小时内有效。

如果您的业务对安全性要求较高,无法访问阿里云OSS链接,则需要单独配置外网访问白名单。请将以下域名添加到您的白名单中,以便顺利访问图片链接。

dashscope-result-bj.oss-cn-beijing.aliyuncs.com
dashscope-result-hz.oss-cn-hangzhou.aliyuncs.com
dashscope-result-sh.oss-cn-shanghai.aliyuncs.com
dashscope-result-wlcb.oss-cn-wulanchabu.aliyuncs.com
dashscope-result-zjk.oss-cn-zhangjiakou.aliyuncs.com
dashscope-result-sz.oss-cn-shenzhen.aliyuncs.com
dashscope-result-hy.oss-cn-heyuan.aliyuncs.com
dashscope-result-cd.oss-cn-chengdu.aliyuncs.com
dashscope-result-gz.oss-cn-guangzhou.aliyuncs.com
dashscope-result-wlcb-acdr-1.oss-cn-wulanchabu-acdr-1.aliyuncs.com

错误码

如果模型调用失败并返回报错信息,请参见错误信息进行解决。

常见问题

Q: qwen-image-edit 支持多轮对话式编辑吗?

A: 不支持。qwen-image-edit模型本身的设计是单轮执行,即每次调用都是一个独立的、无状态的编辑任务,不会记忆之前的编辑历史。若想实现连续编辑,需将上次编辑生成的图片作为新的输入图片,再次调用服务。

Q: 如何查看模型调用量?

A: 模型的调用信息存在小时级延迟,在模型调用完一小时后,请在模型观测(北京新加坡页面,查看调用量、调用次数、成功率等指标。如何查看模型调用记录