Skip to main content
圖片產生與編輯

文本產生映像

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

線上體驗新加坡北京 線上體驗提供無需編程的網頁版文生圖功能,在頁面中輸入文本描述即可直接產生映像:
  • 模型體驗中心:點擊上方的線上體驗連結(新加坡北京)進入,可選擇模型、設定輸出解析度、開啟智能改寫後直接提交產生。
如需在自有應用中整合文生圖能力,請使用下方的 API 呼叫方式。

模型效果

千問(Qwen-image)

複雜布局

9cea00ec-c9bf-9f35-909b-0d8c7b03f6a6_qwen_image3_serving_output_0-2026-08-06-20-13-11

長段落

e03efee1-35b1-9109-a988-e3977add0fac_qwen_image3_serving_output_0

寫實人像

2beecb7f-c3c3-9c10-9458-04325512bb8a_qwen_image3_serving_output_0

UI設計

image (92)

PPT

image (90)

插畫設計

e38cc145-78f6-92a7-9bdb-141be17dba04_qwen_image3_serving_output_0

複雜布局
Create a 16:9 wide horizontal e-commerce storefront hero banner infographic for “TodoTi,” a Mexican-inspired colorful lifestyle brand. The design should look like a professional online shop header for desktop and tablet, with clear visual hierarchy, festive marketing energy, and readable English typography.

Background: vibrant Mexican folk color palette of bright yellow, warm red, peacock blue, and emerald green, blended with soft watercolor washes, subtle handmade paper texture, and fine grain. The top and bottom edges are decorated with traditional papel picado cut-paper banners made of repeating diamonds, triangles, and wave shapes in alternating yellow, red, green, and purple. The papel picado should look light and gently fluttering, with cut-out areas revealing a deep starry-night blue background. Below the top papel picado and above the bottom papel picado, add a continuous Aztec geometric border of stepped lines and diamond motifs in white and antique gold.

Four corners: add small 3D decorative Talavera ceramic pots with blue-and-white floral patterns, glossy glaze highlights, and miniature potted cacti with rich green texture and fine spines. These corner elements should balance the composition and add handcrafted detail.

Left third: brand identity zone. Feature a large 3D wordmark “TodoTi.” The letter “T” extends into two green cactus pads with clear vein texture; the letter “o” contains a red-and-yellow sunburst with sixteen thin rays; the curve of the letter “d” is decorated with blue-and-white Talavera ceramic patterns featuring three peonies and winding vines; the dot of the letter “i” is a glossy red cherry tomato with a white highlight. The wordmark has bold black outlines, high-saturation gradient fills, and a soft drop shadow.

Below the wordmark, place the slogan: “TodoTi — Your Colorful Lifestyle Hub.” The slogan is in rounded bold white sans-serif with a subtle red glow, centered and highly legible. Below it, add a smaller handwritten-style subtitle in bright yellow: “Mexican-inspired warmth to brighten every day.”

Behind the wordmark, add a faint semi-circular Aztec sun calendar relief in antique gold and bronze, with fine geometric patterns and a stylized face motif featuring diamond eyes and a rectangular mouth. The relief should glow softly with warm golden light. On the left edge, stack three small circular badges with peacock-blue backgrounds, white text, and stitched dashed borders: “Curated Picks,” “Direct Sourcing,” and “Thoughtful Service.”

Center-left: a cheerful Mexican folk-art lifestyle illustration. A cute Catrina skeleton girl wears a wide straw sombrero with red-and-green woven tassels and a colorful embroidered poncho in warm red and peacock blue. Her poncho is decorated with Aztec geometric patterns and blooming marigolds with radiating petals. Her face has elegant Day of the Dead makeup: black heart-shaped eye details with white dashed outlines, red rose cheek motifs, and a warm friendly smile. She pushes a vintage wooden cart with mosaic-tile wheels in blue, white, yellow, and green.

