模型

wan2.7-image-pro

Markdown · JSON

wan2.7-image-pro

依據文字任務描述建立圖片的模型。模型開發商提供調色盤控制,並讓一般文字轉圖片生成使用最高 4K 解析度。

關於模型

此說明介紹模型的能力。Ailoot 可用的輸入、輸出與選項,依所選方法列於下方。

Wan2.7-Image-Pro 是 Alibaba 的文字轉圖片模型。目前 Ailoot 卡片公布文字輸入及圖片結果。模型開發商也提供編輯、參考圖組合與局部變更;這些方式須另行支援圖片輸入,目前卡片的方法未提供。

模型開發商的參考圖模式可傳入最多九張原始圖片,並描述要使用每張圖片的哪些元素。編輯時,模型會保留主要物件,修改選定細節,或將多份素材組成新構圖。為了更精確地引導變更,可在同一張輸入圖片上指定最多兩個矩形區域。

調色盤與複雜任務描述

連續系列以外的模式可指定 3–10 色調色盤。推理模式用於不使用參考圖或連續系列的一般文字轉圖片生成:模型會先分析場景描述。

Alibaba 規格中的一般輸出包含一至四張圖片。故事系列可將數量上限設為最多 12 張;實際數量由模型依任務選擇。系列可利用文字與參考圖,維持角色共同特徵及連貫的故事發展。此模式不使用調色盤或推理。

解析度依模式而定

不使用參考圖或連續系列的一般文字轉圖片生成支援 4K 等級。圖片編輯與連續系列則限於 2K 等級。這些標示設定的是像素面積,不是每一邊相同的長度。畫面長寬比可選 1:8 至 8:1;以預設解析度進行編輯時,長寬比依循最後一張參考圖。結果儲存為 PNG。

使用輸入圖片的方式接受 JPEG、JPG、不含透明度的 PNG、BMP 及 WEBP。限制為每個檔案最多 20 MB、每一邊 240 至 8000 像素,長寬比為 1:8 至 8:1。文字任務描述支援中文與英語,上限為 5000 個字元,超出的部分會被捨棄。此版本未提供負面描述或任務描述擴充。起始隨機種子有助於維持生成版本的相似程度,但不保證精確重現。

Ailoot · 圖片 POST /v1/images/generations wan2.7-image-pro

wan2.7-image-pro

Alibaba /wan2.7-image-pro
模型 ID
  • wan2.7-image-pro
  • wan-image
  • wan-image-latest

入門

依據文字任務描述建立圖片的模型。模型開發商提供調色盤控制,並讓一般文字轉圖片生成使用最高 4K 解析度。

接受的輸入
文字
結果
圖片

Ailoot 可用 · 輸入與方法

Ailoot · 圖片 POST /v1/images/generations
輸入
text
輸出
image
輸出格式
圖片檔案
欄位類型要求值與限制預設值
欄位model類型string要求必填值與限制
wan2.7-image-pro
預設值—
欄位prompt類型string要求必填值與限制
長度下限: 1
預設值—
欄位n類型integer要求選填值與限制
最小值: 1
預設值1
欄位response_format類型string要求選填值與限制
url, b64_json
預設值—
欄位stream類型boolean要求選填值與限制預設值false
欄位size類型string要求選填值與限制
依模型而定
預設值—
欄位partial_images類型integer要求選填值與限制
依模型而定
預設值—
欄位images[].image_url類型string要求不支援值與限制
解碼後位元組數上限: 20,971,520
MIME 類型: image/png, image/jpeg
每個陣列的圖片數上限: 9
條件: 每個 images[] 物件提供一個實際 URL。陣列項目數與此字串葉節點是不同概念。
適用條件: 僅限 JSON images/edits;JSON images/generations 不會解析 images 參考資料。
預設值—
欄位image類型file要求選填值與限制
解碼後位元組數上限: 20,971,520
MIME 類型: image/png, image/jpeg
適用條件: 以 multipart/form-data 生成
預設值—
欄位image[]類型file[]要求選填值與限制
項目數上限: 9
解碼後位元組數上限: 20,971,520
MIME 類型: image/png, image/jpeg
適用條件: 以 multipart/form-data 生成
預設值—
輸入素材組合

文字生成圖片 · 必填: prompt

reference_images_generation · 必填: prompt

方法參數與生命週期
參數規格
參數material_types規格text
參數required規格model, prompt
參數optional_controls規格null
參數content_type規格application/json

生命週期: synchronous_result_then_owned_library

GET /v1/media/tasks/{task_id} · 實際回傳的 task_id 或媒體庫紀錄

GET /v1/media/assets/{asset_id}/content

GET /v1/media/assets

GET /v1/media/assets/{asset_id}

方法結構與 ID 均為精確值;供應商能力與准入狀態分開。

方案

Ailoot 方法費率

Ailoot 圖片POST /v1/images/generations
輸出
US$0.075 每張 1K 圖片
輸出
US$0.075 每張 2K 圖片

Ailoot 會在請求前預留估算金額。取得結果後,依實測用量結算最終費用。串流結算採用最終用量紀錄。預留金額與結算的運作方式 →

參考費率詳情

模型層級的參考費率表不會變更方法選擇、報價或費用。實際計費採用所選 Ailoot 方法的費率。

wan2.7-image-pro

各設定的價格

設定計費條件費用
設定wan2.7-image-pro · 預設設定計費條件預設設定費用
輸入 · 輸入 US$0.00 每次呼叫
輸出 · 輸出 US$0.16 每次呼叫

