全部產品
Search
文件中心

Alibaba Cloud Model Studio:文本產生映像

更新時間:Jul 01, 2026

通過文生圖API,您可以基於文本描述創造出全新的映像。阿里雲百鍊提供萬相(Wan)、千問(Qwen-Image)和z-image系列模型。

線上體驗新加坡北京

模型效果

千問(Qwen-image)

複雜文字

p1005416-轉換自-png

超長段落

p1005400-轉換自-png

複雜布局

3

海報製作

image

插畫設計

1

寫實攝影

2

點擊查看提示詞

複雜文字:Bookstore window display. A sign displays “New Arrivals This Week”. Below, a shelf tag with the text “Best-Selling Novels Here”. To the side, a colorful poster advertises “Author Meet And Greet on Saturday” with a central portrait of the author. There are four books on the bookshelf, namely “The light between worlds” “When stars are scattered” “The slient patient” “The night circus”

超長段落:A young girl dressed in a school uniform stands in a classroom, writing on the blackboard. Centered on the board, neatly inscribed in white chalk, is the text: “Introducing Qwen-Image, a foundational image generation model that excels in complex text rendering and precise image editing.” Soft natural light streams through the windows, casting gentle shadows. The scene is rendered in a realistic photographic style, with finely detailed textures, shallow depth of field, and warm tonal hues. The girl’s focused expression and the chalk dust suspended in the air add a sense of movement and vitality. Background elements—including student desks and educational posters—are slightly blurred to emphasize the central action. Ultra-high 32K resolution, DSLR-quality imagery, soft bokeh effect, and documentary-style composition.

複雜布局:Create a classroom PPT slide for a speech. It features artistic, decorative shapes framing neatly arranged textual info as an elegant infographic. Center title: ‘Habits for Emotional Wellbeing’, surrounded by a symmetrical floral pattern. Left upper: ‘Practice Mindfulness’ + minimalist lotus icon + text ‘Be present, observe without judging, accept without resisting’. Downward: ‘Cultivate Gratitude’ + open hand illustration + text ‘Appreciate simple joys and acknowledge positivity daily’. Bottom - left: ‘Stay Connected’ + minimalistic chat bubble icon + text ‘Build and maintain meaningful relationships to sustain emotional energy’. Bottom right: ‘Prioritize Sleep’ + crescent moon illustration + text ‘Quality sleep benefits both body and mind’. Upward right: ‘Regular Physical Activity’ + jogging runner icon + text ‘Exercise boosts mood and relieves anxiety’. Top right: ‘Continuous Learning’ + book icon + text ‘Engage in new skill and knowledge for growth’. The layout balances clarity & artistry, guiding viewers naturally. --ar 16:9 --style clean - presentatio.

海報製作: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.

插畫設計:A vibrant and lively illustration of a sunny, bustling commercial street scene, slice of life. In the foreground, a young boy in a white shirt and shorts is intently choosing items from a market stall. The stall is filled with snacks, drinks, and daily goods.The stall owner, a middle-aged man in an apron, is organizing the products. A wooden sign with “Qwen-Image” in a handwritten style hangs above the stall. The background features modern, colorful buildings with prominent signs for “Alibaba”“Model Studio”“Text-to-Image”. The sky is azure blue with fluffy white clouds and soaring seagulls.Art Style: Realism illustration, delicate and soft, vibrant colors, rich layers, subtle hand-drawn texture, detailed, strong light and shadow, full composition, strong sense of depth, cheerful and relaxing atmosphere.

寫實攝影:一位約20歲出頭的亞洲年輕女性,留著齊劉海、烏黑光滑的長直發,自然垂落於雙肩兩側。她側坐於一張複古碎花布藝沙發上,沙發圖案為米白底色配粉色與綠色花卉,質地略顯陳舊,帶有生活感。她身穿一件寬鬆的淺綠色馬海毛針織毛衣,質感蓬鬆柔軟,下身搭配淺灰藍色亞麻長裙,整體造型清新自然、慵懶隨性。右手輕輕握住一顆紅色番茄,抬至下巴附近,姿態隨意,眼神直視鏡頭,神情平靜、略帶冷淡,帶有一種漫不經心的疏離感。沙發右側放有一個淺色陶盤,盤內盛放著三至四顆飽滿鮮紅的番茄,帶有綠色蒂頭,色彩鮮豔,與畫面整體的冷綠色調形成強烈對比。背景為做舊的青綠色牆面,斑駁而有質感。窗外射入的自然光形成明顯的光束,斜斜打在人物與背景上,光影層次豐富。窗檯及背景角落擺有數盆綠植,左側隱約可見一個深棕色老式木櫃。整張照片色調偏冷綠,疊有明顯的膠捲粒紋感與輕微漏光效果,構圖飽滿,氛圍靜謐、文藝,帶有強烈的複古膠片人文攝影風格。

