Qwen-Image は汎用的な画像生成モデルで、複数のアートスタイルをサポートし、複雑なテキストレンダリングに優れています。複数行のレイアウト、段落レベルのテキスト生成、詳細な描写が可能です。
クイックアクセス: ユーザーガイド | オンラインで試す (シンガポール | 中国 (北京)) | 技術ブログ (その他の例) |
例
プロンプト | 生成された画像 |
癒し系の手描き風ポスターで、鮮やかな緑の芝生の上でボール遊びをする子犬3匹を描き、鳥や星などの装飾要素を加えています。メインタイトル「Come Play Ball!」は太くて青い漫画フォントで上部に大きく表示されています。その下にはサブタイトル「Come [Show Off Your Skills]!」が緑色のフォントで表示されています。吹き出しには「Hehe, watch me amaze my little friends next!」という遊び心あふれるテキストが入り、底部には補足テキストとして「We get to play ball with our friends again!」と書かれています。カラーパレットはフレッシュなグリーンとブルーを中心に、明るいピンクとイエローで強調し、陽気で子供らしい雰囲気を演出しています。 |
|
モデル概要
モデル | 説明 | 出力画像仕様 |
qwen-image-2.0-pro qwen-image-2.0-pro-2026-04-22 と同じ機能 | 画像生成および編集用の Qwen Pro シリーズ。テキストレンダリング、リアルな質感、セマンティクスへの忠実度が強化されています。 画像編集については、「Qwen-Image 編集」をご参照ください。 | 解像度:幅と高さを自由に設定可能。総ピクセル数は 512×512 ~ 2048×2048 の範囲内である必要があります。デフォルト解像度は 2048*2048 です。 フォーマット:PNG 画像枚数:1~6 枚 |
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 高速化シリーズ。品質と応答速度のバランスを取っています。 画像編集については、「Qwen-Image 編集」をご参照ください。 | |
qwen-image-2.0-2026-03-03 | ||
qwen-image-max qwen-image-max-2025-12-30 と同じ機能 | 画像生成用の Qwen Max シリーズ。より高いリアリズムと自然さを実現し、AI 生成特有のアーティファクトが少ないです。 | 解像度:サイズパラメータ設定でサポートされる解像度と縦横比をご確認ください。 フォーマット:PNG 画像枚数:1 枚固定 |
qwen-image-max-2025-12-30 | ||
qwen-image-plus qwen-image と同じ機能 | 画像生成用の Qwen Plus シリーズ。多様なアートスタイルとテキストレンダリングに優れています。 | |
qwen-image-plus-2026-01-09 | ||
qwen-image |
qwen-image-plus および qwen-image のみが非同期呼び出しをサポートしています。
API を呼び出す前に、ご利用のリージョンでサポートされているモデル一覧をご確認ください。
前提条件
呼び出しを行う前に、API キーを取得し、API キーを環境変数としてエクスポートしてください。SDK を使用して呼び出す場合は、DashScope SDK をインストールしてください。
中国 (北京) リージョンとシンガポールリージョンでは、それぞれ別々の API キー および リクエストエンドポイント を使用します。これらは相互に使用できません。リージョンをまたいだ呼び出しは認証エラーまたはサービスエラーを引き起こします。
同期 API(推奨)
HTTP
同期呼び出しは、1 回のリクエストで結果を返します。
シンガポール: POST https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation
呼び出し時に、WorkspaceId を実際のワークスペース IDに置き換えてください。
中国 (北京): POST https://dashscope.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation
リクエストパラメーター | Text-to-Image |
リクエストヘッダー | |
Content-Type リクエストのコンテンツタイプ。必ず | |
Authorization Model Studio API キーを使用してリクエストを認証します。例:Bearer sk-xxxx。 | |
リクエスト本文 | |
model モデル名。例: | |
input 入力情報。 | |
parameters 画像処理パラメーター。 |
レスポンスパラメーター | タスク成功画像 URL の有効期限は 24 時間のみで、その後自動的に消去されます。生成された画像は速やかに保存してください。 タスク失敗タスクが失敗した場合、レスポンスにコードおよびメッセージフィールドでエラーの詳細が含まれます。「エラーコード」をご参照ください。 |
output タスク出力情報。 | |
usage 出力統計情報。成功した結果のみをカウントします。 | |
request_id トレースおよびトラブルシューティング用の一意のリクエスト識別子。 | |
code エラーコード。失敗したリクエストの場合のみ返されます。「エラーコード」をご参照ください。 | |
message 詳細なエラーメッセージ。失敗したリクエストの場合のみ返されます。「エラーコード」をご参照ください。 |
DashScope SDK 呼び出し
DashScope SDK は Python および Java をサポートしています。
SDK のパラメーター名は HTTP パラメーターとほぼ一致し、パラメーター構造は言語固有の規則に従います。同期呼び出しのパラメーターについては、「HTTP」をご参照ください。
Python
実行時エラーを回避するため、最新の DashScope Python SDK をインストールしてください:SDK のインストール。
リクエスト例
import json
import os
import dashscope
from dashscope import MultiModalConversation
# シンガポールリージョン用の URL を使用します。中国 (北京) リージョンの場合は、https://dashscope.aliyuncs.com/api/v1 に置き換えてください。
dashscope.base_http_api_url = 'https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1'
messages = [
{
"role": "user",
"content": [
{"text": "Healing-style hand-drawn poster featuring three puppies playing with a ball on lush green grass, adorned with decorative elements such as birds and stars. The main title “Come Play Ball!” is prominently displayed at the top in bold, blue cartoon font. Below it, the subtitle “Come [Show Off Your Skills]!” appears in green font. A speech bubble adds playful charm with the text: “Hehe, watch me amaze my little friends next!” At the bottom, supplementary text reads: “We get to play ball with our friends again!” The color palette centers on fresh greens and blues, accented with bright pink and yellow tones to highlight a cheerful, childlike atmosphere."}
]
}
]
# 中国 (北京) リージョンとシンガポールリージョンでは API キーが異なります。API キーの取得: https://www.alibabacloud.com/help/en/model-studio/get-api-key
# 環境変数を設定していない場合は、以下の行を api_key="sk-xxx" に置き換えてください。
api_key = os.getenv("DASHSCOPE_API_KEY")
response = MultiModalConversation.call(
api_key=api_key,
model="qwen-image-2.0-pro",
messages=messages,
result_format='message',
stream=False,
watermark=False,
prompt_extend=True,
negative_prompt="Low resolution, low quality, distorted limbs, malformed fingers, oversaturated colors, wax-figure appearance, lack of facial detail, excessive smoothness, AI-looking artifacts, chaotic composition, blurry or warped text.",
size='2048*2048'
)
if response.status_code == 200:
print(json.dumps(response, ensure_ascii=False))
else:
print(f"HTTP ステータスコード: {response.status_code}")
print(f"エラーコード: {response.code}")
print(f"エラーメッセージ: {response.message}")
print("ドキュメントを参照: https://www.alibabacloud.com/help/en/model-studio/error-code")
レスポンス例
画像 URL の有効期限は 24 時間です。画像は速やかにダウンロードしてください。
{
"status_code": 200,
"request_id": "d2d1a8c0-325f-9b9d-8b90-xxxxxx",
"code": "",
"message": "",
"output": {
"text": null,
"finish_reason": null,
"choices": [
{
"finish_reason": "stop",
"message": {
"role": "assistant",
"content": [
{
"image": "https://dashscope-result-wlcb.oss-cn-wulanchabu.aliyuncs.com/xxx.png?Expires=xxx"
}
]
}
}
]
},
"usage": {
"input_tokens": 0,
"output_tokens": 0,
"width": 2048,
"image_count": 1,
"height": 2048
}
}Java
最新の DashScope Java SDK をインストールする必要があります。インストールしないと実行時エラーが発生する可能性があります:SDK のインストール。
リクエスト例
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;
public class QwenImage {
static {
// シンガポールリージョン用の URL を使用します。中国 (北京) リージョンの場合は、https://dashscope.aliyuncs.com/api/v1 に置き換えてください。
Constants.baseHttpApiUrl = "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1";
}
// 中国 (北京) リージョンとシンガポールリージョンでは API キーが異なります。API キーの取得: https://www.alibabacloud.com/help/en/model-studio/get-api-key
// 環境変数を設定していない場合は、以下の行を static String apiKey="sk-xxx" に置き換えてください。
static String apiKey = System.getenv("DASHSCOPE_API_KEY");
public static void call() throws ApiException, NoApiKeyException, UploadFileException, IOException {
MultiModalConversation conv = new MultiModalConversation();
MultiModalMessage userMessage = MultiModalMessage.builder().role(Role.USER.getValue())
.content(Arrays.asList(
Collections.singletonMap("text", "Healing-style hand-drawn poster featuring three puppies playing with a ball on lush green grass, adorned with decorative elements such as birds and stars. The main title “Come Play Ball!” is prominently displayed at the top in bold, blue cartoon font. Below it, the subtitle “Come [Show Off Your Skills]!” appears in green font. A speech bubble adds playful charm with the text: “Hehe, watch me amaze my little friends next!” At the bottom, supplementary text reads: “We get to play ball with our friends again!” The color palette centers on fresh greens and blues, accented with bright pink and yellow tones to highlight a cheerful, childlike atmosphere.")
)).build();
Map<String, Object> parameters = new HashMap<>();
parameters.put("watermark", false);
parameters.put("prompt_extend", true);
parameters.put("negative_prompt", "Low resolution, low quality, distorted limbs, malformed fingers, oversaturated colors, wax-figure appearance, lack of facial detail, excessive smoothness, AI-looking artifacts, chaotic composition, blurry or warped text.");
parameters.put("size", "2048*2048");
MultiModalConversationParam param = MultiModalConversationParam.builder()
.apiKey(apiKey)
.model("qwen-image-2.0-pro")
.messages(Collections.singletonList(userMessage))
.parameters(parameters)
.build();
MultiModalConversationResult result = conv.call(param);
System.out.println(JsonUtils.toJson(result));
}
public static void main(String[] args) {
try {
call();
} catch (ApiException | NoApiKeyException | UploadFileException | IOException e) {
System.out.println(e.getMessage());
}
System.exit(0);
}
}レスポンス例
画像 URL の有効期限は 24 時間です。画像は速やかにダウンロードしてください。
{
"requestId": "5b6f2d04-b019-40db-a5cc-xxxxxx",
"usage": {
"image_count": 1,
"width": 2048,
"height": 2048
},
"output": {
"choices": [
{
"finish_reason": "stop",
"message": {
"role": "assistant",
"content": [
{
"image": "https://dashscope-result-wlcb.oss-cn-wulanchabu.aliyuncs.com/xxx.png?Expires=xxx"
}
]
}
}
]
}
}非同期 API
非同期呼び出しをサポートするのは、qwen-image-plus および qwen-image のみです。
HTTP
非同期呼び出しは、2 ステップの HTTP ワークフローを使用します。
タスクを作成してタスク ID を取得: タスクを作成するリクエストを送信します。レスポンスで タスク ID(task_id)が返されます。
タスク ID を使用して結果をポーリング: task_id を使用してタスクのステータスを完了するまでポーリングし、画像 URL を取得します。
ステップ 1: タスクを作成してタスク ID を取得
シンガポール: POST https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/services/aigc/text2image/image-synthesis
中国 (北京): POST https://dashscope.aliyuncs.com/api/v1/services/aigc/text2image/image-synthesis
-
タスク作成後、返された
task_idを使用して結果をクエリします。task_idの有効期限は 24 時間です。重複タスクを作成しないでください。代わりにポーリングを使用して結果を取得してください。 -
初心者向けのガイドについては、「Postman」をご参照ください。
リクエストパラメーター | Text-to-Image
|
リクエストヘッダー | |
Content-Type リクエストのコンテンツタイプ。必ず | |
Authorization Model Studio API キーを使用してリクエストを認証します。例:Bearer sk-xxxx。 | |
X-DashScope-Async 非同期処理を有効にします。HTTP リクエストでは非同期呼び出しのみサポートされます。必ず 重要
このリクエストヘッダーが欠落している場合、「current user api does not support synchronous calls」というエラーが返されます。 | |
リクエスト本文 | |
model モデル名。 例: | |
input 入力情報。 | |
parameters 画像処理パラメーター。 |
レスポンスパラメーター | 成功レスポンス
エラーレスポンスタスクの作成に失敗しました。「エラーコード」をご参照ください。
|
output タスク出力情報。 | |
request_id トレースおよびトラブルシューティング用の一意のリクエスト識別子。 | |
code エラーコード。失敗したリクエストの場合のみ返されます。「エラーコード」をご参照ください。 | |
message 詳細なエラーメッセージ。失敗したリクエストの場合のみ返されます。「エラーコード」をご参照ください。 |
ステップ 2: タスク ID を使用して結果をポーリング
シンガポール
GET https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/tasks/{task_id}
呼び出し時に、WorkspaceId を実際のワークスペース IDに置き換えてください。
中国 (北京)
GET https://dashscope.aliyuncs.com/api/v1/tasks/{task_id}
-
ポーリングの推奨事項: 画像生成は時間がかかります。10 秒間隔など、適切な間隔でポーリングメカニズムを使用してください。
-
タスクの状態遷移: PENDING → RUNNING → SUCCEEDED または FAILED。
-
結果リンク: タスクが成功すると、24 時間有効の画像 URL が返されます。画像を OSS などの永続ストレージにダウンロードして保存してください。
リクエストパラメーター | タスク結果のポーリング
|
リクエストヘッダー | |
Authorization Model Studio API キーを使用してリクエストを認証します。例:Bearer sk-xxxx。 | |
URL パスパラメーター | |
task_id タスクの ID。 |
レスポンスパラメーター | タスク成功タスクデータ(タスクステータスおよび画像 URL)は 24 時間のみ保持され、その後自動的に消去されます。生成された画像は速やかに保存してください。 タスク失敗タスクが失敗した場合、 |
output タスク出力情報。 | |
usage 出力統計情報。成功した結果のみをカウントします。 | |
request_id トレースおよびトラブルシューティング用の一意のリクエスト識別子。 |
DashScope SDK
DashScope SDK は Python および Java をサポートしています。
SDK のパラメーター名は HTTP のものとほぼ一致します。パラメーター構造は言語固有の規則に従います。非同期呼び出しのパラメーターについては、「HTTP」をご参照ください。
画像モデルは処理時間が長いため、基盤サービスは非同期実行を使用します。SDK は次の 2 つのモードを提供します。
同期呼び出し(ブロッキングモード): SDK はタスクが完了するまで待機し、最終結果を返します。これは標準的な同期呼び出しの動作に一致します。
非同期呼び出し(ノンブロッキングモード): 呼び出しはすぐにタスク ID で戻ります。その ID を使用してタスクのステータスと最終結果をポーリングします。
Python SDK
実行時エラーを回避するため、最新の DashScope Python SDK をインストールしてください:SDK のインストール。
同期
リクエスト例
from http import HTTPStatus
from urllib.parse import urlparse, unquote
from pathlib import PurePosixPath
import requests
from dashscope import ImageSynthesis
import os
import dashscope
# シンガポールリージョン用の URL を使用します。中国 (北京) リージョンの場合は、https://dashscope.aliyuncs.com/api/v1 に置き換えてください。
dashscope.base_http_api_url = 'https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1'
prompt = "Healing-style hand-drawn poster featuring three puppies playing with a ball on lush green grass, adorned with decorative elements such as birds and stars. The main title “Come Play Ball!” is prominently displayed at the top in bold, blue cartoon font. Below it, the subtitle “Come [Show Off Your Skills]!” appears in green font. A speech bubble adds playful charm with the text: “Hehe, watch me amaze my little friends next!” At the bottom, supplementary text reads: “We get to play ball with our friends again!” The color palette centers on fresh greens and blues, accented with bright pink and yellow tones to highlight a cheerful, childlike atmosphere."
# 中国 (北京) リージョンとシンガポールリージョンでは API キーが異なります。API キーの取得: https://www.alibabacloud.com/help/en/model-studio/get-api-key
# 環境変数を設定していない場合は、以下の行を api_key="sk-xxx" に置き換えてください。
api_key = os.getenv("DASHSCOPE_API_KEY")
print('----同期呼び出し、少々お待ちください----')
rsp = ImageSynthesis.call(api_key=api_key,
model="qwen-image-plus", # 非同期呼び出しをサポートするのは qwen-image-plus および qwen-image のみ
prompt=prompt,
negative_prompt=" ",
n=1,
size='1664*928',
prompt_extend=True,
watermark=False)
print(f'response: {rsp}')
if rsp.status_code == HTTPStatus.OK:
# 現在のディレクトリに画像を保存
for result in rsp.output.results:
file_name = PurePosixPath(unquote(urlparse(result.url).path)).parts[-1]
with open('./%s' % file_name, 'wb+') as f:
f.write(requests.get(result.url).content)
else:
print(f'同期呼び出しに失敗しました。status_code: {rsp.status_code}, code: {rsp.code}, message: {rsp.message}')
レスポンス例
URL の有効期限は 24 時間です。画像は速やかにダウンロードしてください。
{
"status_code": 200,
"request_id": "a47b1a65-7041-4565-9068-xxxxxx",
"code": null,
"message": "",
"output": {
"task_id": "91093132-475e-43cf-b94e-xxxxxx",
"task_status": "SUCCEEDED",
"results": [
{
"url": "https://dashscope-result-sz.oss-cn-shenzhen.aliyuncs.com/xxx.png?Expires=xxxxxx",
"orig_prompt": "Healing-style hand-drawn poster featuring three puppies playing with a ball on lush green grass, adorned with decorative elements such as birds and stars. The main title “Come Play Ball!” is prominently displayed at the top in bold, blue cartoon font. Below it, the subtitle “Come [Show Off Your Skills]!” appears in green font. A speech bubble adds playful charm with the text: “Hehe, watch me amaze my little friends next!” At the bottom, supplementary text reads: “We get to play ball with our friends again!” The color palette centers on fresh greens and blues, accented with bright pink and yellow tones to highlight a cheerful, childlike atmosphere.",
"actual_prompt": "Childhood-inspired hand-drawn poster design: Three playful puppies joyfully interact with a colorful ball on a vibrant patch of lush green grass. Delicate decorative elements including fluttering birds and twinkling stars are scattered throughout. At the top center, the bold, blue cartoon-style title “Come Play Ball!” stands out prominently. Directly beneath, the subtitle “Come [Show Off Your Skills]!” is rendered in cheerful green lettering. A whimsical speech bubble near one of the puppies contains the playful text: “Hehe, watch me amaze my little friends next!” At the bottom edge, smaller supplementary text reads: “We get to play ball with our friends again!” The color palette is centered on fresh greens and sky blues, accented with pops of bright pink and sunny yellow, enhancing the cheerful, childlike atmosphere. Style evokes nostalgic, hand-inked illustrations with soft textures, gentle linework, and a whimsical, storybook-like composition."
}
],
"submit_time": "2025-09-09 13:39:20.659",
"scheduled_time": "2025-09-09 13:39:20.717",
"end_time": "2025-09-09 13:39:45.233"
},
"usage": {
"image_count": 1
}
}非同期
リクエスト例
from http import HTTPStatus
from urllib.parse import urlparse, unquote
from pathlib import PurePosixPath
import requests
from dashscope import ImageSynthesis
import os
import dashscope
import time
# シンガポールリージョン用の URL を使用します。中国 (北京) リージョンの場合は、https://dashscope.aliyuncs.com/api/v1 に置き換えてください。
dashscope.base_http_api_url = 'https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1'
prompt = "Healing-style hand-drawn poster featuring three puppies playing with a ball on lush green grass, adorned with decorative elements such as birds and stars. The main title “Come Play Ball!” is prominently displayed at the top in bold, blue cartoon font. Below it, the subtitle “Come [Show Off Your Skills]!” appears in green font. A speech bubble adds playful charm with the text: “Hehe, watch me amaze my little friends next!” At the bottom, supplementary text reads: “We get to play ball with our friends again!” The color palette centers on fresh greens and blues, accented with bright pink and yellow tones to highlight a cheerful, childlike atmosphere."
# 中国 (北京) リージョンとシンガポールリージョンでは API キーが異なります。API キーの取得: https://www.alibabacloud.com/help/en/model-studio/get-api-key
# 環境変数を設定していない場合は、以下の行を api_key="sk-xxx" に置き換えてください。
api_key = os.getenv("DASHSCOPE_API_KEY")
def async_call():
print('----タスクを作成中----')
task_info = create_async_task()
print('----タスクステータスをポーリング中----')
poll_task_status(task_info)
# 非同期タスクを作成
def create_async_task():
rsp = ImageSynthesis.async_call(api_key=api_key,
model="qwen-image-plus", # 非同期呼び出しをサポートするのは qwen-image-plus および qwen-image のみ
prompt=prompt,
negative_prompt=" ",
n=1,
size='1664*928',
prompt_extend=True,
watermark=False)
print(rsp)
if rsp.status_code == HTTPStatus.OK:
print(rsp.output)
else:
print(f'タスクの作成に失敗しました。status_code: {rsp.status_code}, code: {rsp.code}, message: {rsp.message}')
return rsp
# 非同期タスクのステータスをポーリング(5 秒間隔でクエリ、最大 1 分間)
def poll_task_status(task):
start_time = time.time()
timeout = 60 # 1 分のタイムアウト
while True:
# タイムアウトをチェック
if time.time() - start_time > timeout:
print('ポーリングがタイムアウトしました(1 分)。タスクは完了していません。')
return
# タスクステータスを取得
status_rsp = ImageSynthesis.fetch(task)
print(f'タスクステータスクエリ結果: {status_rsp}')
if status_rsp.status_code != HTTPStatus.OK:
print(f'タスクステータスの取得に失敗しました。status_code: {status_rsp.status_code}, code: {status_rsp.code}, message: {status_rsp.message}')
return
task_status = status_rsp.output.task_status
print(f'現在のタスクステータス: {task_status}')
if task_status == 'SUCCEEDED':
print('タスクが完了しました。画像をダウンロード中...')
for result in status_rsp.output.results:
file_name = PurePosixPath(unquote(urlparse(result.url).path)).parts[-1]
with open(f'./{file_name}', 'wb+') as f:
f.write(requests.get(result.url).content)
print(f'画像を {file_name} として保存しました。')
break
elif task_status == 'FAILED':
print(f'タスクの実行に失敗しました。ステータス: {task_status}, code: {status_rsp.code}, message: {status_rsp.message}')
break
elif task_status == 'PENDING' or task_status == 'RUNNING':
print('タスクは進行中です。5 秒後に再クエリします...')
time.sleep(5)
else:
print(f'不明なタスクステータス: {task_status}。5 秒後に再クエリします...')
time.sleep(5)
# 非同期タスクをキャンセル(PENDING ステータスのタスクのみキャンセル可能)
def cancel_task(task):
rsp = ImageSynthesis.cancel(task)
print(rsp)
if rsp.status_code == HTTPStatus.OK:
print(rsp.output.task_status)
else:
print(f'タスクのキャンセルに失敗しました。status_code: {rsp.status_code}, code: {rsp.code}, message: {rsp.message}')
if __name__ == '__main__':
async_call()
レスポンス例
タスク作成時のレスポンス
{ "status_code": 200, "request_id": "31b04171-011c-96bd-ac00-xxxxxx", "code": "", "message": "", "output": { "task_id": "4f90cf14-a34e-4eae-xxxxxxxx", "task_status": "PENDING", "results": [] }, "usage": null }タスク結果のポーリング時のレスポンス
URL の有効期限は 24 時間です。画像は速やかにダウンロードしてください。
{ "status_code": 200, "request_id": "a47b1a65-7041-4565-9068-xxxxxx", "code": null, "message": "", "output": { "task_id": "91093132-475e-43cf-b94e-xxxxxx", "task_status": "SUCCEEDED", "results": [ { "url": "https://dashscope-result-sz.oss-cn-shenzhen.aliyuncs.com/xxx.png?Expires=xxxxxx", "orig_prompt": "Healing-style hand-drawn poster featuring three puppies playing with a ball on lush green grass, adorned with decorative elements such as birds and stars. The main title “Come Play Ball!” is prominently displayed at the top in bold, blue cartoon font. Below it, the subtitle “Come [Show Off Your Skills]!” appears in green font. A speech bubble adds playful charm with the text: “Hehe, watch me amaze my little friends next!” At the bottom, supplementary text reads: “We get to play ball with our friends again!” The color palette centers on fresh greens and blues, accented with bright pink and yellow tones to highlight a cheerful, childlike atmosphere.", "actual_prompt": "Childhood-inspired hand-drawn poster design: Three playful puppies joyfully interact with a colorful ball on a vibrant patch of lush green grass. Delicate decorative elements including fluttering birds and twinkling stars are scattered throughout. At the top center, the bold, blue cartoon-style title “Come Play Ball!” stands out prominently. Directly beneath, the subtitle “Come [Show Off Your Skills]!” is rendered in cheerful green lettering. A whimsical speech bubble near one of the puppies contains the playful text: “Hehe, watch me amaze my little friends next!” At the bottom edge, smaller supplementary text reads: “We get to play ball with our friends again!” The color palette is centered on fresh greens and sky blues, accented with pops of bright pink and sunny yellow, enhancing the cheerful, childlike atmosphere. Style evokes nostalgic, hand-inked illustrations with soft textures, gentle linework, and a whimsical, storybook-like composition." } ], "submit_time": "2025-09-09 13:39:20.659", "scheduled_time": "2025-09-09 13:39:20.717", "end_time": "2025-09-09 13:39:45.233" }, "usage": { "image_count": 1 } }
Java SDK
最新の DashScope Java SDK をインストールする必要があります。インストールしないと実行時エラーが発生する可能性があります:SDK のインストール。
同期
リクエスト例
// Copyright (c) Alibaba, Inc. and its affiliates.
import com.alibaba.dashscope.aigc.imagesynthesis.ImageSynthesis;
import com.alibaba.dashscope.aigc.imagesynthesis.ImageSynthesisListResult;
import com.alibaba.dashscope.aigc.imagesynthesis.ImageSynthesisParam;
import com.alibaba.dashscope.aigc.imagesynthesis.ImageSynthesisResult;
import com.alibaba.dashscope.exception.ApiException;
import com.alibaba.dashscope.exception.NoApiKeyException;
import com.alibaba.dashscope.task.AsyncTaskListParam;
import com.alibaba.dashscope.utils.Constants;
import com.alibaba.dashscope.utils.JsonUtils;
import java.util.HashMap;
import java.util.Map;
public class Text2Image {
static {
// シンガポールリージョン用の URL を使用します。中国 (北京) リージョンの場合は、https://dashscope.aliyuncs.com/api/v1 に置き換えてください。
Constants.baseHttpApiUrl = "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1";
}
// 中国 (北京) リージョンとシンガポールリージョンでは API キーが異なります。API キーの取得: https://www.alibabacloud.com/help/en/model-studio/get-api-key
// 環境変数を設定していない場合は、以下の行を static String apiKey = "sk-xxx" に置き換えてください。
static String apiKey = System.getenv("DASHSCOPE_API_KEY");
public static void basicCall() throws ApiException, NoApiKeyException {
String prompt = "Healing-style hand-drawn poster featuring three puppies playing with a ball on lush green grass, adorned with decorative elements such as birds and stars. The main title “Come Play Ball!” is prominently displayed at the top in bold, blue cartoon font. Below it, the subtitle “Come [Show Off Your Skills]!” appears in green font. A speech bubble adds playful charm with the text: “Hehe, watch me amaze my little friends next!” At the bottom, supplementary text reads: “We get to play ball with our friends again!” The color palette centers on fresh greens and blues, accented with bright pink and yellow tones to highlight a cheerful, childlike atmosphere.";
Map<String, Object> parameters = new HashMap<>();
parameters.put("prompt_extend", true);
parameters.put("watermark", false);
parameters.put("negative_prompt", " ");
ImageSynthesisParam param =
ImageSynthesisParam.builder()
.apiKey(apiKey)
// 非同期呼び出しをサポートするのは qwen-image-plus および qwen-image のみ
.model("qwen-image-plus")
.prompt(prompt)
.n(1)
.size("1664*928")
.parameters(parameters)
.build();
ImageSynthesis imageSynthesis = new ImageSynthesis();
ImageSynthesisResult result = null;
try {
System.out.println("---同期呼び出し、少々お待ちください----");
result = imageSynthesis.call(param);
} catch (ApiException | NoApiKeyException e){
throw new RuntimeException(e.getMessage());
}
System.out.println(JsonUtils.toJson(result));
}
public static void main(String[] args){
try{
basicCall();
}catch(ApiException|NoApiKeyException e){
System.out.println(e.getMessage());
}
}
}
レスポンス例
URL の有効期限は 24 時間です。画像は速やかにダウンロードしてください。
{
"request_id": "9f3044ba-528f-4606-8830-xxxxxx",
"output": {
"task_id": "fecf4c7f-3508-45f4-8454-xxxxxx",
"task_status": "SUCCEEDED",
"results": [
{
"orig_prompt": "Healing-style hand-drawn poster featuring three puppies playing with a ball on lush green grass, adorned with decorative elements such as birds and stars. The main title “Come Play Ball!” is prominently displayed at the top in bold, blue cartoon font. Below it, the subtitle “Come [Show Off Your Skills]!” appears in green font. A speech bubble adds playful charm with the text: “Hehe, watch me amaze my little friends next!” At the bottom, supplementary text reads: “We get to play ball with our friends again!” The color palette centers on fresh greens and blues, accented with bright pink and yellow tones to highlight a cheerful, childlike atmosphere.",
"actual_prompt": "Childhood-inspired hand-drawn poster design: Three playful puppies joyfully interact with a colorful ball on a vibrant patch of lush green grass. Delicate decorative elements including fluttering birds and twinkling stars are scattered throughout. At the top center, the bold, blue cartoon-style title “Come Play Ball!” stands out prominently. Directly beneath, the subtitle “Come [Show Off Your Skills]!” is rendered in cheerful green lettering. A whimsical speech bubble near one of the puppies contains the playful text: “Hehe, watch me amaze my little friends next!” At the bottom edge, smaller supplementary text reads: “We get to play ball with our friends again!” The color palette is centered on fresh greens and sky blues, accented with pops of bright pink and sunny yellow, enhancing the cheerful, childlike atmosphere. Style evokes nostalgic, hand-inked illustrations with soft textures, gentle linework, and a whimsical, storybook-like composition.",
"url": "https://dashscope-result-sz.oss-cn-shenzhen.aliyuncs.com/xxx.png?Expires=xxxx"
}
]
},
"usage": {
"image_count": 1
}
}非同期
リクエスト例
// Copyright (c) Alibaba, Inc. and its affiliates.
import com.alibaba.dashscope.aigc.imagesynthesis.ImageSynthesis;
import com.alibaba.dashscope.aigc.imagesynthesis.ImageSynthesisParam;
import com.alibaba.dashscope.aigc.imagesynthesis.ImageSynthesisResult;
import com.alibaba.dashscope.exception.ApiException;
import com.alibaba.dashscope.exception.NoApiKeyException;
import com.alibaba.dashscope.utils.Constants;
import com.alibaba.dashscope.utils.JsonUtils;
import java.util.HashMap;
import java.util.Map;
public class Text2Image {
static {
// シンガポールリージョン用の URL を使用します。中国 (北京) リージョンの場合は、https://dashscope.aliyuncs.com/api/v1 に置き換えてください。
Constants.baseHttpApiUrl = "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1";
}
// 中国 (北京) リージョンとシンガポールリージョンでは API キーが異なります。API キーの取得: https://www.alibabacloud.com/help/en/model-studio/get-api-key
// 環境変数を設定していない場合は、以下の行を static String apiKey = "sk-xxx" に置き換えてください。
static String apiKey = System.getenv("DASHSCOPE_API_KEY");
public void asyncCall() {
System.out.println("---タスクを作成中----");
String taskId = this.createAsyncTask();
System.out.println("--タスクが完了して画像 URL が返されるまで待ちます----");
this.waitAsyncTask(taskId);
}
public String createAsyncTask() {
String prompt = "Healing-style hand-drawn poster featuring three puppies playing with a ball on lush green grass, adorned with decorative elements such as birds and stars. The main title “Come Play Ball!” is prominently displayed at the top in bold, blue cartoon font. Below it, the subtitle “Come [Show Off Your Skills]!” appears in green font. A speech bubble adds playful charm with the text: “Hehe, watch me amaze my little friends next!” At the bottom, supplementary text reads: “We get to play ball with our friends again!” The color palette centers on fresh greens and blues, accented with bright pink and yellow tones to highlight a cheerful, childlike atmosphere.";
Map<String, Object> parameters = new HashMap<>();
parameters.put("prompt_extend", true);
parameters.put("watermark", false);
parameters.put("negative_prompt", " ");
ImageSynthesisParam param =
ImageSynthesisParam.builder()
.apiKey(apiKey)
// 非同期呼び出しをサポートするのは qwen-image-plus および qwen-image のみ
.model("qwen-image-plus")
.prompt(prompt)
.n(1)
.size("1664*928")
.parameters(parameters)
.build();
try {
ImageSynthesisResult result = new ImageSynthesis().asyncCall(param);
System.out.println(JsonUtils.toJson(result));
String taskId = result.getOutput().getTaskId();
System.out.println("task_id=" + taskId);
return taskId;
} catch (Exception e) {
throw new RuntimeException(e.getMessage());
}
}
public void waitAsyncTask(String taskId) {
ImageSynthesis imageSynthesis = new ImageSynthesis();
long startTime = System.currentTimeMillis();
int timeout = 60 * 1000; // 1 分のタイムアウト
int interval = 5 * 1000; // 5 秒のポーリング間隔
while (true) {
if (System.currentTimeMillis() - startTime > timeout) {
System.out.println("ポーリングがタイムアウトしました(1 分)。タスクは完了していません。");
return;
}
try {
ImageSynthesisResult result = imageSynthesis.fetch(taskId, apiKey);
System.out.println("タスクステータスクエリ結果: " + JsonUtils.toJson(result));
if (result.getOutput() == null) {
System.out.println("タスクステータスの取得に失敗しました。出力が空です。");
return;
}
String taskStatus = result.getOutput().getTaskStatus();
System.out.println("現在のタスクステータス: " + taskStatus);
switch (taskStatus) {
case "SUCCEEDED":
System.out.println("タスクが完了しました");
System.out.println(JsonUtils.toJson(result));
return;
case "FAILED":
System.out.println("タスクの実行に失敗しました。ステータス: " + taskStatus);
return;
case "PENDING":
case "RUNNING":
System.out.println("タスクは進行中です。5 秒後に再クエリします...");
Thread.sleep(interval);
break;
default:
System.out.println("不明なタスクステータス: " + taskStatus + "。5 秒後に再クエリします...");
Thread.sleep(interval);
break;
}
} catch (ApiException | NoApiKeyException e) {
System.err.println("API 呼び出し例外: " + e.getMessage());
return;
} catch (InterruptedException e) {
System.err.println("スレッド割り込み例外: " + e.getMessage());
Thread.currentThread().interrupt();
return;
}
}
}
public static void main(String[] args){
Text2Image text2Image = new Text2Image();
text2Image.asyncCall();
}
}レスポンス例
タスク作成時のレスポンス
{ "request_id": "5dbf9dc5-4f4c-9605-85ea-542f97709ba8", "output": { "task_id": "7277e20e-aa01-4709-xxxxxxxx", "task_status": "PENDING" } }タスク結果のポーリング時のレスポンス
URL の有効期限は 24 時間です。画像は速やかにダウンロードしてください。
{ "request_id": "9f3044ba-528f-4606-8830-xxxxxx", "output": { "task_id": "fecf4c7f-3508-45f4-8454-xxxxxx", "task_status": "SUCCEEDED", "results": [ { "orig_prompt": "Healing-style hand-drawn poster featuring three puppies playing with a ball on lush green grass, adorned with decorative elements such as birds and stars. The main title “Come Play Ball!” is prominently displayed at the top in bold, blue cartoon font. Below it, the subtitle “Come [Show Off Your Skills]!” appears in green font. A speech bubble adds playful charm with the text: “Hehe, watch me amaze my little friends next!” At the bottom, supplementary text reads: “We get to play ball with our friends again!” The color palette centers on fresh greens and blues, accented with bright pink and yellow tones to highlight a cheerful, childlike atmosphere.", "actual_prompt": "Childhood-inspired hand-drawn poster design: Three playful puppies joyfully interact with a colorful ball on a vibrant patch of lush green grass. Delicate decorative elements including fluttering birds and twinkling stars are scattered throughout. At the top center, the bold, blue cartoon-style title “Come Play Ball!” stands out prominently. Directly beneath, the subtitle “Come [Show Off Your Skills]!” is rendered in cheerful green lettering. A whimsical speech bubble near one of the puppies contains the playful text: “Hehe, watch me amaze my little friends next!” At the bottom edge, smaller supplementary text reads: “We get to play ball with our friends again!” The color palette is centered on fresh greens and sky blues, accented with pops of bright pink and sunny yellow, enhancing the cheerful, childlike atmosphere. Style evokes nostalgic, hand-inked illustrations with soft textures, gentle linework, and a whimsical, storybook-like composition.", "url": "https://dashscope-result-sz.oss-cn-shenzhen.aliyuncs.com/xxx.png?Expires=xxxx" } ] }, "usage": { "image_count": 1 } }
課金とレート制限
無料クォータおよび料金については、「モデルの料金」をご参照ください。
レート制限については、「Qwen (Qwen-Image)」をご参照ください。
課金の詳細: 正常に生成された画像 ごとに課金されます。失敗した呼び出しや処理エラーは、課金対象にならず、新規ユーザー無料クォータも消費しません。
エラーコード
モデルの呼び出しに失敗してエラーメッセージが返された場合は、「エラーコード」を参照して解決してください。
よくある質問
Q: prompt_extend パラメーターを有効にするべきですか、それとも無効にするべきですか?
A: より多様な画像コンテンツを生成し、モデルに詳細を追加させたい場合は、このオプションを有効にしてください(デフォルト)。画像の詳細を厳密に制御する必要がある場合は無効にして、Text-to-Image プロンプトガイドに基づいてプロンプトを最適化してください。
Q: qwen-image、qwen-image-plus、qwen-image-max、qwen-image-2.0、qwen-image-edit の違いは何ですか?
A:
画像生成および編集を統合したモデル: Text-to-Image および画像編集の両方をサポートします。
qwen-image-2.0-proおよびqwen-image-2.0-pro-2026-03-03: 同じ機能。Pro シリーズは、より専門的なテキストレンダリング、より細かいリアルな質感、詳細なリアルなシーン、より強いセマンティクスへの忠実度を提供します。同期呼び出しのみをサポートします。qwen-image-2.0およびqwen-image-2.0-2026-03-03: 同じ機能。高速化バージョンは、モデルのパフォーマンスと品質のバランスを取ります。同期呼び出しのみをサポートします。
Text-to-Image モデル: テキスト記述から画像を生成します。
qwen-image-maxおよびqwen-image-max-2025-12-30: 同じ機能。qwen-image-plusと比較して、より高いリアリズムと自然さを実現し、キャラクターの質感、ディテール、テキストレンダリングの結果が向上しています。qwen-imageおよびqwen-image-plus: 同じ機能ですが、qwen-image-plusの方がコスト効率に優れています。qwen-image-plus-2026-01-09: Qwen-Image の新しいスナップショットバージョン。qwen-image-maxの蒸留および高速化バージョンで、高品質な画像を高速に生成できます。
画像編集モデル:
qwen-image-edit: 入力画像とテキスト命令に基づいて、画像間変換、インペインティングなどの操作を実行します。詳細については、「Qwen - 画像編集」をご参照ください。
Q: 画像ストレージのドメイン名ホワイトリストを取得するにはどうすればよいですか?
A: モデルによって生成された画像は OSS に保存されます。API は一時的な公開 URL を返します。このダウンロード URL のファイアウォールホワイトリストを設定する場合、以下の点にご注意ください。基盤となるストレージは動的に変更される可能性があります。このトピックでは、古い情報によるアクセス障害を防ぐため、固定の OSS ドメイン名ホワイトリストは提供していません。セキュリティ制御の要件がある場合は、アカウントマネージャーに連絡して、最新の OSS ドメイン名リストを取得してください。