請求範例

Ailoot · 圖片

curlPython SDKNode.js SDK
set -eu
: "${AILOOT_API_KEY:?Set your Ailoot API key}"
export AILOOT_API_KEY
export AILOOT_API_KEY
: "${AILOOT_PROMPT_FILE:?Set your actual UTF-8 image brief}"
export AILOOT_PROMPT_FILE
python3 - <<'PY_REQUEST'
import json,os
from pathlib import Path
p=json.loads('{"model": "wan2.7-image-pro", "prompt": ""}')
f=Path(os.environ["AILOOT_PROMPT_FILE"])
if not f.is_file():raise SystemExit("Choose your actual UTF-8 brief")
p['prompt']=f.read_text(encoding="utf-8")
if not p['prompt'].strip():raise SystemExit("Brief must contain text")
Path("request.json").write_text(json.dumps(p,ensure_ascii=False))
PY_REQUEST
curl --fail-with-body --silent --show-error https://api.ailoot.ai/v1/images/generations \
  -H "Authorization: Bearer $AILOOT_API_KEY" -H 'Content-Type: application/json' \
  --data-binary @request.json -D response-headers.txt -o result.json
python3 - <<'PY_RESULT'
import base64, json, os, subprocess
from pathlib import Path
from urllib.parse import urlsplit, urljoin

def save_images(items):
    if not items: raise SystemExit("No completed images; retain the full response")
    for index, item in enumerate(items):
        encoded=item.get("b64_json")
        uri=item.get("url", "")
        if not encoded and uri.startswith("data:image/"):
            header, separator, encoded=uri.partition(",")
            if not separator or ";base64" not in header: raise SystemExit("Unsupported image data URI")
        if encoded:
            raw=base64.b64decode(encoded,validate=True)
        elif uri:
            uri=urljoin("https://api.ailoot.ai",uri)
            parsed=urlsplit(uri)
            if parsed.scheme!="https" or not parsed.netloc or parsed.username or parsed.password:
                raise SystemExit("Invalid returned image URL")
            owned=parsed.netloc=="api.ailoot.ai" and parsed.path.startswith("/v1/media/assets/") and parsed.path.endswith("/content")
            args=["curl","--fail-with-body","--silent","--show-error",uri]
            if owned: args += ["-H","Authorization: Bearer "+os.environ["AILOOT_API_KEY"]]
            temporary=Path(f"image-{index}.bin")
            subprocess.run(args+["-o",str(temporary)],check=True)
            raw=temporary.read_bytes()
            temporary.unlink()
        else: raise SystemExit("Image has neither bytes nor URL")
        if not raw: raise SystemExit("Empty image result")
        ext="png" if raw.startswith(b"\x89PNG") else "jpg" if raw.startswith(b"\xff\xd8") else "webp" if raw[:4]==b"RIFF" and raw[8:12]==b"WEBP" else "svg" if raw.lstrip().startswith((b"<svg",b"<?xml")) else "bin"
        Path(f"image-{index}.{ext}").write_bytes(raw)
    print("Every returned image saved; complete response metadata retained")
save_images(json.loads(Path("result.json").read_text())["data"])
PY_RESULT
from openai import OpenAI
import base64, json, os, subprocess
from pathlib import Path
from urllib.parse import urlsplit, urljoin

def save_images(items):
    if not items: raise SystemExit("No completed images; retain the full response")
    for index, item in enumerate(items):
        encoded=item.get("b64_json")
        uri=item.get("url", "")
        if not encoded and uri.startswith("data:image/"):
            header, separator, encoded=uri.partition(",")
            if not separator or ";base64" not in header: raise SystemExit("Unsupported image data URI")
        if encoded:
            raw=base64.b64decode(encoded,validate=True)
        elif uri:
            uri=urljoin("https://api.ailoot.ai",uri)
            parsed=urlsplit(uri)
            if parsed.scheme!="https" or not parsed.netloc or parsed.username or parsed.password:
                raise SystemExit("Invalid returned image URL")
            owned=parsed.netloc=="api.ailoot.ai" and parsed.path.startswith("/v1/media/assets/") and parsed.path.endswith("/content")
            args=["curl","--fail-with-body","--silent","--show-error",uri]
            if owned: args += ["-H","Authorization: Bearer "+os.environ["AILOOT_API_KEY"]]
            temporary=Path(f"image-{index}.bin")
            subprocess.run(args+["-o",str(temporary)],check=True)
            raw=temporary.read_bytes()
            temporary.unlink()
        else: raise SystemExit("Image has neither bytes nor URL")
        if not raw: raise SystemExit("Empty image result")
        ext="png" if raw.startswith(b"\x89PNG") else "jpg" if raw.startswith(b"\xff\xd8") else "webp" if raw[:4]==b"RIFF" and raw[8:12]==b"WEBP" else "svg" if raw.lstrip().startswith((b"<svg",b"<?xml")) else "bin"
        Path(f"image-{index}.{ext}").write_bytes(raw)
    print("Every returned image saved; complete response metadata retained")

