Qwen 画像編集モデルは、複数画像の入出力をサポートしています。画像内のテキストの正確な修正、オブジェクトの追加または削除、被写体のポーズ調整、画像スタイルの転送、画像の詳細の強調が可能です。
モデル概要
入力画像 1 | 入力画像 2 | 入力画像 3 | 出力画像 (複数画像) | |
|
|
|
|
|
入力プロンプト:画像 1 の少女に、画像 2 の黒いドレスを着せ、画像 3 のポーズで座らせます。
モデル | 説明 | 出力画像の仕様 |
qwen-image-edit-max 現在、qwen-image-edit-max-2026-01-16 と同じ機能を持ちます | 単一画像の編集と複数画像の融合をサポートします。
| フォーマット:PNG
|
qwen-image-edit-max-2026-01-16 | ||
qwen-image-edit-plus 現在、qwen-image-edit-plus-2025-10-30 と同じ機能を持ちます | ||
qwen-image-edit-plus-2025-12-15 | ||
qwen-image-edit-plus-2025-10-30 | ||
qwen-image-edit | 単一画像の編集と複数画像の融合をサポートします。
| フォーマット:PNG。 解像度:カスタマイズ不可。出力解像度は、上記のデフォルトの動作に従います。 |
API を呼び出す前に、各リージョンのモデルをご参照ください。
前提条件
呼び出しを行う前に、API キーを取得し、API キーを環境変数として設定してください。
SDK を使用して API を呼び出すには、DashScope SDK をインストールしてください。SDK は Python と Java で利用できます。
北京リージョンとシンガポールリージョンでは、API キーとリクエストエンドポイントが異なります。これらを相互に使用しないでください。リージョンをまたいだ呼び出しは、認証の失敗やサービスエラーにつながります。
HTTP
シンガポール: POST https://dashscope-intl.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation
北京: POST https://dashscope.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation
リクエストパラメーター | 単一画像の編集この例では、 複数画像の融合この例では、 |
ヘッダー | |
Content-Type リクエストのコンテンツタイプ。このパラメーターを | |
Authorization 認証情報。この API は、認証に Model Studio API キーを使用します。例:`Bearer sk-xxxx`。 | |
リクエストボディ | |
model モデル名。値の例: | |
input 入力オブジェクト。次のフィールドが含まれます: | |
parameters 画像生成を制御するための追加パラメーター。 |
レスポンスパラメーター | 成功レスポンスタスクステータスや画像 URL などのタスクデータは 24 時間のみ保持され、その後自動的にパージされます。生成された画像は速やかに保存する必要があります。 エラーレスポンスタスクが失敗した場合、レスポンスは関連情報を返します。code および message フィールドから失敗の原因を特定できます。エラーの解決方法の詳細については、「エラーコード」をご参照ください。 |
output モデルによって生成された結果。 | |
usage このリクエストのリソース使用量。このパラメーターは、リクエストが成功した場合にのみ返されます。 | |
request_id 一意のリクエスト ID。この ID を使用して、問題を追跡およびトラブルシューティングできます。 | |
code エラーコード。このパラメーターは、リクエストが失敗した場合にのみ返されます。詳細については、「エラーメッセージ」をご参照ください。 | |
message 詳細なエラーメッセージ。このパラメーターは、リクエストが失敗した場合にのみ返されます。詳細については、「エラーメッセージ」をご参照ください。 |
DashScope SDK
SDK のパラメーター名は、ほとんどが HTTP API と一致しています。パラメーターの完全なリストについては、「Qwen API リファレンス」をご参照ください。
Python SDK
最新バージョンの DashScope Python SDK をインストールしてください。そうしない場合、実行時エラーが発生する可能性があります:「SDK のインストールまたはアップグレード」。
非同期 API はサポートされていません。
リクエスト例
この例では、qwen-image-edit-max モデルを使用して 2 枚の画像を生成します。
公開 URL を使用して画像を渡す
import json
import os
import dashscope
from dashscope import MultiModalConversation
# 以下はシンガポールリージョンの URL です。北京リージョンのモデルを使用する場合は、URL を https://dashscope.aliyuncs.com/api/v1 に置き換えてください。
dashscope.base_http_api_url = 'https://dashscope-intl.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 キーが異なります。API キーの取得:https://www.alibabacloud.com/help/model-studio/get-api-key
# 環境変数が設定されていない場合は、ご利用の API キーに置き換えてください:api_key="sk-xxx"
api_key = os.getenv("DASHSCOPE_API_KEY")
# qwen-image-edit-max および qwen-image-edit-plus シリーズは、1〜6 枚の画像の出力をサポートします。この例では、2 枚の画像を出力する方法を示します。
response = MultiModalConversation.call(
api_key=api_key,
model="qwen-image-edit-max",
messages=messages,
stream=False,
n=2,
watermark=False,
negative_prompt=" ",
prompt_extend=True,
size="1024*1536",
)
if response.status_code == 200:
# 完全なレスポンスを表示するには、次の行のコメントを解除してください。
# print(json.dumps(response, ensure_ascii=False))
for i, content in enumerate(response.output.choices[0].message.content):
print(f"出力画像 {i+1} の URL:{content['image']}")
else:
print(f"HTTP ステータスコード:{response.status_code}")
print(f"エラーコード:{response.code}")
print(f"エラーメッセージ:{response.message}")
print("詳細については、ドキュメントをご参照ください:https://www.alibabacloud.com/help/model-studio/error-code")
Base64 エンコーディングを使用して画像を渡す
import json
import os
import dashscope
from dashscope import MultiModalConversation
import base64
import mimetypes
# 以下はシンガポールリージョンの URL です。北京リージョンのモデルを使用する場合は、URL を https://dashscope.aliyuncs.com/api/v1 に置き換えてください。
dashscope.base_http_api_url = 'https://dashscope-intl.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 キーが異なります。API キーの取得:https://www.alibabacloud.com/help/model-studio/get-api-key
# 環境変数が設定されていない場合は、ご利用の API キーに置き換えてください:api_key="sk-xxx"
api_key = os.getenv("DASHSCOPE_API_KEY")
# qwen-image-edit-max および qwen-image-edit-plus シリーズは、1〜6 枚の画像の出力をサポートします。この例では、2 枚の画像を出力する方法を示します。
response = MultiModalConversation.call(
api_key=api_key,
model="qwen-image-edit-max",
messages=messages,
stream=False,
n=2,
watermark=False,
negative_prompt=" ",
prompt_extend=True,
size="1920*1080",
)
if response.status_code == 200:
# 完全なレスポンスを表示するには、次の行のコメントを解除してください。
# print(json.dumps(response, ensure_ascii=False))
for i, content in enumerate(response.output.choices[0].message.content):
print(f"出力画像 {i+1} の URL:{content['image']}")
else:
print(f"HTTP ステータスコード:{response.status_code}")
print(f"エラーコード:{response.code}")
print(f"エラーメッセージ:{response.message}")
print("詳細については、ドキュメントをご参照ください:https://www.alibabacloud.com/help/model-studio/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_tokensとoutput_tokensは互換性フィールドであり、現在は 0 に固定されています。
{
"status_code": 200,
"request_id": "fa41f9f9-3cb6-434d-a95d-4ae6b9xxxxxx",
"code": "",
"message": "",
"output": {
"text": null,
"finish_reason": null,
"choices": [
{
"finish_reason": "stop",
"message": {
"role": "assistant",
"content": [
{
"image": "https://dashscope-result-hz.oss-cn-hangzhou.aliyuncs.com/xxx.png?Expires=xxx"
},
{
"image": "https://dashscope-result-hz.oss-cn-hangzhou.aliyuncs.com/xxx.png?Expires=xxx"
}
]
}
}
],
"audio": null
},
"usage": {
"input_tokens": 0,
"output_tokens": 0,
"characters": 0,
"height": 1536,
"image_count": 2,
"width": 1024
}
}Java SDK
DashScope Java SDK の最新バージョンをインストールしてください。そうしない場合、実行時エラーが発生する可能性があります:SDK のインストールまたはアップグレード。
リクエスト例
次の例では、qwen-image-edit-max モデルを使用して 2 枚のイメージを生成する方法を示します。
パブリック 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.JsonUtils;
import com.alibaba.dashscope.utils.Constants;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.List;
public class QwenImageEdit {
static {
// 次の URL はシンガポールリージョン用です。北京リージョンのモデルを使用する場合は、URL を https://dashscope.aliyuncs.com/api/v1 に置き換えてください。
Constants.baseHttpApiUrl = "https://dashscope-intl.aliyuncs.com/api/v1";
}
// シンガポールリージョンと北京リージョンでは、それぞれ別の API キーを使用します。API キーを取得するには、https://www.alibabacloud.com/help/model-studio/get-api-key をご参照ください。
// 環境変数を設定していない場合は、次の行を Model Studio API キーに置き換えてください: 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();
// qwen-image-edit-max と qwen-image-edit-plus は 1~6 枚のイメージの出力をサポートします。この例では、2 枚のイメージを出力する方法を示します。
Map<String, Object> parameters = new HashMap<>();
parameters.put("watermark", false);
parameters.put("negative_prompt", " ");
parameters.put("n", 2);
parameters.put("prompt_extend", true);
parameters.put("size", "1024*1536");
MultiModalConversationParam param = MultiModalConversationParam.builder()
.apiKey(apiKey)
.model("qwen-image-edit-max")
.messages(Collections.singletonList(userMessage))
.parameters(parameters)
.build();
MultiModalConversationResult result = conv.call(param);
// 完全な応答を表示するには、次の行のコメントを解除してください。
// System.out.println(JsonUtils.toJson(result));
List<Map<String, Object>> contentList = result.getOutput().getChoices().get(0).getMessage().getContent();
int imageIndex = 1;
for (Map<String, Object> content : contentList) {
if (content.containsKey("image")) {
System.out.println("URL of output image " + imageIndex + ": " + content.get("image"));
imageIndex++;
}
}
}
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.JsonUtils;
import com.alibaba.dashscope.utils.Constants;
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;
import java.util.List;
public class QwenImageEdit {
static {
// 次の URL はシンガポールリージョン用です。北京リージョンのモデルを使用する場合は、URL を https://dashscope.aliyuncs.com/api/v1 に置き換えてください。
Constants.baseHttpApiUrl = "https://dashscope-intl.aliyuncs.com/api/v1";
}
// シンガポールリージョンと北京リージョンでは、それぞれ別の API キーを使用します。API キーを取得するには、https://www.alibabacloud.com/help/model-studio/get-api-key をご参照ください。
// 環境変数を設定していない場合は、次の行を Model Studio API キーに置き換えてください: 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();
// qwen-image-edit-max と qwen-image-edit-plus は 1~6 枚のイメージの出力をサポートします。この例では、2 枚のイメージを出力する方法を示します。
Map<String, Object> parameters = new HashMap<>();
parameters.put("watermark", false);
parameters.put("negative_prompt", " ");
parameters.put("n", 2);
parameters.put("prompt_extend", true);
parameters.put("size", "1536*1024");
MultiModalConversationParam param = MultiModalConversationParam.builder()
.apiKey(apiKey)
.model("qwen-image-edit-max")
.messages(Collections.singletonList(userMessage))
.parameters(parameters)
.build();
MultiModalConversationResult result = conv.call(param);
// 完全な応答を表示するには、次の行のコメントを解除してください。
// System.out.println(JsonUtils.toJson(result));
List<Map<String, Object>> contentList = result.getOutput().getChoices().get(0).getMessage().getContent();
int imageIndex = 1;
for (Map<String, Object> content : contentList) {
if (content.containsKey("image")) {
System.out.println("URL of output image " + imageIndex + ": " + content.get("image"));
imageIndex++;
}
}
}
/**
* ファイルを Base64 文字列にエンコードします。
* @param filePath ファイルパス。
* @return data:{mime_type};base64,{base64_data} フォーマットの Base64 文字列。
*/
public static String encodeFile(String filePath) {
Path path = Paths.get(filePath);
if (!Files.exists(path)) {
throw new IllegalArgumentException("File does not exist: " + filePath);
}
// MIME タイプを検出します。
String mimeType = null;
try {
mimeType = Files.probeContentType(path);
} catch (IOException e) {
throw new IllegalArgumentException("Unable to detect the file type: " + filePath);
}
if (mimeType == null || !mimeType.startsWith("image/")) {
throw new IllegalArgumentException("Unsupported or unrecognized image format.");
}
// ファイルコンテンツを読み取り、エンコードします。
byte[] fileBytes = null;
try{
fileBytes = Files.readAllBytes(path);
} catch (IOException e) {
throw new IllegalArgumentException("Unable to read the file content: " + 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("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);
}
}応答例
イメージリンクの有効期間は 24 時間です。速やかにイメージをダウンロードしてください。
{
"requestId": "46281da9-9e02-941c-ac78-be88b8xxxxxx",
"usage": {
"image_count": 2,
"width": 1024,
"height": 1536
},
"output": {
"choices": [
{
"finish_reason": "stop",
"message": {
"role": "assistant",
"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"
}
]
}
}
]
}
}イメージのアクセス権限の設定
モデルによって生成されたイメージは Object Storage Service (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 画像編集モデルがサポートしている言語は何ですか?
A:公式にサポートしているのは簡体字中国語と英語です。その他の言語でも動作する可能性はありますが、結果は保証されません。
Q:縦横比の異なる複数のリファレンスイメージをアップロードした場合、出力イメージの縦横比はどのように決定されますか?
A:デフォルトでは、出力イメージの縦横比は、入力配列の最後のイメージの縦横比と一致します。この動作は、parameters.size パラメーターを指定することで上書きできます。
Q:モデルの使用状況を確認するにはどうすればよいですか?
A:詳細については、「請求クエリとコスト管理」をご参照ください。