萬相

人像寫真

p1023523-轉換自-png

寫實攝影

p1023409-轉換自-png

繪畫流派

p1023526-轉換自-png

文字產生

p1023535-轉換自-png

海報設計

p1023546-轉換自-png

組圖產生

p1023532-轉換自-png

點擊查看提示詞

人像寫真:hyper-realistic Scandinavian woman portrait, flowing platinum blonde hair and piercing blue eyes with prominent freckles, sharp intellectual gaze, Nordic cold-toned directional lighting creating icy atmosphere, minimalist modern styling with clean lines, shallow depth-of-field blurred cold-gradient background, authentic Nordic facial features and porcelain skin texture.

寫實攝影:fish-eye perspective forest scene with dramatic perspective distortion, ultra-detailed red fox staring into lens with piercing amber eyes, hyper-realistic fur texture showing individual guard hairs and undercoat layers, radially warped trees forming circular background patterns, watercolor painting style with translucent washes and organic pigment bleeding, soft pastel palette of moss green and earth ochre tones, painterly lighting with atmospheric glow through canopy gaps

繪畫流派:Vintage oil painting style pastoral song, a farmer herding sheep across a meadow full of wildflowers, a windmill in the distance turning under blue sky and white clouds, smoke curling from the chimney of a wooden house, bright and soft colors, full of tranquility and comfort.​

文字產生:植物圖鑑的一頁,手繪水彩風格,描繪了一株“蒲公英”,並標註了它的各個部位名稱。

海報設計:Cinematic poster scene: Extreme macro close-up of eye in wooden crack. Minimalist monochrome, watercolor-CGI fusion, low saturation. Slow push-in with tremor for surreal intensity. Vast negative space, hidden title. Optimized for immersive video generation.

組圖產生:一位老人的一生回憶,四張不同畫框的肖像畫,分別描繪他的童年(黑白照片)、青年(軍裝照)、中年(西裝工作照)和晚年(與老伴的合影)。

模型選型

  • wan2.7-image-pro:功能最全面,支援組圖產生和高達4096x4096的解析度,並增強了五官控制、色彩控制和超長文字渲染能力。

  • qwen-image-2.0-pro:擅長文本渲染,能精準產生貼合物理材質的中英文,適合組建圖表、海報和PPT等。

  • z-image-turbo:追求速度與性價比。產生速度快、成本低,擅長高逼真度的人像與產品圖。

快速開始

前提條件

在調用前,請擷取API Key,再配置API Key到環境變數。如果通過DashScope SDK進行調用,還需要安裝SDK

範例程式碼

調用方式說明

萬相-非同步呼叫

Python

請求樣本
import os
import dashscope
from dashscope.aigc.image_generation import ImageGeneration
from dashscope.api_entities.dashscope_response import Message

# 以下為新加坡地區base_url,各地區的base_url不同
dashscope.base_http_api_url = 'https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1'

# 若沒有配置環境變數,請用百鍊API Key將下行替換為:api_key="sk-xxx"
# 各地區的API Key不同。擷取API Key:https://www.alibabacloud.com/help/zh/model-studio/get-api-key
api_key = os.getenv("DASHSCOPE_API_KEY")