f=Path(os.environ["AILOOT_PROMPT_FILE"])
if not f.is_file():raise SystemExit("Set your actual UTF-8 image brief file")
request={'model': 'wan2.7-image-pro', 'prompt': ''}
request["prompt"]=f.read_text(encoding="utf-8")
client=OpenAI(base_url="https://api.ailoot.ai/v1",api_key=os.environ["AILOOT_API_KEY"],max_retries=0)
result=client.images.generate(**request)
Path("sdk-result.txt").write_text(str(result),encoding="utf-8")
save_images([{"b64_json":getattr(item,"b64_json",None),"url":getattr(item,"url",None)} for item in result.data])
import OpenAI from "openai";
import { readFileSync, writeFileSync } from "node:fs";
const key=process.env.AILOOT_API_KEY;
if(!key) throw new Error("Set your actual Ailoot API key");
const client=new OpenAI({baseURL:"https://api.ailoot.ai/v1",apiKey:key,maxRetries:0});
const request={"model": "wan2.7-image-pro", "prompt": ""};
if(!process.env.AILOOT_PROMPT_FILE)throw new Error("Set your actual UTF-8 image brief file");
request.prompt=readFileSync(process.env.AILOOT_PROMPT_FILE,"utf8");
const result=await client.images.generate(request);
writeFileSync("sdk-result.json",JSON.stringify(result,null,2));
if(!result.data?.length) throw new Error("No completed images");
for(let index=0;index<result.data.length;index++) {
  const item=result.data[index];let encoded=item.b64_json,uri=item.url||"",raw;
  if(!encoded && uri.startsWith("data:image/")) {
    const comma=uri.indexOf(",");if(comma<0 || !uri.slice(0,comma).includes(";base64")) throw new Error("Unsupported image data URI");
    encoded=uri.slice(comma+1);
  }
  if(encoded) {
    if(encoded.length%4!==0 || !/^[A-Za-z0-9+/]*={0,2}$/.test(encoded)) throw new Error("Invalid Base64");
    raw=Buffer.from(encoded,"base64");
  } else if(uri) {
    const u=new URL(uri,"https://api.ailoot.ai");
    if(u.protocol!=="https:" || u.username || u.password) throw new Error("Invalid returned URL");
    const owned=u.origin==="https://api.ailoot.ai" && u.pathname.startsWith("/v1/media/assets/") && u.pathname.endsWith("/content");
    const response=await fetch(u,{headers:owned?{Authorization:"Bearer "+key}:{},redirect:"manual"});
    if(!response.ok) throw new Error("Image content download failed: "+response.status);
    raw=Buffer.from(await response.arrayBuffer());
  } else throw new Error("Image has neither bytes nor URL");
  if(!raw.length) throw new Error("Empty image result");
  const ext=raw.subarray(0,4).equals(Buffer.from([137,80,78,71]))?"png":raw[0]===255&&raw[1]===216?"jpg":raw.toString("ascii",0,4)==="RIFF"&&raw.toString("ascii",8,12)==="WEBP"?"webp":raw.toString("utf8").trimStart().startsWith("<svg")||raw.toString("utf8").trimStart().startsWith("<?xml")?"svg":"bin";
  writeFileSync(`image-${index}.${ext}`,raw);
}
console.log("Every returned image saved; sdk-result.json retains complete metadata");

接收並儲存結果

Ailoot · 圖片

下載每張傳回的圖片,或儲存其 Base64 內容

  • GET /v1/media/tasks/{task_id}
  • GET /v1/media/assets/{asset_id}/content
  • GET /v1/media/assets
  • GET /v1/media/assets/{asset_id}
保留所有已完成的結果

請儲存每張已完成的圖片;從每個傳回的 URL 取得圖片,或解碼其 Base64 內容。

儲存所有資料項目。解碼每個 b64_json,或透過每個回傳的已簽署 URL 取得內容。依實際 MIME 類型/位元組內容選擇副檔名。

需要檢查原始回應時

若圖片生成或編輯結果需要檢查,請保留原始 operation_id/X-Client-Request-ID 與回傳的結果資訊。使用實際的 task_id 或 asset_id 值,透過媒體庫取回自己擁有的既有結果。請勿重新提交生成/編輯請求,也請勿以 operation_id 組成輪詢 URL。

回應欄位
欄位類型
欄位created類型integer
欄位data[].url類型string
欄位data[].b64_json類型base64 string
欄位usage類型object
錯誤與後續步驟
回應條件下一步
回應400 · invalid_request_error條件必要欄位、素材表示方式或參數值無效下一步提出新的建立請求前,先修正指定欄位。
回應server_error條件回傳的回應表示該作業或結果需要檢查下一步保留原始回傳的作業/任務 ID、請求標頭與回應;繼續以支援的方式讀取該原始作業。請勿重新提交建立請求。

別名

模型別名

Ailoot wan2.7-image-pro, wan-image, wan-image-latest

方法路徑別名

請使用上方列出的 API 方法路徑。

相關呼叫用 ID

wan2.7-image-pro, wan-image, wan-image-latest

Ailoot · 圖片 POST /v1/images/generations wan-image

wan-image

Alibaba /wan-image
模型 ID
  • wan2.7-image-pro
  • wan-image
  • wan-image-latest

入門

依據文字任務描述建立圖片的模型。模型開發商提供調色盤控制,並讓一般文字轉圖片生成使用最高 4K 解析度。

接受的輸入
文字
結果
圖片

Ailoot 可用 · 輸入與方法