The cart is filled with clearly visible everyday products with small clean English labels. Include a Talavera ceramic mug labeled “Talavera Ceramic Mug — Heat-resistant, underglaze art, 350ml”; a handwoven sisal basket labeled “Handwoven Basket — Natural sisal, sturdy, 30x20x15cm”; a green cactus-shaped scented candle with a soft flame labeled “Cactus Candle — Plant essential oil, calming, 40-hour burn”; and colorful Mexican throw pillows labeled “Mexican Pillow — Cotton-linen, removable cover, 45x45cm.” The illustration background is a sunny desert oasis with real cacti, soft clouds, warm side-backlight, and a thin golden rim light on the illustrated elements.

Center-right: product category navigation in a 2x2 grid of rounded rectangle cards with even spacing, 15px rounded corners, and subtle paper texture. Card 1, red background, title “Home Textiles” in bold white, with a flat icon of a woven wall tapestry with tassels; body text: “Rugs, pillows, tablecloths, curtains. Premium cotton-linen with vivid colors that bring Mexican warmth home.” Card 2, peacock-blue background, title “Kitchen & Dining” in bold white, with a Talavera ceramic plate icon; body text in bright yellow: “Bowls, cups, tableware, storage. Handcrafted ceramic texture makes every meal feel special.” Card 3, bright yellow background, title “Bath & Care” in bold dark brown, with a cactus-shaped soap dish icon; body text in dark brown: “Towels, soap dishes, toothbrush cups, shelves. Water-resistant materials for a fresh, relaxing bath space.” Card 4, emerald-green background, title “Lifestyle Goods” in bold white, with a colorful pinwheel icon; body text in white: “Hangers, hooks, tissue boxes, trash bins. Practical, beautiful details that elevate daily living.”

Right side: promotional zone shaped like a large Mexican mariachi guitar. The guitar body is warm wood with red-and-gold floral vine carvings, the neck extends upward, and the strings are silvery with a metallic shine. Inside the guitar body, place the main promotion. At the top, add a red ribbon banner with white bold text: “TodoTi Grand Opening Fiesta.” Below it, display a large offer: “Spend $199, Save $50,” with “Spend” and “Save” in white medium text and the numbers in oversized yellow-and-red 3D type. Below the offer, add smaller handwritten white text: “New customers: $20 off first order + free shipping.”

At the bottom of the guitar body, place three small circular badges with dark blue backgrounds, white text, and thin gold outlines: “7-Day Easy Returns,” “Fast Shipping,” and “Authentic Quality.” From the guitar neck, let several colorful ribbons flow outward with tilted text: “Now through the end of the month.”

Bottom area: brand story and culture zone against a deep blue night sky with glowing white five-pointed stars and black cactus silhouettes. On the left, place a title block: “About TodoTi” in bold white with a soft yellow glow. To the right, create three equal columns. Column 1 heading in bright yellow with a white underline: “Design Philosophy”; body in light gray-white: “TodoTi brings the color and craft of Mexican folk art into modern home essentials, blending Aztec motifs and Talavera patterns with everyday practicality.” Column 2 heading: “Quality Promise”; body: “We carefully select trusted global suppliers and test every product for safe, durable, and eco-friendly quality.” Column 3 heading: “Lifestyle Philosophy”; body: “Life is better in color. TodoTi helps you celebrate daily moments with warmth, joy, and vibrant Mexican-inspired energy.”

Very bottom: a slim interactive guidance bar above the Aztec border. Use a translucent frosted-white background with a soft blur. Left side: “Get more home inspiration from @TodoTiOfficial” in dark brown, aligned with a small official badge icon. Center: a white rounded search box with a magnifying-glass icon and placeholder text: “Search everyday essentials and start a colorful life” in warm red. Right side: a headset customer-service icon with dark brown text: “Questions? Customer Care: 400-888-TODO | 9:00–22:00.”

Overall style: vibrant, festive, handcrafted, authentic Mexican-inspired e-commerce banner, modern retail marketing layout, balanced composition, clean information hierarchy, high readability, warm lighting, rich details, professional storefront hero image. All on-image text must be in English only, with no Chinese characters, no misspellings, and clean legible typography.
超長段落
Vertical Western European 19th-century illustrated poetry page, Romantic maritime farewell theme, international English visual tradition, not an East Asian painting. The composition is a vertical art print or vintage book page with aged ivory paper, fine engraved linework, muted blue-gray watercolor washes, and elegant negative space. The main feature is a long English poem rendered clearly in elegant English copperplate-inspired calligraphy, highly legible, English alphabet only, standard left-to-right reading order, top-to-bottom layout, correct punctuation, exact line breaks, natural ink pressure, dark sepia-black lettering, subtle vintage letterpress texture, refined international typography.