def main():
    message = Message(
        role="user",
        content=[
            {"text": "一位年輕女性,自然隨性的自拍風格,超高清寫實人物生活照。她身著黃色碎花長袖上衣,長發自然垂落且略帶波浪卷。畫面背景為戶外自然景色,近處有綠植,遠處可見水域和山巒。自然柔和的陽光灑在人物臉上和身上,形成自然的光影效果,拍攝機位為人物手持功能的中景自拍視角,人物身體自然站立,展現出輕鬆自在的狀態。角度自然,隨手一拍的快照風格,不經意間的抓拍。"}
        ]
    )
    
    # 提交非同步任務
    print("提交非同步任務...")
    response = ImageGeneration.async_call(
        model="wan2.7-image-pro",
        api_key=api_key,
        messages=[message],
        enable_sequential=False,
        n=1,
        size="2K"
    )
    
    if response.status_code == 200:
        print(f"任務提交成功,任務ID: {response.output.task_id}")
        
        # 等待任務完成
        status = ImageGeneration.wait(task=response, api_key=api_key)
        
        if status.output.task_status == "SUCCEEDED":
            print("任務完成!")
            print(f"結果:")
            print(status)
        else:
            print(f"任務失敗,狀態: {status.output.task_status}")
    else:
        print(f"任務建立失敗: {response.code} - {response.message}")


if __name__ == "__main__":
    try:
        main()
    except Exception as e:
        print(f"錯誤: {e}")
響應樣本

1、建立任務的響應樣本

{
    "status_code": 200,
    "request_id": "4fb3050f-de57-4a24-84ff-e37ee5xxxxxx",
    "code": "",
    "message": "",
    "output": {
        "text": null,
        "finish_reason": null,
        "choices": null,
        "audio": null,
        "task_id": "77093787-a217-4c29-9cd4-ca7b5ac86xxx",
        "task_status": "PENDING"
    },
    "usage": {
        "input_tokens": 0,
        "output_tokens": 0,
        "characters": 0
    }
}

2、查詢任務結果的響應樣本

url 有效期間24小時,請及時下載映像。
{
    "status_code": 200,
    "request_id": "56e318fd-ed60-99e8-8ca1-cdef25ca4xxx",
    "code": "",
    "message": "",
    "output": {
        "text": null,
        "finish_reason": null,
        "choices": [
            {
                "finish_reason": "stop",
                "message": {
                    "role": "assistant",
                    "content": [
                        {
                            "image": "https://dashscope-result-bj.oss-cn-beijing.aliyuncs.com/xxxxxx.png?Expires=xxxxxx",
                            "type": "image"
                        }
                    ]
                }
            }
        ],
        "audio": null,
        "task_id": "77093787-a217-4c29-9cd4-ca7b5ac86xxx",
        "task_status": "SUCCEEDED",
        "submit_time": "2026-03-31 23:04:46.166",
        "scheduled_time": "2026-03-31 23:04:46.208",
        "end_time": "2026-03-31 23:05:11.664",
        "finished": true
    },
    "usage": {
        "input_tokens": 720,
        "output_tokens": 11,
        "characters": 0,
        "size": "2048*2048",
        "total_tokens": 731,
        "image_count": 1
    }
}

Java

請求樣本
import com.alibaba.dashscope.aigc.imagegeneration.*;
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.util.Collections;

public class Main {

    static {
        // 以下為新加坡地區url,各地區的base_url不同
        Constants.baseHttpApiUrl = "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1";
    }

    // 若沒有配置環境變數,請用百鍊API Key將下行替換為:apiKey="sk-xxx"
    // 各地區的API Key不同。擷取API Key:https://www.alibabacloud.com/help/zh/model-studio/get-api-key
    static String apiKey = System.getenv("DASHSCOPE_API_KEY");

    public static ImageGenerationResult waitTask(String taskId)
            throws ApiException, NoApiKeyException {
        ImageGeneration imageGeneration = new ImageGeneration();
        return imageGeneration.wait(taskId, apiKey);
    }

    public static void asyncCall() throws ApiException, NoApiKeyException, UploadFileException {
        ImageGenerationMessage message = ImageGenerationMessage.builder()
                .role("user")
                .content(Collections.singletonList(
                        Collections.singletonMap("text", "一位年輕女性,自然隨性的自拍風格,超高清寫實人物生活照。她身著黃色碎花長袖上衣,長發自然垂落且略帶波浪卷。畫面背景為戶外自然景色,近處有綠植,遠處可見水域和山巒。自然柔和的陽光灑在人物臉上和身上,形成自然的光影效果,拍攝機位為人物手持功能的中景自拍視角,人物身體自然站立,展現出輕鬆自在的狀態。角度自然,隨手一拍的快照風格,不經意間的抓拍。")
                )).build();

        ImageGenerationParam param = ImageGenerationParam.builder()
                .apiKey(apiKey)
                .model("wan2.7-image-pro")
                .messages(Collections.singletonList(message))
                .enableSequential(false)
                .n(1)
                .size("2K")
                .build();

        ImageGeneration imageGeneration = new ImageGeneration();
        ImageGenerationResult taskResult = null;
        try {
            System.out.println("----async call, creating task----");
            taskResult = imageGeneration.asyncCall(param);
        } catch (ApiException | NoApiKeyException | UploadFileException e) {
            throw new RuntimeException(e.getMessage());
        }
        System.out.println("Task created: " + JsonUtils.toJson(taskResult));

        // 等待任務完成
        String taskId = taskResult.getOutput().getTaskId();
        ImageGenerationResult result = waitTask(taskId);
        System.out.println(JsonUtils.toJson(result));
    }