Ailoot · 圖片 POST /v1/images/generations
輸入
text
輸出
image
輸出格式
圖片檔案
欄位類型要求值與限制預設值
欄位model類型string要求必填值與限制
wan-image
預設值—
欄位prompt類型string要求必填值與限制
長度下限: 1
預設值—
欄位n類型integer要求選填值與限制
最小值: 1
預設值1
欄位response_format類型string要求選填值與限制
url, b64_json
預設值—
欄位stream類型boolean要求選填值與限制預設值false
欄位size類型string要求選填值與限制
依模型而定
預設值—
欄位partial_images類型integer要求選填值與限制
依模型而定
預設值—
欄位images[].image_url類型string要求不支援值與限制
解碼後位元組數上限: 20,971,520
MIME 類型: image/png, image/jpeg
每個陣列的圖片數上限: 9
條件: 每個 images[] 物件提供一個實際 URL。陣列項目數與此字串葉節點是不同概念。
適用條件: 僅限 JSON images/edits;JSON images/generations 不會解析 images 參考資料。
預設值—
欄位image類型file要求選填值與限制
解碼後位元組數上限: 20,971,520
MIME 類型: image/png, image/jpeg
適用條件: 以 multipart/form-data 生成
預設值—
欄位image[]類型file[]要求選填值與限制
項目數上限: 9
解碼後位元組數上限: 20,971,520
MIME 類型: image/png, image/jpeg
適用條件: 以 multipart/form-data 生成
預設值—
輸入素材組合

文字生成圖片 · 必填: prompt

reference_images_generation · 必填: prompt

方法參數與生命週期
參數規格
參數material_types規格text
參數required規格model, prompt
參數optional_controls規格null
參數content_type規格application/json

生命週期: synchronous_result_then_owned_library

GET /v1/media/tasks/{task_id} · 實際回傳的 task_id 或媒體庫紀錄

GET /v1/media/assets/{asset_id}/content

GET /v1/media/assets

GET /v1/media/assets/{asset_id}

方法結構與 ID 均為精確值;供應商能力與准入狀態分開。

方案

Ailoot 方法費率

Ailoot 圖片POST /v1/images/generations
輸出
US$0.075 每張 1K 圖片
輸出
US$0.075 每張 2K 圖片

Ailoot 會在請求前預留估算金額。取得結果後,依實測用量結算最終費用。串流結算採用最終用量紀錄。預留金額與結算的運作方式 →

參考費率詳情

模型層級的參考費率表不會變更方法選擇、報價或費用。實際計費採用所選 Ailoot 方法的費率。

wan2.7-image-pro

各設定的價格

設定計費條件費用
設定wan2.7-image-pro · 預設設定計費條件預設設定費用
輸入 · 輸入 US$0.00 每次呼叫
輸出 · 輸出 US$0.16 每次呼叫

請求範例

Ailoot · 圖片

curlPython SDKNode.js SDK
set -eu
: "${AILOOT_API_KEY:?Set your Ailoot API key}"
export AILOOT_API_KEY
export AILOOT_API_KEY
: "${AILOOT_PROMPT_FILE:?Set your actual UTF-8 image brief}"
export AILOOT_PROMPT_FILE
python3 - <<'PY_REQUEST'
import json,os
from pathlib import Path
p=json.loads('{"model": "wan-image", "prompt": ""}')
f=Path(os.environ["AILOOT_PROMPT_FILE"])
if not f.is_file():raise SystemExit("Choose your actual UTF-8 brief")
p['prompt']=f.read_text(encoding="utf-8")
if not p['prompt'].strip():raise SystemExit("Brief must contain text")
Path("request.json").write_text(json.dumps(p,ensure_ascii=False))
PY_REQUEST
curl --fail-with-body --silent --show-error https://api.ailoot.ai/v1/images/generations \
  -H "Authorization: Bearer $AILOOT_API_KEY" -H 'Content-Type: application/json' \
  --data-binary @request.json -D response-headers.txt -o result.json
python3 - <<'PY_RESULT'
import base64, json, os, subprocess
from pathlib import Path
from urllib.parse import urlsplit, urljoin

def save_images(items):
    if not items: raise SystemExit("No completed images; retain the full response")
    for index, item in enumerate(items):
        encoded=item.get("b64_json")
        uri=item.get("url", "")
        if not encoded and uri.startswith("data:image/"):
            header, separator, encoded=uri.partition(",")
            if not separator or ";base64" not in header: raise SystemExit("Unsupported image data URI")
        if encoded:
            raw=base64.b64decode(encoded,validate=True)
        elif uri:
            uri=urljoin("https://api.ailoot.ai",uri)
            parsed=urlsplit(uri)
            if parsed.scheme!="https" or not parsed.netloc or parsed.username or parsed.password:
                raise SystemExit("Invalid returned image URL")
            owned=parsed.netloc=="api.ailoot.ai" and parsed.path.startswith("/v1/media/assets/") and parsed.path.endswith("/content")
            args=["curl","--fail-with-body","--silent","--show-error",uri]
            if owned: args += ["-H","Authorization: Bearer "+os.environ["AILOOT_API_KEY"]]
            temporary=Path(f"image-{index}.bin")
            subprocess.run(args+["-o",str(temporary)],check=True)
            raw=temporary.read_bytes()
            temporary.unlink()
        else: raise SystemExit("Image has neither bytes nor URL")
        if not raw: raise SystemExit("Empty image result")
        ext="png" if raw.startswith(b"\x89PNG") else "jpg" if raw.startswith(b"\xff\xd8") else "webp" if raw[:4]==b"RIFF" and raw[8:12]==b"WEBP" else "svg" if raw.lstrip().startswith((b"<svg",b"<?xml")) else "bin"
        Path(f"image-{index}.{ext}").write_bytes(raw)
    print("Every returned image saved; complete response metadata retained")
save_images(json.loads(Path("result.json").read_text())["data"])
PY_RESULT
from openai import OpenAI
import base64, json, os, subprocess
from pathlib import Path
from urllib.parse import urlsplit, urljoin