Below and around the text, illustrate a cold twilight seashore: gray stones beside the sea, a small boat floating near the shore, distant ships moving toward a haven under low hills, pale evening mist over the water, faint moonlight, soft ripples, a lonely coastal atmosphere, melancholic but restrained. The mood is poetic, timeless, and elegant, like a Victorian English maritime lyric. No Chinese characters, no Chinese painting style, no seals, no stamps, no modern objects, no illegible glyphs, no random letters.

Render exactly the following 12 lines from Alfred, Lord Tennyson's public-domain poem “Break, Break, Break”; do not render the title or author name:

Break, break, break,
On thy cold gray stones, O Sea!
And I would that my tongue could utter
The thoughts that arise in me.
O well for the fisherman's boy,
That he shouts with his sister at play!
O well for the sailor lad,
That he sings in his boat on the bay!
And the stately ships go on
To their haven under the hill;
But O for the touch of a vanish'd hand,
And the sound of a voice that is still.

High resolution, masterful long-form English text rendering, poetic, elegant, museum-quality Western illustrated book page.
寫實人像
幫我產生一張生活化美食男生人像寫真,呈現實拍電影質感。畫面主體是一位24歲左右的年輕男生,五官清爽乾淨,眉眼溫和,皮膚自然清透,保留真實的膚質細節。他穿著質地柔軟的米白色粗棒針織毛衣,內搭純白T恤微微露出領口,展現出溫暖、精緻且鬆弛的生活氣息。人物坐在溫馨的西餐廳餐桌前,身體微微前傾,右手握著銀質刀叉正在輕輕切開盤中的惠靈頓牛排,左手自然輕扶著案頭邊緣。他微微側頭看向鏡頭,嘴角帶著若有似無的鬆弛淺笑,眼神溫柔且帶有生活感。木質案頭上擺滿了精緻的西餐餐食,旁邊有裝著琥珀色飲品的複古高腳杯和一小瓶淡雅的複古插花。人物身後是通透的玻璃牆面,上面印有淺金色的法文手寫體菜單“Menu du Jour”,文字以絲印工藝自然貼合在玻璃表面,並帶有輕微的環境反光。環境採用暖黃色室內頂光,光線柔和地灑在人物面部和案頭食物上,食物表面泛著誘人的高光,背景玻璃透出室外微弱的冷色環境光線,形成電影感十足的冷暖光影對比。採用近距離平視取景,機位略帶側前方的呼吸感,避免死板置中,小景深讓背景的玻璃牆面和餐廳環境輕微虛化,形成溫暖的散景光斑,前景的插花和飲品邊緣也帶有自然的虛化過渡,整體色調溫暖治癒,充滿濃鬱的生活氛圍與美食誘惑。
UI設計
這張圖片是一款沈浸式亞洲雨林聲音探索體驗網站的寬屏電腦端介面設計,整體氛圍暗沉靜謐,設計構想源自老式野外錄音裝置與類比科學儀器。整體配色以深邃祖母綠、濃鬱黑曜石黑與柔和大地棕為主,營造出安寧沉靜的氛圍。介面搭載細微水汽與薄霧特效,柔和斑駁的光影折射效果類比陽光穿透茂密樹冠的景象,背景融入紙張細紋、葉脈等自然肌理。整體畫面寫實度極高,風格對標英國廣播公司高端自然紀實紀錄片,構圖富有電影質感,渲染細節極致精細。
頁面最頂端橫貫一整條極簡半透明導覽列。最左側為品牌識別,由精緻線條繪製的老式類比麥克風與龜背竹葉交織而成,搭配柔和米奶油色優雅襯線字型文字“RAINFOREST ARCHIVE”。導覽列右側是導覽功能表,包含四個極簡文字連結,字型與顏色和品牌名保持一致:“Expeditions”、“Species”、“Field Notes”、“About”。
頁面上三分之二地區為主視覺橫幅板塊。背景是一張畫質超清、氛圍感濃鬱的古老亞洲龍腦香科雨林實景圖,林間縈繞著輕柔綿延的薄霧;前景虛化的深綠色蕨類枝葉形成自然暗角。橫幅板塊左側疊加主標題,採用大號高對比精緻襯線字型,文字為“Voices of the
Canopy”。標題正下方是字型大小更小、質感雅緻的副標題,淺米奶油色,內容為“An auditory journey through the ancient
dipterocarp forests of Southeast Asia.”。文字帶有輕微打字機質感,字元排布存在細微自然錯落,強化複古類比裝置的複古氛圍。
橫幅板塊中下位置是核心音頻互動組件:一台複刻老式野外類比錄音機的精密播放器,原型為經典納格拉或馬蘭茨磁帶機。播放器機身採用拉絲深槍灰色金屬材質,帶有細微自然劃痕與使用磨損痕迹;配有兩個大型滾花金屬旋鈕,旋鈕上印有小巧清晰的無襯線刻印文字“GAIN”與“MONITOR”。裝置中央是經典音量表,內建溫潤柔和的琥珀色背光,表內指標輕靠零刻度位置。音量表右側設有重型實體撥動開關,撥至上方代表“PLAY”播放狀態。音頻播放時,音量表向外緩緩擴散出同心波紋特效,形似輕柔水紋或細微聲波,採用半透明霧綠色調,與薄霧背景自然融合。
橫幅板塊下方,頁面配置切換為簡約紀實風網格,用作聲音素材庫地區。板塊頂部配有精緻小型標題,全大寫字母加寬字距排版,文字為“CURRENT EXPEDITIONS”。標題下方採用規整雙欄網格,陳列四張風格各異的聲景卡片。
左上第一張卡片:背景是氛圍感暗沉的薄霧河岸縮圖,標題文字“Dawn Chorus in Danum Valley”,下方標註資訊“Location: Sabah, Borneo”、“Duration: 42:15”,卡片右側配有一枚小巧琥珀色標識,標註“Currently Playing”。
右上第二張卡片:畫面為濕潤寬大綠葉特寫,標題文字“Monsoon Rain on Broadleaves”,標註資訊“Location: Khao Yai, Thailand”、“Duration: 1:15:30”,附帶細線條邊框按鈕,文字“Listen”。
左下第三張卡片:畫面是黃昏時分森林樹冠朦朧剪影,標題文字“Nocturnal Gibbon Calls”,標註資訊“Location: Khao Sok, Thailand”、“Duration: 58:02”,附帶細線條邊框按鈕,文字“Listen”。
右下第四張卡片:畫面為樹皮紋理微距特寫,標題文字“Hornbill Wingbeats”,標註資訊“Location: Taman Negara, Malaysia”、“Duration: 24:40”,附帶細線條邊框按鈕,文字“Listen”。
聲景網格最右側,縱向貫穿該下半地區的豎版面板,設計複刻老式野外科學記錄本內頁。紙張帶有柔和複古米黃肌理,頁面右下角留有淡咖啡漬痕迹。面板標題採用打字機等寬字型,文字“FIELD NOTES”;本文墨水色調雅緻、微微褪色,內容為:
“Recorded using
parabolic microphones
and Nagra IV-S
tape recorders.
Humidity: 94%
Temp: 24°C”
文字旁配有深棕烏墨手繪精緻豬籠草植物速寫。
頁面最底端是極簡頁尾,整頁寬度貫通,上方設有一條細深綠色分隔線。頁尾左側文字“Copyright 2024 Rainforest Archive”,右側文字“Funded by the Wildlife Conservation Society”,兩處文字均採用柔和低調的精緻小號襯線字型。
PPT製作:
這是一張寬高比為 16:9 的專業教育類 PPT 投影片,整體背景採用極淡的藍灰色柔和漸層,疊加有極低透明度的正弦波暗紋與微弱的網格點陣紋理,營造出嚴謹的物理學術氛圍與科技感。畫面頂部置中位置是主標題區,文字為巨大的深藏青色無襯線粗體“AC Circuit Anaysis: Resistor with Sinusoidal Voltage”,標題下方緊貼一條明亮的橙色細橫線作為視覺分割,橫線兩端帶有微小的圓形端點裝飾,增強版式的儀式感。畫面主體分為左右兩列,採用嚴謹的柵格對齊系統,左右兩列寬度比例約為 1:1.2,確保右側複雜的公式計算擁有充足的展示空間。左側列頂部是一個圓角矩形橙色標題列,內部置中顯示白色加粗文字“PROBLEM DATA & WAVEFORM”,標題列底部帶有輕微的投影,使其具有浮起的立體質感。橙色標題列下方是一個淺灰白色的圓角數據卡片,卡片邊緣有極細的淺藍色邊框,內部垂直排列四個資料要點,每個要點左側配有純灰色的極簡線性表徵圖,依次為電阻符號、波浪線、電壓箭頭和時鐘符號。四個要點的文字採用深灰色清晰字型,依次為“Resistor (R) = 10 Ω”、“Waveform = Sinusoidal”、“Peak Voltage (V subscript p) = 311 V”、“Period (T) = 0.02 s”,文字排版整齊,行距舒適,關鍵數字使用稍深的顏色進行視覺強調。數據卡片下方是圖表區域,頂部置中顯示深灰色圖表標題“Voltage vs. Time”。圖表主體是一個帶有淺灰色網格線的二維座標系,垂直 Y 軸左側標有深灰色文字“Voltage (V)”,刻度標記旁分別標有白色背景框包裹的深藍色文字“+311”、“0”和“-311”。水平 X 軸下方標有深灰色文字“Time (s)”,刻度標記旁標有“0.01”和“0.02”。座標系中央繪製了一條平滑、飽滿且帶有輕微光暈效果的鮮紅色正弦波曲線,曲線線條寬度適中,展現出完美的周期性。在正弦波的波峰處,有一條深藍色的垂直雙向箭頭指示振幅,箭頭旁標有深藍色文字“V subscript p = 311 V”。在 X 軸的一個完整周期上方,有一條深藍色的水平尺寸標註線,兩端帶有垂直引出線,中間標有深藍色文字“T = 0.02 s”。圖表區域整體留白充足,視覺焦點集中在紅色波形上。右側列頂部同樣是一個圓角矩形橙色標題列,與左側標題列高度對齊,內部置中顯示白色加粗文字“SOLUTION STEPS & CALCULATIONS”。橙色標題列下方垂直排列四個淺藍色漸層的圓角卡片,卡片之間保持均勻的垂直間距,內部留有充足的呼吸空間。第一個卡片左上方有一個深藍色的圓形編號徽章,內部顯示白色數字“1”。卡片標題為深藍色加粗文字“1. Maximum Current (I subscript p)”。下方本文分為三行,採用標準數學公式的視覺樣式排版,呈現為分數線、上下標和根號的優雅形態,文字內容為深灰色“Formula: Ohm’s Law, I subscript p = V subscript p over R”,接著是計算過程“I subscript p = 311 V over 10 Ω = 31.1 A”。卡片右下角有一個亮黃色底色的圓角高亮框,內部顯示加粗的深藍色文字“I subscript p = 31.1 A”。第二個卡片左上方編號徽章顯示“2”,標題為“2. AC Voltmeter Reading (V subscript rms)”。本文包含說明“Voltmeters read RMS value.”,公式“V subscript rms = V subscript p over square root of 2”,以及計算“V subscript rms = 311 V over 1.414 ≈ 220 V”,右下角高亮框顯示“V subscript rms ≈ 220 V”。第三個卡片編號徽章顯示“3”,標題為“3. Actual Power Dissipated (P subscript avg)”。本文包含“Using RMS values.”,公式“P subscript avg = (V subscript rms) squared over R”,計算過程“P subscript avg = (220 V) squared over 10 Ω = 48400 over 10 W = 4840 W”,右下角高亮框顯示“P subscript avg = 4.84 kW”。第四個卡片編號徽章顯示“4”,標題為“4. Joule Heat in Half Cycle (Q subscript half)”。本文包含“Energy = Power × Time”,時間計算“Time = T over 2 = 0.01 s”,主計算“Q subscript half = P subscript avg × (0.01 s) = 4840 W × 0.01 s = 48.4 J”,右下角高亮框顯示“Q subscript half = 48.4 J”。四個卡片的高亮框統一位於右下角,形成整齊的視覺對齊與閱讀動線。畫面最底部是一條極細的淺灰色橫向分隔線,分隔線下方置中顯示淺灰色小號無襯線字型“Experimental Physics - AC Circuits Analysis Module”。頁尾地區保持極簡,其餘背景保持純圖形與留白。整張投影片色彩系統以深藏青、亮橙色、淺藍灰和純白為主,紅色波形與黃色高亮框作為視覺點綴,打破了單調,提升了畫面的活力與專業度。所有文字邊緣銳利,對比極高,確保在投影或螢幕上清晰可讀。光影處理克制,僅通過卡片底部的微弱投影和標題列的輕微高光來增強層次感,整體呈現出高度成熟、結構清晰、資訊飽滿的專業物理教學課件質感。
插畫設計:
這幅畫作以柔和的米白色水彩紙為底,呈現一幅手繪水彩插圖。紙張表面展現出傳統植物藝術的特徵,包括清晰可見的顏料顆粒和濕畫法帶來的柔和色彩暈染。畫面上方中央地區繪有一簇簇紫羅蘭和三色堇。花瓣由淡紫色、深紫色和淡紫色漸層交織而成,花心呈金黃色。花朵旁點綴著一片翠綠色的小葉,以半透明的水彩暈染和精細的葉脈刻畫而成。柔和的定向光線照亮畫面,突顯了水彩紙的質感和顏料的微妙變化。在花卉圖案正下方,紙張下半部分水平置中的位置,是“Виолета”字樣。該字樣以弧形書法體書寫,並使用了金屬金色墨水。字母造型採用流暢、連續的筆畫,並略帶浮雕立體感,在光線照射下呈現出柔和的金屬光澤。