    public static void main(String[] args) {
        try {
            asyncCall();
        } catch (ApiException | NoApiKeyException | UploadFileException e) {
            System.out.println(e.getMessage());
        }
    }
}
響應樣本

1、建立任務的響應樣本

{
    "requestId": "7d026dc1-e8c9-9caa-84ac-e82e2da97xxx",
    "output": {
        "task_id": "2de18c56-c151-4b80-8105-1d164733exxx",
        "task_status": "PENDING"
    },
    "status_code": 200,
    "code": "",
    "message": ""
}

2、查詢任務結果的響應樣本

{
    "requestId": "daea7295-4ce0-928a-9a11-4d2bea058xxx",
    "usage": {
        "input_tokens": 720,
        "output_tokens": 11,
        "total_tokens": 731,
        "image_count": 1,
        "size": "2048*2048"
    },
    "output": {
        "choices": [
            {
                "finish_reason": "stop",
                "message": {
                    "role": "assistant",
                    "content": [
                        {
                            "image": "https://dashscope-result-bj.oss-cn-beijing.aliyuncs.com/xxxxxx.png?Expires=xxxxxx",
                            "type": "image"
                        }
                    ]
                }
            }
        ],
        "task_id": "2de18c56-c151-4b80-8105-1d164733exxx",
        "task_status": "SUCCEEDED",
        "finished": true,
        "submit_time": "2026-03-31 19:49:53.124",
        "scheduled_time": "2026-03-31 19:49:53.175",
        "end_time": "2026-03-31 19:50:53.160"
    },
    "status_code": 200,
    "code": "",
    "message": ""
}

curl

說明
  • 非同步呼叫必須設定 Header 參數X-DashScope-Asyncenable

  • 非同步任務的 task_id 查詢有效期間為 24 小時,到期後任務狀態將變為 UNKNOWN

步驟1:發起建立工作要求

該請求會返回一個任務ID(task_id)。

curl --location 'https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/services/aigc/image-generation/generation' \
    --header 'Content-Type: application/json' \
    --header "Authorization: Bearer $DASHSCOPE_API_KEY" \
    --header "X-DashScope-Async: enable" \
    --data '{
        "model": "wan2.7-image-pro",
        "input": {
            "messages": [
                {
                    "role": "user",
                    "content": [
                        {"text": "一間有著精緻窗戶的花店,漂亮的木質門,擺放著花朵"}
                    ]
                }
            ]
        },
        "parameters": {
            "size": "2K",
            "n": 1,
            "watermark": false,
            "thinking_mode": true
        }
    }'
    
步驟2:根據任務ID查詢結果

使用上一步擷取的 task_id,通過介面輪詢任務狀態,直到 task_status 變為 SUCCEEDED 或 FAILED。

{task_id}完整替換為上一步介面返回的task_id的值。task_id查詢有效期間為24小時。

curl -X GET https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/tasks/{task_id} \
--header "Authorization: Bearer $DASHSCOPE_API_KEY"

千問-同步調用

Python

請求樣本

import json
import os
import dashscope
from dashscope import MultiModalConversation

# 以下為新加坡地區URL,調用時請將WorkspaceId替換為真實的業務空間ID,各地區的URL不同。
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 Key不同。擷取API Key:https://www.alibabacloud.com/help/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-2.0-pro",
    messages=messages,
    result_format='message',
    stream=False,
    watermark=False,
    prompt_extend=True,
    negative_prompt="低解析度,低畫質,肢體畸形,手指畸形,畫面過飽和,蠟像感,人臉無細節,過度光滑,畫面具有AI感。構圖混亂。文字模糊,扭曲。",
    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/zh/model-studio/error-code")