def save_images(items):
    if not items: raise SystemExit("No completed images; retain the full response")
    for index, item in enumerate(items):
        encoded=item.get("b64_json")
        uri=item.get("url", "")
        if not encoded and uri.startswith("data:image/"):
            header, separator, encoded=uri.partition(",")
            if not separator or ";base64" not in header: raise SystemExit("Unsupported image data URI")
        if encoded:
            raw=base64.b64decode(encoded,validate=True)
        elif uri:
            uri=urljoin("https://api.ailoot.ai",uri)
            parsed=urlsplit(uri)
            if parsed.scheme!="https" or not parsed.netloc or parsed.username or parsed.password:
                raise SystemExit("Invalid returned image URL")
            owned=parsed.netloc=="api.ailoot.ai" and parsed.path.startswith("/v1/media/assets/") and parsed.path.endswith("/content")
            args=["curl","--fail-with-body","--silent","--show-error",uri]
            if owned: args += ["-H","Authorization: Bearer "+os.environ["AILOOT_API_KEY"]]
            temporary=Path(f"image-{index}.bin")
            subprocess.run(args+["-o",str(temporary)],check=True)
            raw=temporary.read_bytes()
            temporary.unlink()
        else: raise SystemExit("Image has neither bytes nor URL")
        if not raw: raise SystemExit("Empty image result")
        ext="png" if raw.startswith(b"\x89PNG") else "jpg" if raw.startswith(b"\xff\xd8") else "webp" if raw[:4]==b"RIFF" and raw[8:12]==b"WEBP" else "svg" if raw.lstrip().startswith((b"<svg",b"<?xml")) else "bin"
        Path(f"image-{index}.{ext}").write_bytes(raw)
    print("Every returned image saved; complete response metadata retained")

f=Path(os.environ["AILOOT_PROMPT_FILE"])
if not f.is_file():raise SystemExit("Set your actual UTF-8 image brief file")
request={'model': 'wan-image', 'prompt': ''}
request["prompt"]=f.read_text(encoding="utf-8")
client=OpenAI(base_url="https://api.ailoot.ai/v1",api_key=os.environ["AILOOT_API_KEY"],max_retries=0)
result=client.images.generate(**request)
Path("sdk-result.txt").write_text(str(result),encoding="utf-8")
save_images([{"b64_json":getattr(item,"b64_json",None),"url":getattr(item,"url",None)} for item in result.data])
import OpenAI from "openai";
import { readFileSync, writeFileSync } from "node:fs";
const key=process.env.AILOOT_API_KEY;
if(!key) throw new Error("Set your actual Ailoot API key");
const client=new OpenAI({baseURL:"https://api.ailoot.ai/v1",apiKey:key,maxRetries:0});
const request={"model": "wan-image", "prompt": ""};
if(!process.env.AILOOT_PROMPT_FILE)throw new Error("Set your actual UTF-8 image brief file");
request.prompt=readFileSync(process.env.AILOOT_PROMPT_FILE,"utf8");
const result=await client.images.generate(request);
writeFileSync("sdk-result.json",JSON.stringify(result,null,2));
if(!result.data?.length) throw new Error("No completed images");
for(let index=0;index<result.data.length;index++) {
  const item=result.data[index];let encoded=item.b64_json,uri=item.url||"",raw;
  if(!encoded && uri.startsWith("data:image/")) {
    const comma=uri.indexOf(",");if(comma<0 || !uri.slice(0,comma).includes(";base64")) throw new Error("Unsupported image data URI");
    encoded=uri.slice(comma+1);
  }
  if(encoded) {
    if(encoded.length%4!==0 || !/^[A-Za-z0-9+/]*={0,2}$/.test(encoded)) throw new Error("Invalid Base64");
    raw=Buffer.from(encoded,"base64");
  } else if(uri) {
    const u=new URL(uri,"https://api.ailoot.ai");
    if(u.protocol!=="https:" || u.username || u.password) throw new Error("Invalid returned URL");
    const owned=u.origin==="https://api.ailoot.ai" && u.pathname.startsWith("/v1/media/assets/") && u.pathname.endsWith("/content");
    const response=await fetch(u,{headers:owned?{Authorization:"Bearer "+key}:{},redirect:"manual"});
    if(!response.ok) throw new Error("Image content download failed: "+response.status);
    raw=Buffer.from(await response.arrayBuffer());
  } else throw new Error("Image has neither bytes nor URL");
  if(!raw.length) throw new Error("Empty image result");
  const ext=raw.subarray(0,4).equals(Buffer.from([137,80,78,71]))?"png":raw[0]===255&&raw[1]===216?"jpg":raw.toString("ascii",0,4)==="RIFF"&&raw.toString("ascii",8,12)==="WEBP"?"webp":raw.toString("utf8").trimStart().startsWith("<svg")||raw.toString("utf8").trimStart().startsWith("<?xml")?"svg":"bin";
  writeFileSync(`image-${index}.${ext}`,raw);
}
console.log("Every returned image saved; sdk-result.json retains complete metadata");

接收並儲存結果

Ailoot · 圖片

下載每張傳回的圖片,或儲存其 Base64 內容

  • GET /v1/media/tasks/{task_id}
  • GET /v1/media/assets/{asset_id}/content
  • GET /v1/media/assets
  • GET /v1/media/assets/{asset_id}
保留所有已完成的結果

請儲存每張已完成的圖片;從每個傳回的 URL 取得圖片,或解碼其 Base64 內容。

