Qwen 圖片生成

OpenAI 相容:POST /v1/images/generations。原生路徑:/api/v1/services/aigc/multimodal-generation/generation。圖片生成 API

模型 ID 以平台「開放模型清單」為準。OpenAI 相容路徑請用 prompt + image / image_urls;不支援 messages、style、quality。


1. OpenAI 相容串接 (POST)

  • 路徑: https://www.tokenpad.ai/v1/images/generations
  • 驗證: Authorization: Bearer sk-your_token

A. 文字生圖

curl -X POST https://www.tokenpad.ai/v1/images/generations \
  -H "Authorization: Bearer sk-your_token_here" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "qwen-image-3.0-pro",
    "prompt": "賽博龐克城市夜景,霓虹倒影,超清寫實,電影級構圖",
    "size": "1024*1024",
    "n": 1,
    "response_format": "url"
  }'

B. 單圖參考 / 圖生圖

curl -X POST https://www.tokenpad.ai/v1/images/generations \
  -H "Authorization: Bearer sk-your_token_here" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "qwen-image-3.0-pro",
    "prompt": "參考圖中人物,站在圖書館窗邊遠眺,電影感自然光",
    "image": "https://example.com/assets/character_face.jpg",
    "size": "1024*1024",
    "n": 1
  }'

C. 多圖參考生圖

curl -X POST https://www.tokenpad.ai/v1/images/generations \
  -H "Authorization: Bearer sk-your_token_here" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "qwen-image-3.0-pro",
    "prompt": "參考圖一角色外形與圖二場景氛圍,統一插畫風格,暖色自然光",
    "image_urls": [
      "https://example.com/character.png",
      "https://example.com/scene.png"
    ],
    "size": "1280*720",
    "n": 2
  }'

D. 負向提示詞

curl -X POST https://www.tokenpad.ai/v1/images/generations \
  -H "Authorization: Bearer sk-your_token_here" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "qwen-image-3.0-pro",
    "prompt": "賽博龐克城市夜景,霓虹倒影,超清寫實",
    "negative_prompt": "模糊,低畫質,變形,浮水印",
    "size": "1024*1024",
    "n": 1
  }'

2. OpenAI 相容參數字典

參數型別必填說明
modelstring是如 qwen-image-3.0-pro
promptstring是畫面描述
negative_promptstring否負向提示詞
imagestring / array否參考圖 URL;單張字串或 URL 陣列
image_urlsarray否多圖參考 URL 陣列(與 image 陣列等價,任選其一)
sizestring否如 1024*1024、1280*720;1024x1024 自動轉為 *
ninteger否生成張數,預設 1
response_formatstring否"url" 或 "b64_json"

3. 阿里百煉原生路由(簡要)

能力路徑
影像提交POST /api/v1/services/aigc/multimodal-generation/generation
非同步查詢GET /api/v1/tasks/{task_id}

已含官方 input / parameters 結構時可原樣透傳;非同步任務須標頭 X-DashScope-Async: enable。


4. 回傳範例 (200 OK)

{
  "created": 1719441600,
  "data": [
    { "url": "https://example.com/output/qwen_img_1.png" },
    { "url": "https://example.com/output/qwen_img_2.png" }
  ]
}

5. 常見錯誤碼與問題排解

HTTP 狀態碼、錯誤主體格式及分情境排解已 統一維護 於專頁,避免與各呼叫範例重複導致不同步。

👉 閘道常見錯誤碼與排解

速記(詳情見專頁):

碼含義
400參數無效 / 內容風控或版權攔截
402帳戶餘額不足(不是 429)
429權杖 RPS/RPM 頻率限制,或低餘額在途任務過多
403權杖/IP/模型權限(餘額見 402;內容攔截見 400)
200 + status: failed非同步影片等長任務的業務失敗(輪詢時常見)

HTTP 回應碼與控制台呼叫日誌 status_code 一致,可依 log_id 追溯。

維護約定:新增或調整錯誤說明時,請只更新專頁 error-codes;本附錄透過連結自動指向最新內容。

Raw Markdown (.md) · llms.txt