萬相

人像寫真

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

模型選型

  • qwen-image-3.0-pro:千問映像3.0旗艦版,支援prompt智能改寫,擅長文本渲染,能精準產生貼合物理材質的中英文。
  • wan2.7-image-pro:功能最全面,支援組圖產生和高達4096x4096的解析度,並增強了五官控制、色彩控制和超長文字渲染能力。
  • z-image-turbo:追求速度與性價比。產生速度快、成本低,擅長高逼真度的人像與產品圖。

使用方式

文生圖提供兩種使用方式,請按需選擇:

使用方式

是否需要編程

入口

適用情境

網頁版線上體驗

模型體驗中心(見本文開篇的線上體驗連結)

快速試用模型、驗證提示詞效果、少量出圖

API 呼叫

見下方快速開始

在自有應用或服務中批量、自動化地整合文生圖能力

快速開始

前提條件

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

範例程式碼

調用方式說明
  • 千問-同步調用
  • 萬相-非同步呼叫
  • Python
  • Java
  • curl
import os
import base64
import mimetypes
import dashscope
from dashscope import MultiModalConversation

dashscope.base_http_api_url = 'https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1'

response = MultiModalConversation.call(
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    model="qwen-image-3.0-pro",
    messages=[{
        "role": "user",
        "content": [
            {"text": "畫面是一張豎幅戶外人像攝影,整體從上到下呈現溫暖的午后街景氛圍。頂部左側到上方大面積被深綠色藤蔓和橙色小花覆蓋,花葉從建築簷口自然垂落,受陽光照射的葉片呈黃綠色高光,陰影處則偏深綠,形成濃密而柔和的背景層次。左上至中上地區是一塊深藍色橫向招牌,招牌表面較暗、略帶磨砂質感,上面以白色哥特體大字寫著 Il Messaggero,文字位於畫面左側偏上,部分被前景花葉輕微遮擋,字型高對比、帶裝飾性尖角和粗細變化。招牌下方是報刊亭或書報攤的玻璃展示窗,黑色金屬架構將櫥窗分隔成多個矩形地區,內部陳列著許多報紙、雜誌和書刊封面,但大多因景深虛化和光線反射而難以辨讀,形成淺色紙張與深色邊框交錯的背景材質。畫面右上方是強烈的逆光地區,陽光從街道盡頭照入,背景建築被虛化成米灰色塊面,邊緣柔和,呈現明顯的淺景深效果。畫面中部偏右是一名年輕成年女性的半身至膝上人像,她回頭面向鏡頭微笑,身體略向右轉,肩背朝向觀者,姿態自然放鬆。她有長而濃密的黑色波浪捲髮,髮絲被逆光勾勒出金色輪廓光,發梢在右側向外散開,顯得輕盈蓬鬆。她膚色白皙,臉型柔和偏鵝蛋形,眉形細緻,眼睛明亮,眼妝清透,睫毛明顯,面部帶有自然高光,唇部為柔和珊瑚紅色,笑容露齒,表情親切明朗。她佩戴小巧耳飾,身穿黑色細肩帶露背連衣裙,面料顏色深黑、輪廓簡潔,細肩帶從肩部向背部延伸,背部線條清晰。畫面下部偏左到中部,她雙手抱著一束玫瑰花,花束體積較大,主要由橙色、杏色、粉色和淺桃色玫瑰組成,花瓣層層捲曲,邊緣被陽光照亮,綠色葉片和長花莖從花束下方垂出,花束與黑色裙裝形成鮮明色彩對比。右側背景是一條被陽光照亮的城市街道,地面呈暖灰與金黃色調,遠處建築、街邊設施和一個模糊的紅色圓形交通標誌位於右下遠景,均因焦外虛化而只保留色塊和輪廓。整張照片採用暖色膠片感處理,帶有細膩顆粒、柔和對比和明顯逆光邊緣光,人物位於視覺焦點,背景報刊亭、花藤、街道和陽光共同營造出浪漫、明亮、都市漫步式的氛圍。"}
        ]
    }],
    prompt_extend=True
)