儲存所有資料項目。解碼每個 b64_json,或透過每個回傳的已簽署 URL 取得內容。依實際 MIME 類型/位元組內容選擇副檔名。

需要檢查原始回應時

若圖片生成或編輯結果需要檢查,請保留原始 operation_id/X-Client-Request-ID 與回傳的結果資訊。使用實際的 task_id 或 asset_id 值,透過媒體庫取回自己擁有的既有結果。請勿重新提交生成/編輯請求,也請勿以 operation_id 組成輪詢 URL。

回應欄位
欄位類型
欄位created類型integer
欄位data[].url類型string
欄位data[].b64_json類型base64 string
欄位usage類型object
錯誤與後續步驟
回應條件下一步
回應400 · invalid_request_error條件必要欄位、素材表示方式或參數值無效下一步提出新的建立請求前,先修正指定欄位。
回應server_error條件回傳的回應表示該作業或結果需要檢查下一步保留原始回傳的作業/任務 ID、請求標頭與回應;繼續以支援的方式讀取該原始作業。請勿重新提交建立請求。

別名

模型別名

Ailoot wan2.7-image-pro, wan-image, wan-image-latest

方法路徑別名

請使用上方列出的 API 方法路徑。

相關呼叫用 ID

wan2.7-image-pro, wan-image, wan-image-latest

Ailoot · 圖片 POST /v1/images/generations wan-image-latest

wan-image-latest

Alibaba /wan-image-latest
模型 ID
  • wan2.7-image-pro
  • wan-image
  • wan-image-latest

入門

依據文字任務描述建立圖片的模型。模型開發商提供調色盤控制,並讓一般文字轉圖片生成使用最高 4K 解析度。

接受的輸入
文字
結果
圖片

Ailoot 可用 · 輸入與方法

Ailoot · 圖片 POST /v1/images/generations
輸入
text
輸出
image
輸出格式
圖片檔案
欄位類型要求值與限制預設值
欄位model類型string要求必填值與限制
wan-image-latest
預設值—
欄位prompt類型string要求必填值與限制
長度下限: 1
預設值—
欄位n類型integer要求選填值與限制
最小值: 1
預設值1
欄位response_format類型string要求選填值與限制
url, b64_json
預設值—
欄位stream類型boolean要求選填值與限制預設值false
欄位size類型string要求選填值與限制
依模型而定
預設值—
欄位partial_images類型integer要求選填值與限制
依模型而定
預設值—
欄位images[].image_url類型string要求不支援值與限制
解碼後位元組數上限: 20,971,520
MIME 類型: image/png, image/jpeg
每個陣列的圖片數上限: 9
條件: 每個 images[] 物件提供一個實際 URL。陣列項目數與此字串葉節點是不同概念。
適用條件: 僅限 JSON images/edits;JSON images/generations 不會解析 images 參考資料。
預設值—
欄位image類型file要求選填值與限制
解碼後位元組數上限: 20,971,520
MIME 類型: image/png, image/jpeg
適用條件: 以 multipart/form-data 生成
預設值—
欄位image[]類型file[]要求選填值與限制
項目數上限: 9
解碼後位元組數上限: 20,971,520
MIME 類型: image/png, image/jpeg
適用條件: 以 multipart/form-data 生成
預設值—
輸入素材組合

文字生成圖片 · 必填: prompt

reference_images_generation · 必填: prompt

方法參數與生命週期
參數規格
參數material_types規格text
參數required規格model, prompt
參數optional_controls規格null
參數content_type規格application/json

生命週期: synchronous_result_then_owned_library

GET /v1/media/tasks/{task_id} · 實際回傳的 task_id 或媒體庫紀錄

GET /v1/media/assets/{asset_id}/content

GET /v1/media/assets

GET /v1/media/assets/{asset_id}

方法結構與 ID 均為精確值;供應商能力與准入狀態分開。

方案

Ailoot 方法費率

Ailoot 圖片POST /v1/images/generations
輸出
US$0.075 每張 1K 圖片
輸出
US$0.075 每張 2K 圖片

Ailoot 會在請求前預留估算金額。取得結果後,依實測用量結算最終費用。串流結算採用最終用量紀錄。預留金額與結算的運作方式 →

參考費率詳情

模型層級的參考費率表不會變更方法選擇、報價或費用。實際計費採用所選 Ailoot 方法的費率。

wan2.7-image-pro

各設定的價格

設定計費條件費用
設定wan2.7-image-pro · 預設設定計費條件預設設定費用
輸入 · 輸入 US$0.00 每次呼叫
輸出 · 輸出 US$0.16 每次呼叫

請求範例

Ailoot · 圖片

curlPython SDKNode.js SDK
set -eu
: "${AILOOT_API_KEY:?Set your Ailoot API key}"
export AILOOT_API_KEY
export AILOOT_API_KEY
: "${AILOOT_PROMPT_FILE:?Set your actual UTF-8 image brief}"
export AILOOT_PROMPT_FILE
python3 - <<'PY_REQUEST'
import json,os
from pathlib import Path
p=json.loads('{"model": "wan-image-latest", "prompt": ""}')
f=Path(os.environ["AILOOT_PROMPT_FILE"])
if not f.is_file():raise SystemExit("Choose your actual UTF-8 brief")
p['prompt']=f.read_text(encoding="utf-8")
if not p['prompt'].strip():raise SystemExit("Brief must contain text")
Path("request.json").write_text(json.dumps(p,ensure_ascii=False))
PY_REQUEST
curl --fail-with-body --silent --show-error https://api.ailoot.ai/v1/images/generations \
  -H "Authorization: Bearer $AILOOT_API_KEY" -H 'Content-Type: application/json' \
  --data-binary @request.json -D response-headers.txt -o result.json
