跳转到主要内容
图像生成与编辑

文生图

根据文本提示词生成图像。

根据文本描述生成图像。如需对比各模型并选择合适的方案,请参见图像模型模型体验千问云

模型效果展示

Qwen-Image

复杂文字长段落复杂版式
复杂文字
长段落
复杂版式
海报创作插画设计写实摄影
海报创作
插画设计
写实摄影
复杂文字: 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 silent 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 - presentation.海报创作: 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 "Qwen Cloud" "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.写实摄影: A realistic, high-fashion street-style photograph of a young Asian woman. She stands confidently on a vibrant, neon-lit city street at night. She is wearing a sleek black bomber jacket with a subtle white geometric logo and the word "Qwen" embroidered on the back, paired with dark cargo pants. The background is filled with the glowing signs and soft bokeh of city lights, creating a cinematic and atmospheric mood. The lighting is dramatic, with highlights from the neon signs casting colors onto her face and jacket. In the bottom-right corner, overlayed text reads "Neon Dreams" and "Urban Pulse". The text is in a modern, stylish, sans-serif font with a slight neon glow effect, seamlessly integrated into the composition. The entire image should be a masterpiece, ultra-detailed, 8K, UHD, with sharp focus and professional photographic quality, capturing a candid yet powerful urban moment.

Wan 系列

人像摄影写实摄影绘画风格
人像摄影
写实摄影
绘画风格
文字生成海报设计图集生成
文字生成
海报设计
图集生成
人像摄影: 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 with a blurred, cold-gradient background, authentic Nordic facial features and porcelain skin texture.写实摄影: a 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 scene, 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.文字生成: A page from a botanical illustration book, hand-drawn watercolor style, depicting a "dandelion" and labeling its various parts.海报设计: 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.图集生成: Memories of an old man's life, four portraits in different frames, depicting his childhood (black and white photo), youth (military uniform photo), middle age (business suit work photo), and old age (photo with his wife).

模型可用性

模型详情和定价请参见图像模型

快速开始

前提条件

获取 API key 并将其设置为环境变量。如需使用 SDK,请先安装 SDK
Python SDK 需要 1.25.15+ 版本,Java SDK 需要 2.22.13+ 版本。

示例代码

所有 Wan 模型都支持异步调用。wan2.7-image-prowan2.7-imagewan2.6-imagewan2.6-t2i 还支持同步调用。所有 Qwen-Image 模型支持同步调用,其中 qwen-image-plusqwen-image 还支持异步调用。
  • 同步调用(Qwen-Image)
  • 异步调用(Wan)
请求示例
import json
import os
import dashscope
from dashscope import MultiModalConversation

dashscope.base_http_api_url = 'https://dashscope.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="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}")
响应示例
{
  "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.oss-cn-shanghai.aliyuncs.com/xxx.png?Expires=xxx"
            }
          ]
        }
      }
    ]
  },
  "usage": {
    "input_tokens": 0,
    "output_tokens": 0,
    "width": 2048,
    "image_count": 1,
    "height": 2048
  }
}

核心能力

指令遵循

参数说明
  • Prompt(必选):描述期望的内容、风格和构图。传入格式如下:
    • Qwen-Image、Wan 2.7 和 wan2.6-t2i:通过 input.messages[].content[].text 传入。参见示例代码中对应标签页的代码。
    • Wan 2.5 及更早版本:通过 input.prompt 传入。
  • negative_prompt(可选):描述需要从图像中排除的元素,如"模糊"或"多余的手指"。通过 parameters.negative_prompt 设置。除 wan2.7-image-prowan2.7-image 外,所有模型均支持。
wan2.7-image-prowan2.7-image 支持 negative_prompt,请使用正向提示词来引导生成效果。
提示词编写建议:结构化的提示词通常能产生更好的效果。详见文生图提示词指南

启用提示词改写

参数parameters.prompt_extend(布尔值,默认:true)。 自动扩展简短的提示词以提升图像质量,会增加约 3-4 秒的延迟。
wan2.7-image-prowan2.7-image 支持 prompt_extend,请改用 thinking_mode——详见 Wan 2.7 参数
使用建议
  • 启用:当提示词比较简单或宽泛时,可显著提升生成质量。
  • 禁用(设为 false):当需要精细控制、已编写详细提示词、或对延迟敏感时。

设置输出图像分辨率

