Skip to content

万相 2.7 图像生成

阿里巴巴万相 2.7 图像生成模型,旗舰级画质,支持 4K 分辨率、组图生成和思考模式,具备出色的中英文理解和生成能力。

模型列表

模型说明
wan2.7-image-pro旗舰版,支持 4K 分辨率
wan2.7-image标准版,最高 2K 分辨率

快速开始

python
from openai import OpenAI

client = OpenAI(
    base_url="https://open.dieyuyun.com/v1",
    api_key="YOUR_API_KEY"
)

response = client.images.generate(
    model="wan2.7-image-pro",
    prompt="一间有着精致窗户的花店",
    size="2048x2048",
    n=1
)

print(response.data[0].url)

请求端点

项目
方法POST
路径/v1/images/generations
Base URLhttps://open.dieyuyun.com
兼容协议OpenAI Images API

认证

Bearer Token: Authorization: Bearer YOUR_API_KEY

标准请求字段

字段类型必填默认值说明
modelstring模型标识: wan2.7-image-prowan2.7-image
promptstring图像描述文本,支持中英文
sizestring1024x1024图像尺寸(宽x高),详见下方支持的尺寸
ninteger1生成数量,非组图模式 1-4,组图模式 1-12
response_formatstringurl返回格式: urlb64_json
asyncbooleanfalse启用异步模式,返回 taskId 用于查询结果,详见 异步任务

扩展参数

万相 2.7 支持通过 parameters 对象传递扩展参数:

字段类型必填默认值说明
parameters.enable_sequentialbooleanfalse启用组图生成模式,生成风格一致的多张图像
parameters.thinking_modebooleantrue思考模式,启用后模型会先分析提示词再生成,提升画面准确性
parameters.color_palettestring颜色主题,指定画面的整体色调风格
parameters.watermarkbooleanfalse是否添加 AI 生成水印
parameters.seedinteger随机种子,用于复现生成结果
json
{
  "model": "wan2.7-image-pro",
  "prompt": "一间有着精致窗户的花店",
  "size": "2048x2048",
  "parameters": {
    "thinking_mode": true,
    "watermark": false,
    "seed": 42
  }
}

注意

万相 2.7 模型不支持 negative_prompt(负面提示词)和 prompt_extend(提示词扩展)参数。

支持的尺寸

wan2.7-image-pro(旗舰版,支持 4K)

尺寸比例
4096x40961:1
4096x230416:9
2304x40969:16
4096x30724:3
3072x40963:4
2048x20481:1
2688x153616:9
1536x26889:16
2368x17284:3
1728x23683:4
1024x10241:1
1696x96016:9
960x16969:16
1472x11044:3
1104x14723:4
1248x8323:2
832x12482:3

wan2.7-image(标准版,最高 2K)

尺寸比例
2048x20481:1
2688x153616:9
1536x26889:16
2368x17284:3
1728x23683:4
1024x10241:1
1696x96016:9
960x16969:16
1472x11044:3
1104x14723:4
1248x8323:2
832x12482:3

请求示例

bash
curl https://open.dieyuyun.com/v1/images/generations \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "wan2.7-image-pro",
    "prompt": "一间有着精致窗户的花店",
    "size": "2048x2048",
    "n": 1
  }'
python
from openai import OpenAI

client = OpenAI(
    base_url="https://open.dieyuyun.com/v1",
    api_key="YOUR_API_KEY"
)

response = client.images.generate(
    model="wan2.7-image-pro",
    prompt="一间有着精致窗户的花店",
    size="2048x2048",
    n=1
)

print(response.data[0].url)
javascript
import OpenAI from 'openai'

const client = new OpenAI({
  baseURL: 'https://open.dieyuyun.com/v1',
  apiKey: 'YOUR_API_KEY',
})

const response = await client.images.generate({
  model: 'wan2.7-image-pro',
  prompt: '一间有着精致窗户的花店',
  size: '2048x2048',
  n: 1,
})

console.log(response.data[0].url)

组图生成示例

启用 enable_sequential 后,模型会生成风格一致的多张图像,适合连环插画、故事板和系列素材创作:

bash
curl https://open.dieyuyun.com/v1/images/generations \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "wan2.7-image-pro",
    "prompt": "一只小猫在花园里玩耍,春天,阳光明媚,水彩风格",
    "size": "1024x1024",
    "n": 4,
    "parameters": {
      "enable_sequential": true
    }
  }'
python
from openai import OpenAI

client = OpenAI(
    base_url="https://open.dieyuyun.com/v1",
    api_key="YOUR_API_KEY"
)

response = client.images.generate(
    model="wan2.7-image-pro",
    prompt="一只小猫在花园里玩耍,春天,阳光明媚,水彩风格",
    size="1024x1024",
    n=4,
    parameters={
        "enable_sequential": True
    }
)

for img in response.data:
    print(img.url)
javascript
import OpenAI from 'openai'

const client = new OpenAI({
  baseURL: 'https://open.dieyuyun.com/v1',
  apiKey: 'YOUR_API_KEY',
})

const response = await client.images.generate({
  model: 'wan2.7-image-pro',
  prompt: '一只小猫在花园里玩耍,春天,阳光明媚,水彩风格',
  size: '1024x1024',
  n: 4,
  parameters: {
    enable_sequential: true,
  },
})

for (const img of response.data) {
  console.log(img.url)
}

异步模式

在请求中添加 "async": true 即可启用异步模式。异步请求不会直接返回生成结果,而是返回一个 taskId,用于后续查询任务进度和获取结果。

json
{
  "id": "task_abc123",
  "status": "queued",
  "progress": 0
}
字段类型说明
idstring任务 ID,用于查询任务状态
statusstring当前状态: queued / processing
progressinteger进度百分比 (0-100)

任务完成后,通过 GET /v1/tasks/{taskId} 获取结果,返回格式与同步响应一致。

详见 异步任务 了解完整的轮询流程和最佳实践。

响应格式

成功响应

json
{
  "created": 1717000000,
  "data": [
    {
      "url": "https://...",
      "revised_prompt": "一间充满法式风情的花店,拥有精致的彩色玻璃窗户,窗台上摆满了各色鲜花"
    }
  ],
  "usage": {
    "generated_images": 1,
    "total_tokens": 0
  }
}
字段类型说明
createdintegerUnix 时间戳
dataarray生成结果数组
data[].urlstring图像 URL
data[].revised_promptstring模型优化后的提示词
usageobject用量统计
usage.generated_imagesinteger生成的图像数量
usage.total_tokensinteger总消耗 Token 数

错误响应

详见 错误码

最佳实践

  • 思考模式: 默认启用 thinking_mode,模型会先理解和分析提示词,再决定生成策略,显著提升画面准确性和细节表现。
  • 4K 输出: 使用 wan2.7-image-pro 模型配合 4K 尺寸(如 4096x4096),适合印刷品、广告素材等对画质要求极高的场景。
  • 组图创作: 启用 enable_sequential 后,n 参数范围扩展至 1-12,可一次生成风格统一的系列图像,非常适合连环插画和故事板。
  • 颜色主题: 通过 color_palette 参数指定色调风格,如"暖色调"、"莫兰迪色系"等,快速统一视觉风格。
  • 提示词技巧: 描述越具体,生成效果越好。建议包含场景、光线、风格、构图等细节信息。
  • 复现结果: 记录 seed 值可复现相似的生成结果,便于迭代优化。
  • 水印控制: 默认不添加水印(watermark: false),商业使用时无需额外处理。

速率限制

详见 速率限制

相关文档