python3 - <<'PY_RESULT'
import base64, json, os, subprocess
from pathlib import Path
from urllib.parse import urlsplit, urljoin

def save_images(items):
    if not items: raise SystemExit("No completed images; retain the full response")
    for index, item in enumerate(items):
        encoded=item.get("b64_json")
        uri=item.get("url", "")
        if not encoded and uri.startswith("data:image/"):
            header, separator, encoded=uri.partition(",")
            if not separator or ";base64" not in header: raise SystemExit("Unsupported image data URI")
        if encoded:
            raw=base64.b64decode(encoded,validate=True)
        elif uri:
            uri=urljoin("https://api.ailoot.ai",uri)
            parsed=urlsplit(uri)
            if parsed.scheme!="https" or not parsed.netloc or parsed.username or parsed.password:
                raise SystemExit("Invalid returned image URL")
            owned=parsed.netloc=="api.ailoot.ai" and parsed.path.startswith("/v1/media/assets/") and parsed.path.endswith("/content")
            args=["curl","--fail-with-body","--silent","--show-error",uri]
            if owned: args += ["-H","Authorization: Bearer "+os.environ["AILOOT_API_KEY"]]
            temporary=Path(f"image-{index}.bin")
            subprocess.run(args+["-o",str(temporary)],check=True)
            raw=temporary.read_bytes()
            temporary.unlink()
        else: raise SystemExit("Image has neither bytes nor URL")
        if not raw: raise SystemExit("Empty image result")
        ext="png" if raw.startswith(b"\x89PNG") else "jpg" if raw.startswith(b"\xff\xd8") else "webp" if raw[:4]==b"RIFF" and raw[8:12]==b"WEBP" else "svg" if raw.lstrip().startswith((b"<svg",b"<?xml")) else "bin"
        Path(f"image-{index}.{ext}").write_bytes(raw)
    print("Every returned image saved; complete response metadata retained")
save_images(json.loads(Path("result.json").read_text())["data"])
PY_RESULT
from openai import OpenAI
import base64, json, os, subprocess
from pathlib import Path
from urllib.parse import urlsplit, urljoin

def save_images(items):
    if not items: raise SystemExit("No completed images; retain the full response")
    for index, item in enumerate(items):
        encoded=item.get("b64_json")
        uri=item.get("url", "")
        if not encoded and uri.startswith("data:image/"):
            header, separator, encoded=uri.partition(",")
            if not separator or ";base64" not in header: raise SystemExit("Unsupported image data URI")
        if encoded:
            raw=base64.b64decode(encoded,validate=True)
        elif uri:
            uri=urljoin("https://api.ailoot.ai",uri)
            parsed=urlsplit(uri)
            if parsed.scheme!="https" or not parsed.netloc or parsed.username or parsed.password:
                raise SystemExit("Invalid returned image URL")
            owned=parsed.netloc=="api.ailoot.ai" and parsed.path.startswith("/v1/media/assets/") and parsed.path.endswith("/content")
            args=["curl","--fail-with-body","--silent","--show-error",uri]
            if owned: args += ["-H","Authorization: Bearer "+os.environ["AILOOT_API_KEY"]]
            temporary=Path(f"image-{index}.bin")
            subprocess.run(args+["-o",str(temporary)],check=True)
            raw=temporary.read_bytes()
            temporary.unlink()
        else: raise SystemExit("Image has neither bytes nor URL")
        if not raw: raise SystemExit("Empty image result")
        ext="png" if raw.startswith(b"\x89PNG") else "jpg" if raw.startswith(b"\xff\xd8") else "webp" if raw[:4]==b"RIFF" and raw[8:12]==b"WEBP" else "svg" if raw.lstrip().startswith((b"<svg",b"<?xml")) else "bin"
        Path(f"image-{index}.{ext}").write_bytes(raw)
    print("Every returned image saved; complete response metadata retained")