響應樣本

映像連結的有效期間為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"
                        }
                    ]
                }
            }
        ]
    }
}

Java

請求樣本

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,調用時請將WorkspaceId替換為真實的業務空間ID,各地區的URL不同。
        Constants.baseHttpApiUrl = "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1";
    }

    // 新加坡和北京地區的API Key不同。擷取API Key:https://www.alibabacloud.com/help/zh/model-studio/get-api-key
    // 若沒有配置環境變數,請用百鍊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", "低解析度,低畫質,肢體畸形,手指畸形,畫面過飽和,蠟像感,人臉無細節,過度光滑,畫面具有AI感。構圖混亂。文字模糊,扭曲。");
        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);
    }

響應樣本

映像連結的有效期間為24小時,請及時下載映像。
{
    "requestId": "5b6f2d04-b019-40db-a5cc-xxxxxx",
    "output": {
        "choices": [
            {
                "finish_reason": "stop",
                "message": {
                    "role": "assistant",
                    "content": [
                        {
                            "image": "https://dashscope-result-wlcb.oss-cn-wulanchabu.aliyuncs.com/xxx.png?Expires=xxx"
                        }
                    ]
                }
            }
        ]
    }
}

curl

請求樣本
curl --location 'https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation' \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer $DASHSCOPE_API_KEY" \
--data '{
    "model": "qwen-image-2.0-pro",
    "input": {
        "messages": [
            {
                "role": "user",
                "content": [
                    {
                        "text": "冬日北京的都市街景,青灰瓦頂、硃紅色外牆的兩間相鄰中式商鋪比肩而立,簷下懸掛印有剪紙馬的暖光燈籠,在陰天漫射光中投下柔和光暈,映照濕潤鵝卵石路面泛起細膩反光。左側為書法店:靛藍色老舊的牌匾上以遒勁行書刻著“文字渲染”。店門口的玻璃上掛著一幅字,自上而下,用田英章硬筆寫著“專業投影片 中英文海報 進階資訊圖”,落款印章為“1k token”硃砂印。店內的牆上,可以模糊的辨認有三幅豎排的書法作品,第一幅寫著“阿里巴巴”,第二幅寫著“通義千問”,第三幅寫著“映像產生”。一位白髮蒼蒼的老人背對著鏡頭觀賞。右側為花店,牌匾上以鮮花做成文字“真實質感”;店內多層花架陳列紅玫瑰、粉洋牡丹和綠植,門上貼了一個圓形花邊標識,標識上寫著“2k resolution”,門口擺放了一個彩色霓虹燈,上面寫著“細膩刻畫 人物 自然 建築”。兩家店中間堆放了一個雪人,舉了一老式小黑板,上面用粉筆字寫著“Qwen-Image-2.0 正式發布”。街道左側,年輕情侶依偎在一起,女孩是瘦臉,身穿米白色羊絨大衣,肉色光腿神器。女孩舉著心形透明氣球,氣球印有白色的字:“生圖編輯變形平板”。裡面有一個毛茸茸的卡皮巴拉玩偶。男孩身著剪裁合體的深灰色呢子外套,內搭淺色高領毛衣。街道右側,一個後背上寫著“更小模型,更快速度”的騎手疾馳而過。整條街光影交織、動靜相宜。"
                    }
                ]
            }
        ]
    },
    "parameters": {
        "negative_prompt": "低解析度,低畫質,肢體畸形,手指畸形,畫面過飽和,蠟像感,人臉無細節,過度光滑,畫面具有AI感。構圖混亂。文字模糊,扭曲。",
        "prompt_extend": true,
        "watermark": false,
        "size": "2048*2048"
    }
}'
curl --location 'https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation' \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer $DASHSCOPE_API_KEY" \
--data '{
    "model": "qwen-image-2.0-pro",
    "input": {
      "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."
            }
          ]
        }
      ]
    },
    "parameters": {
      "negative_prompt": "低解析度,低畫質,肢體畸形,手指畸形,畫面過飽和,蠟像感,人臉無細節,過度光滑,畫面具有AI感。構圖混亂。文字模糊,扭曲。",
      "prompt_extend": true,
      "watermark": false,
      "size": "2048*2048"
    }
}'
響應樣本
{
    "output": {
        "choices": [
            {
                "finish_reason": "stop",
                "message": {
                    "content": [
                        {
                            "image": "https://dashscope-result-sh.oss-cn-shanghai.aliyuncs.com/xxx.png?Expires=xxx"
                        }
                    ],
                    "role": "assistant"
                }
            }
        ]
    },
    "request_id": "d0250a3d-b07f-49e1-bdc8-6793f4929xxx"
}

