Aliyun Qwen-Image (多模態影像生成 / 編輯)

POST /v1/images/generations

## Aliyun Qwen-Image Multimodal (多模態影像生成 / 編輯) 通義千問影像生成多模態介面. 適用模型: | 模型 | 類型 | 說明 | |---|---|---| | `qwen-image-2.0` | 文生圖 | 2.0 基礎款 | | `qwen-image-2.0-pro` | 文生圖 | 2.0 高品質增強版 | | `qwen-image-max` | 文生圖 | 旗艦高品質 | | `qwen-image-edit` | 影像編輯 | 必須傳 1-3 張參考圖 | | `qwen-image-edit-plus` | 影像編輯 | 編輯增強版 | | `qwen-image-edit-max` | 影像編輯 | 編輯旗艦版 | ### Body 結構 - `input.messages[]` 陣列 — 一個 user message 含多個 content blocks - 每個 `content[]` block: - `{"text": "提示詞"}` — 文本提示 - `{"image": "https://..."}` — 參考圖 URL, 必須公網可達 (https) ### 模型協議要求 | 模型 | content 必須包含 | 備註 | |---|---|---| | qwen-image-2.0 / -2.0-pro / -max | 1 個 `{text}` | 純文生圖, 可選 0 個 `{image}` | | qwen-image-edit / -edit-plus / -edit-max | 1 個 `{text}` + **1-3 個 `{image}`** | 必須傳參考圖 | ### 響應解析 - `output.choices[0].message.content[]` — 陣列, 含 1 個 `{"image": "https://..."}` 塊 - `usage.image_count` / `usage.height` / `usage.width` — 生成圖片資訊 ### 基礎文生圖 (無參考圖) 如只需簡單文生圖 (不需多模態), 也可用更輕量的 [Aliyun Qwen-Image 文生圖](/docs/api/aliyun-qwen-image) 介面 (qwen-image / qwen-image-plus).

请求体

modelstringrequiredQwen-Image multimodal 模型. `-2.0` / `-2.0-pro` / `-max` 文生圖; `-edit*` 系列需 1-3 張參考圖編輯
inputobjectrequired輸入物件, 包含 messages 陣列
    messagesarrayrequired對話訊息陣列. 當前 image 場景僅支援單個 user message
        rolestringrequired訊息角色, 當前僅 user
        contentarrayrequired內容塊陣列. 必須含至少 1 個 `{text}`. 編輯類模型必須再含 1-3 個 `{image}` 參考圖
            textstring文本提示詞 (單 content block 內僅 `text` 或 `image` 二選一)
            imagestring參考圖 URL (https), Aliyun 上游內部下載. URL 必須公網可達
parametersobject生成參數
    sizestring影像尺寸, DashScope 風格 (`*` 分隔)
    ninteger生成張數, 當前上游限單次 1 張
    seedinteger隨機種子. 同 prompt + 同 seed 可復現近似結果, 便於風格調優
    watermarkboolean是否新增水印
    negative_promptstring負向提示詞 — 模型應避免的元素
    prompt_extendboolean是否啟用 prompt 智慧擴充套件 (上游自動補充細節)

响应

调用示例

curl -X POST "https://api.router.ai/v1/images/generations" \
  -H "Authorization: Bearer sk-xxxxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "qwen-image-edit",
    "input": {
      "messages": [
        {
          "role": "user",
          "content": [
            {"text": "把这张图改成赛博朋克风格, 加上霓虹灯"},
            {"image": "https://example.com/reference.png"}
          ]
        }
      ]
    },
    "parameters": {
      "size": "1024*1024",
      "n": 1,
      "seed": 42
    }
  }'

API 文件