print(response)
if response.status_code == 200:
    url = response.output.choices[0].message.content[0]["image"]
    print(f"Generated image URL: {url}")
else:
    print(f"Error: {response.code} - {response.message}")

關鍵能力

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提升出圖品質。
參數: parameters.prompt_extend_mode (string,可選,預設為 direct)。僅qwen-image-3.0系列支援,用於指定prompt_extend開啟後的改寫方式:
  • direct:直接提示詞增強(DPE),適用於大多數情境。文生圖(T2I)和圖生圖/影像編輯(I2I)均支援。
  • agent:智能體提示詞增強(APE),提供更精細的改寫效果,僅支援文生圖(T2I)。圖生圖/影像編輯(I2I)情境傳入agent將返回400錯誤。

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-3.0 系列

自訂 "寬*高"

512*512 – 2048*2048

模型自動推薦

1:8 – 8:1

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與自訂40964096解析度,其餘情境僅支援2K與20482048解析度。
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-3.0系列, 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%"
    }
]

7. 其他通用參數

參數:parameters.n(integer,可選,預設為 1)。輸出映像的數量。qwen-image-3.0 系列支援 1~6 張;wan2.7-image-prowan2.7-image 在關閉組圖模式時支援 1~4 張;開啟組圖模式時表示最大產生映像數量(取值範圍 1~12,預設為 12),詳見上文“組圖產生”。
n 直接影響費用:費用 = 單價 × 成功產生的圖片張數。
參數:parameters.seed(integer,可選,取值範圍 [0, 2147483647])。隨機數種子,未傳入時由服務隨機播放;使用相同 seed 可使產生結果保持相對穩定。具體支援情況以各模型的 API 參考為準。 參數:parameters.watermark(bool,可選,預設為 false)。是否添加浮水印標識,浮水印位於圖片右下角,文案為“AI產生”。

應用於生產環境

  • 容錯策略
    • 處理限流:當 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提升出圖品質。 Q:模型體驗如何清空會話的內容? A: 點擊控制台右上方清空当前对话
Token Plan
模型體驗
用量統計與效能監控
資產中心
服務支援