關鍵能力

1. 指令遵循(提示詞)

參數:messages.content.textinput.prompt(必選)、negative_prompt(可選)。

  • text \ prompt(正向提示詞):描述希望在畫面中看到的內容、主體、情境、風格、光照和構圖。文生圖的核心控制參數。

  • negative_prompt(反向提示詞):描述不希望在畫面中出現的內容,如“模糊”、“多餘的手指”等。僅用於輔助最佳化產生品質。

撰寫技巧:一個結構化的 Prompt 通常能帶來更好的效果,撰寫技巧請參見文生圖Prompt指南

wan2.7-image-pro、wan2.7-image不支援negative_prompt參數,對於不希望出現的元素,請在正向提示詞中描述(不要出現xxx)。

2. 開啟prompt智能改寫

參數: parameters.prompt_extend (bool, 預設為 true)。

此功能可自動擴充和最佳化較短的Prompt,提升出圖效果。開啟此功能額外耗時 3-5 秒。此耗時為使用大模型改寫文本。

實踐建議:

  • 建議開啟:當輸入 Prompt 較簡潔或寬泛時,此功能可顯著增益圖像效果。

  • 建議關閉:若需控制畫面細節、或已提供詳細描述,或對響應延遲敏感。請將參數 prompt_extend 顯式設為 false

wan2.7-image-pro、wan2.7-image不支援prompt_extend參數,可通過開啟thinking_mode提升出圖品質。

3. 設定輸出映像解析度

參數: parameters.size (string),格式為 "寬*高"

模型

size格式

總像素支援範圍

預設

寬高比

wan2.7-image-pro

縮寫

1K(1024*1024)、2K(2048*2048)、4K(4096*4096)

2K(2048*2048)

1:8 – 8:1

自訂 "寬*高"

768*768 – 4096*4096

wan2.7-image

縮寫

1K(1024*1024)、2K(2048*2048)

2K(2048*2048)

1:8 – 8:1

自訂 "寬*高"

768*768 – 2048*2048

wan2.6-image(圖文混排輸出模式)

自訂 "寬*高"

768*768 – 1280*1280

匹配輸入寬高比 (≤1280*1280)

1:4 – 4:1

wan2.6-t2i, wan2.5-t2i-preview

自訂 "寬*高"

1280*1280 – 1440*1440

1280*1280

1:4 – 4:1

wan2.2 及更早的 t2i 模型

自訂 "寬*高"

[512, 1440],且總像素 ≤1440*1440

1024*1024

-

qwen-image-2.0 系列

自訂 "寬*高"

512*512 – 2048*2048

2048*2048

-

qwen-image-max / qwen-image-plus 系列

僅限固定預設尺寸

見下方預設尺寸

1664*928 (16:9)

-

wan2.7-image-pro僅文生圖情境(無圖片輸入、非組圖產生)支援4K與自訂4096*4096解析度,其餘情境僅支援2K與2048*2048解析度。

qwen-image-max、qwen-image-plus 系列:僅支援以下 5 種固定的解析度:

  • 1664*928(預設值):16:9

  • 1472*1104:4:3

  • 1328*1328:1:1

  • 1104*1472:3:4

  • 928*1664:9:16

推薦解析度:

寬高比

4K (wan2.7-image-pro)

2K (wan2.7-image, qwen-image-2.0)

1K (Wan t2i)

1:1

4096*4096

2048*2048

1280*1280

16:9

4096*2304

2688*1536

1696*960

9:16

2304*4096

1536*2688

960*1696

4:3

4096*3072

2368*1728

1472*1104

3:4

3072*4096

1728*2368

1104*1472

4. 組圖產生

參數:parameters.enable_sequential(bool,預設為 false)。僅wan2.7-image-prowan2.7-image支援。