参数parameters.size(字符串),格式为 "宽*高"
模型尺寸格式支持范围默认值宽高比
qwen-image-2.0 系列自定义 "宽*高"512*512 – 2048*20482048*2048 (1:1)
qwen-image-max / qwen-image-plus仅支持固定预设见下方预设值1664*928 (16:9)
wan2.7-image-pro简写或 "宽*高"768*768 – 4096*4096"2K" (2048*2048)1:8 – 8:1
wan2.7-image简写或 "宽*高"768*768 – 2048*2048"2K" (2048*2048)1:8 – 8:1
wan2.6-image自定义 "宽*高"768*768 – 1280*1280与输入一致(≤1280*1280)1:4 – 4:1
wan2.6-t2iwan2.5-t2i-preview自定义 "宽*高"1280*1280 – 1440*14401280*12801:4 – 4:1
wan2.2 及更早的文生图模型自定义 "宽*高"单边 [512, 1440],≤1440*14401024*1024 (1:1)
此处列出的 wan2.6-image 仅针对其图文交错生成模式。如需图像编辑功能,请参见图像编辑
简写尺寸(仅限 wan2.7,不可与像素值混用):
简写分辨率wan2.7-image-prowan2.7-image
"1K"1024*1024支持支持
"2K"2048*2048支持(默认)支持(默认)
"4K"4096*4096支持不支持
各像素范围下的推荐分辨率
宽高比4K2K1K
1:14096*40962048*20481280*1280
16:94096*23042688*15361696*960
9:162304*40961536*2688960*1696
4:34096*30722368*17281472*1104
3:43072*40961728*23681104*1472
  • 4K:仅 wan2.7-image-pro 支持。
  • 2K:wan2.7-image-pro、wan2.7-image、qwen-image-2.0 系列。
  • 1K:Wan 文生图模型。
qwen-image-max / qwen-image-plus 固定分辨率:1664*928(16:9,默认)、1472*1104(4:3)、1328*1328(1:1)、1104*1472(3:4)、928*1664(9:16)。

设置生成图片数量

参数parameters.n(整数)。
模型范围默认值
wan2.7(enable_sequential=false1–44
wan2.7(enable_sequential=true1–1212
qwen-image-2.0 系列1–61
qwen-image-max / qwen-image-plus仅支持 11
wan2.6-image(enable_interleave=false1–44
wan2.6-image(enable_interleave=true仅支持 11
wan2.6-t2i / wan2.5 及更早版本1–44
费用 = 单价 x 成功生成的图片数。测试阶段建议将 n 设为 1。
使用 wan2.6-image 的图文交错模式(enable_interleave=true)时,n 必须为 1。如需控制最大生成图片数,请使用 parameters.max_images(范围:1–5,默认:5)。实际生成数量由模型决定,可能少于指定的最大值。

Wan 2.7 参数

以下参数仅适用于 wan2.7-image-prowan2.7-image
  • enable_sequential(布尔值,默认:false):启用图集生成。设为 true 时,可将 n 设为 1-12,单次请求生成多张风格一致的图片。
    enable_sequential 设为 true 时,thinking_modecolor_palette 不可用。
  • thinking_mode(布尔值,默认:true):启用增强推理,提升提示词理解能力和图像质量。仅在 enable_sequentialfalse 时可用。
  • color_palette(数组):自定义配色方案。指定 3-10 种颜色(推荐 8 种),每种颜色包含十六进制色值和占比(百分比字符串),所有占比之和必须为 100%。仅在 enable_sequentialfalse 时可用。
"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%"}
]

上线注意事项

容错处理

  • 限流Throttling 错误码或 HTTP 429 表示触发了限流。详见限流
  • 异步任务轮询:前 30 秒每 3 秒轮询一次,之后逐步延长间隔。设置最终超时时间(如 2 分钟),超时后将任务视为失败。

风险防范

  • 结果持久化:图片 URL 在 24 小时后过期。获取结果后应立即下载并存储到自有存储服务(如 OSS)。
  • 内容审核:所有 promptnegative_prompt 输入都会经过内容审核。不合规的输入会被拦截,返回 DataInspectionFailed 错误。
  • 版权与合规:提示词中引用品牌商标、名人肖像或受版权保护的 IP 可能存在侵权风险,由此产生的法律责任由用户自行承担。

API 参考

错误码

调用失败时,请参见错误信息