f=Path(os.environ["AILOOT_PROMPT_FILE"])
if not f.is_file():raise SystemExit("Set your actual UTF-8 image brief file")
request={'model': 'wan-image-latest', 'prompt': ''}
request["prompt"]=f.read_text(encoding="utf-8")
client=OpenAI(base_url="https://api.ailoot.ai/v1",api_key=os.environ["AILOOT_API_KEY"],max_retries=0)
result=client.images.generate(**request)
Path("sdk-result.txt").write_text(str(result),encoding="utf-8")
save_images([{"b64_json":getattr(item,"b64_json",None),"url":getattr(item,"url",None)} for item in result.data])
import OpenAI from "openai";
import { readFileSync, writeFileSync } from "node:fs";
const key=process.env.AILOOT_API_KEY;
if(!key) throw new Error("Set your actual Ailoot API key");
const client=new OpenAI({baseURL:"https://api.ailoot.ai/v1",apiKey:key,maxRetries:0});
const request={"model": "wan-image-latest", "prompt": ""};
if(!process.env.AILOOT_PROMPT_FILE)throw new Error("Set your actual UTF-8 image brief file");
request.prompt=readFileSync(process.env.AILOOT_PROMPT_FILE,"utf8");
const result=await client.images.generate(request);
writeFileSync("sdk-result.json",JSON.stringify(result,null,2));
if(!result.data?.length) throw new Error("No completed images");
for(let index=0;index<result.data.length;index++) {
  const item=result.data[index];let encoded=item.b64_json,uri=item.url||"",raw;
  if(!encoded && uri.startsWith("data:image/")) {
    const comma=uri.indexOf(",");if(comma<0 || !uri.slice(0,comma).includes(";base64")) throw new Error("Unsupported image data URI");
    encoded=uri.slice(comma+1);
  }
  if(encoded) {
    if(encoded.length%4!==0 || !/^[A-Za-z0-9+/]*={0,2}$/.test(encoded)) throw new Error("Invalid Base64");
    raw=Buffer.from(encoded,"base64");
  } else if(uri) {
    const u=new URL(uri,"https://api.ailoot.ai");
    if(u.protocol!=="https:" || u.username || u.password) throw new Error("Invalid returned URL");
    const owned=u.origin==="https://api.ailoot.ai" && u.pathname.startsWith("/v1/media/assets/") && u.pathname.endsWith("/content");
    const response=await fetch(u,{headers:owned?{Authorization:"Bearer "+key}:{},redirect:"manual"});
    if(!response.ok) throw new Error("Image content download failed: "+response.status);
    raw=Buffer.from(await response.arrayBuffer());
  } else throw new Error("Image has neither bytes nor URL");
  if(!raw.length) throw new Error("Empty image result");
  const ext=raw.subarray(0,4).equals(Buffer.from([137,80,78,71]))?"png":raw[0]===255&&raw[1]===216?"jpg":raw.toString("ascii",0,4)==="RIFF"&&raw.toString("ascii",8,12)==="WEBP"?"webp":raw.toString("utf8").trimStart().startsWith("<svg")||raw.toString("utf8").trimStart().startsWith("<?xml")?"svg":"bin";
  writeFileSync(`image-${index}.${ext}`,raw);
}
console.log("Every returned image saved; sdk-result.json retains complete metadata");

接收並儲存結果

Ailoot · 圖片

下載每張傳回的圖片,或儲存其 Base64 內容

  • GET /v1/media/tasks/{task_id}
  • GET /v1/media/assets/{asset_id}/content
  • GET /v1/media/assets
  • GET /v1/media/assets/{asset_id}
保留所有已完成的結果

請儲存每張已完成的圖片;從每個傳回的 URL 取得圖片,或解碼其 Base64 內容。

儲存所有資料項目。解碼每個 b64_json,或透過每個回傳的已簽署 URL 取得內容。依實際 MIME 類型/位元組內容選擇副檔名。

需要檢查原始回應時

若圖片生成或編輯結果需要檢查,請保留原始 operation_id/X-Client-Request-ID 與回傳的結果資訊。使用實際的 task_id 或 asset_id 值,透過媒體庫取回自己擁有的既有結果。請勿重新提交生成/編輯請求,也請勿以 operation_id 組成輪詢 URL。

回應欄位
欄位類型
欄位created類型integer
欄位data[].url類型string
欄位data[].b64_json類型base64 string
欄位usage類型object
錯誤與後續步驟
回應條件下一步
回應400 · invalid_request_error條件必要欄位、素材表示方式或參數值無效下一步提出新的建立請求前,先修正指定欄位。
回應server_error條件回傳的回應表示該作業或結果需要檢查下一步保留原始回傳的作業/任務 ID、請求標頭與回應;繼續以支援的方式讀取該原始作業。請勿重新提交建立請求。

別名

模型別名

Ailoot wan2.7-image-pro, wan-image, wan-image-latest

方法路徑別名

請使用上方列出的 API 方法路徑。

相關呼叫用 ID

wan2.7-image-pro, wan-image, wan-image-latest

FAQ · wan2.7-image-pro
可以使用哪些輸入與結果?

POST /v1/images/generations · wan2.7-image-pro: text → image

POST /v1/images/generations · wan-image: text → image

POST /v1/images/generations · wan-image-latest: text → image

請求使用哪些欄位?

POST /v1/images/generations · wan2.7-image-pro: model, prompt, n, response_format, stream, image, image[]

POST /v1/images/generations · wan-image: model, prompt, n, response_format, stream, image, image[]

POST /v1/images/generations · wan-image-latest: model, prompt, n, response_format, stream, image, image[]

適用哪些限制?

POST /v1/images/generations · wan2.7-image-pro: n.minimum: 1

POST /v1/images/generations · wan-image: n.minimum: 1

POST /v1/images/generations · wan-image-latest: n.minimum: 1

更多詳情

將 Ailoot 串接 Claude Code、OpenCode、Hermes 或自己的應用程式。

公司及其專案組合

公司及其專案組合:數百萬客戶,每月銷售額達數十億。

優惠購買 token。

訂閱優惠適合持續工作,折扣碼購買 token 最高可折 50%。

訂閱
為定期請求選擇優惠方案。
最高 50% 折扣碼
購買時輸入代碼,價格依活動重算。
歷史中的費用
每次請求保存模型、token 與金額。

選擇訂閱 · 查看模型價格

將 API 加入 你銷售的產品。

依 Ailoot 正式服務條款與授權合約串接 SaaS、應用程式與機器人;轉售請申請經銷授權。

商用應用程式
在付費功能加入文字、圖片、影片與聲音生成。
經銷授權
提供專案說明與存取方式,要求書面使用和轉售條件。
網站文件
串接前可閱讀正式服務條款、授權合約與資料處理政策。

申請經銷授權 · 正式服務條款與授權合約