設為true時啟用組圖模式,模型將根據提示詞和參考圖片的內容一次性產生多張有故事連貫性的映像。

  • 產生數量:通過n參數控制,開啟組圖模式時,取值範圍1~12(預設12),實際數量由模型決定且不超過n。

  • 注意:開啟組圖模式時,thinking_modecolor_palette參數不可用。

5. 思考模式

參數:parameters.thinking_mode(bool,預設為 true)。僅wan2.7-image-prowan2.7-image支援。

開啟時,模型將增強推理能力以提升出圖品質,但會增加產生耗時。

僅在關閉組圖模式(enable_sequential=false)時可用。

6. 自訂色彩主題

參數:parameters.color_palette(array)。僅wan2.7-image-prowan2.7-image支援。

通過傳入包含顏色(hex)和佔比(ratio)的對象數組,自訂產生映像的顏色方案。需包含3至10種顏色,推薦設定為8種。所有ratio值相加總和必須為100.00%。

僅在關閉組圖模式(enable_sequential=false)時可用。

點擊查看輸入樣本

"color_palette": [
    {
        "hex": "#C2D1E6",
        "ratio": "23.51%"
    },
    {
        "hex": "#CDD8E9",
        "ratio": "20.13%"
    },
    {
        "hex": "#B5C8DB",
        "ratio": "15.88%"
    },
    {
        "hex": "#C0B5B4",
        "ratio": "13.27%"
    },
    {
        "hex": "#DAE0EC",
        "ratio": "10.11%"
    },
    {
        "hex": "#636574",
        "ratio": "8.93%"
    },
    {
        "hex": "#CACAD2",
        "ratio": "5.55%"
    },
    {
        "hex": "#CBD4E4",
        "ratio": "2.62%"
    }
]

應用於生產環境

  • 容錯策略

    • 處理限流:當 API 返回 Throttling 錯誤碼或 HTTP 429 狀態代碼時,表明已觸發限流,限流處理請參見限流

    • 非同步任務輪詢:輪詢查詢非同步任務結果時,建議採用合理的輪詢策略(如前30秒每3秒一次,之後拉長間隔),避免因過於頻繁的請求而觸發限流。為任務設定一個最終逾時時間(如 2 分鐘),逾時後標記為失敗。

  • 風險防範

    • 結果持久化:API 返回的圖片 URL 有 24 小時有效期間。生產系統必須在擷取 URL 後立即下載圖片,並轉存至您自己的持久化儲存服務中(如阿里雲Object Storage Service)。

    • Alibaba Content Security Service審核:所有 promptnegative_prompt 都會經過Alibaba Content Security Service審核。若輸入內容不合規,請求將被攔截並返回 DataInspectionFailed 錯誤。

    • 產生內容的著作權與合規風險:請確保您的提示詞內容符合相關法律法規。產生包含品牌商標、名人肖像、受著作權保護的 IP 形象等內容可能涉及侵權風險,請您自行評估並承擔相應責任。

API文檔

計費與限流

  • 模型免費額度和計費單價請參見模型價格

  • 模型限流請參見限流-映像產生

  • 計費說明:按成功產生的 映像張數 計費。模型調用失敗或處理錯誤不產生任何費用,也不消耗新人免費額度

錯誤碼

如果模型調用失敗並返回報錯資訊,請參見錯誤碼進行解決。

常見問題

Q: 圖片 URL 多久會失效?我應該如何永久儲存圖片?

A: 圖片 URL 的有效期間為 24 小時。您必須在擷取到 URL 後,立即通過程式下載圖片,並將其儲存到您自己的持久化儲存中,例如本機伺服器或阿里雲Object Storage Service。

Q: 調用API返回DataInspectionFailed錯誤,如何處理?

A: 該錯誤表示輸入文本觸發了Alibaba Content Security Service審核。請檢查並修改prompt或negative_prompt中的文本,移除可能違規的內容後重試。

Q: prompt_extend參數應該開啟還是關閉?

A: 當輸入的prompt比較簡潔或希望模型發揮更多創意時,建議保持開啟(預設)。當prompt已經非常詳細、專業,或對API響應延遲有嚴格要求時,建議顯式設定為false。

注意:wan2.7-image-pro、wan2.7-image不支援prompt_extend參數,可通過開啟thinking_mode提升出圖品質。