跳转到主要内容
万相V2

Wan v2 — 同步调用

Wan 文生图同步接口

POST
/services/aigc/multimodal-generation/generation
cURL - wan2.6-t2i (sync)
curl --location 'https://dashscope.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation' \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer $DASHSCOPE_API_KEY" \
--data '{
  "model": "wan2.6-t2i",
  "input": {
    "messages": [
      {
        "role": "user",
        "content": [
          {
            "text": "A flower shop with exquisite windows, a beautiful wooden door, and flowers on display"
          }
        ]
      }
    ]
  },
  "parameters": {
    "prompt_extend": true,
    "watermark": false,
    "n": 1,
    "negative_prompt": "",
    "size": "1280*1280"
  }
}'
{
  "output": {
    "choices": [
      {
        "finish_reason": "stop",
        "message": {
          "content": [
            {
              "image": "https://dashscope-463f.oss-accelerate.aliyuncs.com/xxxx.png?Expires=xxx",
              "type": "image"
            }
          ],
          "role": "assistant"
        }
      }
    ],
    "finished": true
  },
  "usage": {
    "image_count": 1,
    "input_tokens": 0,
    "output_tokens": 0,
    "size": "1280*1280",
    "total_tokens": 0
  },
  "request_id": "815505c6-7c3d-49d7-b197-xxxxxx"
}
获取 API Key将其设置为环境变量。如需使用 SDK,请先安装 SDK
该同步接口仅适用于 wan2.6-t2i 模型,可在单次请求中直接返回生成的图像,无需轮询。 wan2.5 及更早版本,或需要异步处理时,请使用异步提交接口。

SDK 版本要求

  • DashScope Python SDK:需 1.25.7 或更高版本。
  • DashScope Java SDK:需 2.22.6 或更高版本。

鉴权

string
header
必填

千问云 API Key。详见获取 API Key

请求体

application/json
enum<string>
必填

模型名称。wan2.6-t2i 模型请填写 wan2.6-t2i

wan2.6-t2i
wan2.6-t2i
object
必填

包含消息数组的输入对象。

object

wan2.6-t2i 模型的参数。

响应

200-application/json
object
object

用量统计信息。

string
默认值"815505c6-7c3d-49d7-b197-xxxxxx"

唯一请求标识符,用于追踪和问题排查。