wan2.7-image-pro
โมเดลสร้างภาพจากคำสั่งข้อความ ผู้ผลิตรองรับการกำหนดพาเลตต์สีและความละเอียดได้ถึง 4K สำหรับการสร้างภาพจากข้อความแบบทั่วไป
- Ailoot · รูปภาพ
POST /v1/images/generationswan2.7-image-pro - Ailoot · รูปภาพ
POST /v1/images/generationswan-image - Ailoot · รูปภาพ
POST /v1/images/generationswan-image-latest
เกี่ยวกับโมเดล
คำอธิบายนี้ครอบคลุมความสามารถของโมเดล อินพุต เอาต์พุต และตัวเลือกที่ใช้ได้ใน Ailoot แสดงด้านล่างตามเมธอดที่เลือก
Wan2.7-Image-Pro เป็นโมเดลของ Alibaba สำหรับสร้างภาพจากข้อความ การ์ด Ailoot ปัจจุบันเผยแพร่อินพุตข้อความและผลลัพธ์เป็นภาพ ผู้ผลิตยังรองรับการแก้ไขภาพ การรวมภาพอ้างอิง และการเปลี่ยนแปลงเฉพาะจุด วิธีเหล่านี้ต้องมีการรองรับภาพอินพุตแยกต่างหาก และไม่ได้รวมอยู่ในวิธีที่การ์ดปัจจุบันนำเสนอ
ในโหมดภาพอ้างอิงของผู้ผลิต สามารถส่งภาพต้นฉบับได้ถึงเก้าภาพ แล้วอธิบายว่าต้องการใช้องค์ประกอบใดจากแต่ละภาพ เมื่อแก้ไขภาพ โมเดลรักษาวัตถุหลักไว้ เปลี่ยนรายละเอียดที่เลือก หรือจัดองค์ประกอบใหม่จากเนื้อหาของหลายภาพ เพื่อชี้นำการเปลี่ยนแปลงอย่างแม่นยำยิ่งขึ้น สามารถกำหนดพื้นที่สี่เหลี่ยมได้ถึงสองบริเวณบนภาพอินพุตหนึ่งภาพ
พาเลตต์และคำสั่งซับซ้อน
เมื่อไม่ได้สร้างชุดภาพต่อเนื่อง สามารถกำหนดพาเลตต์ 3–10 สีได้ โหมดใช้เหตุผลมีไว้สำหรับการสร้างภาพจากข้อความแบบทั่วไปที่ไม่มีภาพอ้างอิงและไม่ใช่ชุดภาพต่อเนื่อง โดยโมเดลจะวิเคราะห์คำอธิบายฉากก่อน
ข้อกำหนดของ Alibaba ระบุผลลัพธ์แบบทั่วไปตั้งแต่หนึ่งถึงสี่ภาพ ในชุดภาพเล่าเรื่องสามารถกำหนดขีดจำกัดสูงสุดได้ถึง 12 ภาพ โดยโมเดลเลือกจำนวนจริงตามคำสั่ง ชุดภาพสามารถใช้ทั้งข้อความและภาพอ้างอิงเพื่อรักษาลักษณะร่วมของตัวละครและการดำเนินเรื่องที่ต่อเนื่องกัน โหมดนี้ไม่ใช้พาเลตต์และการใช้เหตุผล
ความละเอียดขึ้นอยู่กับโหมด
ระดับ 4K รองรับในการสร้างภาพจากข้อความแบบทั่วไปที่ไม่มีภาพอ้างอิงและไม่ใช่ชุดภาพต่อเนื่อง การแก้ไขจากภาพและชุดภาพต่อเนื่องจำกัดที่ระดับ 2K ระดับเหล่านี้กำหนดพื้นที่พิกเซล ไม่ใช่ความยาวเท่ากันของทุกด้าน เลือกอัตราส่วนได้ตั้งแต่ 1:8 ถึง 8:1 เมื่อแก้ไขภาพด้วยความละเอียดที่ตั้งไว้ อัตราส่วนจะเป็นไปตามภาพอ้างอิงสุดท้าย ผลลัพธ์บันทึกเป็น PNG
สำหรับวิธีที่ใช้ภาพอินพุต Alibaba รองรับ JPEG, JPG, PNG ที่ไม่มีความโปร่งใส, BMP และ WEBP ขีดจำกัดคือ 20 MB ต่อไฟล์ แต่ละด้านมีขนาดตั้งแต่ 240 ถึง 8000 พิกเซล และอัตราส่วนตั้งแต่ 1:8 ถึง 8:1 คำสั่งข้อความรองรับภาษาจีนและภาษาอังกฤษ สูงสุด 5000 อักขระ ส่วนที่เกินจะถูกตัดทิ้ง เวอร์ชันนี้ไม่รองรับคำอธิบายเชิงลบและการขยายคำสั่ง ค่า seed เริ่มต้นช่วยรักษาความคล้ายกันของตัวเลือก แต่ไม่ทำให้สร้างซ้ำได้ตรงกันทุกประการ
Ailoot · รูปภาพ POST /v1/images/generations wan2.7-image-pro
wan2.7-image-prowan2.7-image-prowan-imagewan-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 เงื่อนไข: URL จริงหนึ่งรายการต่อออบเจ็กต์ images[] จำนวนสมาชิกในอาร์เรย์เป็นคนละเรื่องกับฟิลด์สตริงปลายทางนี้ ใช้เมื่อ: เฉพาะ JSON images/edits เท่านั้น JSON images/generations ไม่แยกวิเคราะห์ข้อมูลอ้างอิงภาพ | ค่าเริ่มต้น— |
ฟิลด์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
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 · รูปภาพ
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}/contentGET /v1/media/assetsGET /v1/media/assets/{asset_id}
เก็บผลลัพธ์ที่เสร็จสมบูรณ์ทั้งหมด
บันทึกภาพที่สร้างเสร็จทุกภาพ โดยดึงภาพจากทุก URL ที่ส่งกลับมา หรือถอดรหัสเนื้อหา Base64
บันทึกข้อมูลทุกรายการ ถอดรหัส b64_json แต่ละรายการ หรือดึงข้อมูลจาก URL ที่ลงนามแล้วและส่งกลับมาทุกรายการ เลือกนามสกุลไฟล์จาก MIME/ไบต์จริง
เมื่อต้องตรวจสอบการตอบกลับต้นฉบับ
หากผลลัพธ์การสร้างหรือแก้ไขภาพต้องได้รับการตรวจสอบ ให้เก็บ operation_id/X-Client-Request-ID เดิมและข้อมูลผลลัพธ์ที่ส่งกลับมาไว้ กู้คืนผลลัพธ์ที่มีอยู่และเป็นของตนเองผ่านคลังสื่อโดยใช้ค่า task_id หรือ asset_id จริง ห้ามส่งคำขอสร้าง/แก้ไขซ้ำ หรือสร้าง URL สำหรับตรวจสอบสถานะเป็นระยะจาก operation_id
ฟิลด์การตอบกลับ
| ฟิลด์ | ประเภท |
|---|---|
ฟิลด์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
ชื่อพาธเมธอดอื่น
ใช้พาธเมธอดที่แสดงด้านบน
ID ที่เกี่ยวข้องสำหรับเรียกใช้โมเดล
Ailoot · รูปภาพ POST /v1/images/generations wan-image
wan-imagewan2.7-image-prowan-imagewan-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 เงื่อนไข: URL จริงหนึ่งรายการต่อออบเจ็กต์ images[] จำนวนสมาชิกในอาร์เรย์เป็นคนละเรื่องกับฟิลด์สตริงปลายทางนี้ ใช้เมื่อ: เฉพาะ JSON images/edits เท่านั้น JSON images/generations ไม่แยกวิเคราะห์ข้อมูลอ้างอิงภาพ | ค่าเริ่มต้น— |
ฟิลด์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
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 · รูปภาพ
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}/contentGET /v1/media/assetsGET /v1/media/assets/{asset_id}
เก็บผลลัพธ์ที่เสร็จสมบูรณ์ทั้งหมด
บันทึกภาพที่สร้างเสร็จทุกภาพ โดยดึงภาพจากทุก URL ที่ส่งกลับมา หรือถอดรหัสเนื้อหา Base64
บันทึกข้อมูลทุกรายการ ถอดรหัส b64_json แต่ละรายการ หรือดึงข้อมูลจาก URL ที่ลงนามแล้วและส่งกลับมาทุกรายการ เลือกนามสกุลไฟล์จาก MIME/ไบต์จริง
เมื่อต้องตรวจสอบการตอบกลับต้นฉบับ
หากผลลัพธ์การสร้างหรือแก้ไขภาพต้องได้รับการตรวจสอบ ให้เก็บ operation_id/X-Client-Request-ID เดิมและข้อมูลผลลัพธ์ที่ส่งกลับมาไว้ กู้คืนผลลัพธ์ที่มีอยู่และเป็นของตนเองผ่านคลังสื่อโดยใช้ค่า task_id หรือ asset_id จริง ห้ามส่งคำขอสร้าง/แก้ไขซ้ำ หรือสร้าง URL สำหรับตรวจสอบสถานะเป็นระยะจาก operation_id
ฟิลด์การตอบกลับ
| ฟิลด์ | ประเภท |
|---|---|
ฟิลด์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
ชื่อพาธเมธอดอื่น
ใช้พาธเมธอดที่แสดงด้านบน
ID ที่เกี่ยวข้องสำหรับเรียกใช้โมเดล
Ailoot · รูปภาพ POST /v1/images/generations wan-image-latest
wan-image-latestwan2.7-image-prowan-imagewan-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 เงื่อนไข: URL จริงหนึ่งรายการต่อออบเจ็กต์ images[] จำนวนสมาชิกในอาร์เรย์เป็นคนละเรื่องกับฟิลด์สตริงปลายทางนี้ ใช้เมื่อ: เฉพาะ JSON images/edits เท่านั้น JSON images/generations ไม่แยกวิเคราะห์ข้อมูลอ้างอิงภาพ | ค่าเริ่มต้น— |
ฟิลด์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
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 · รูปภาพ
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}/contentGET /v1/media/assetsGET /v1/media/assets/{asset_id}
เก็บผลลัพธ์ที่เสร็จสมบูรณ์ทั้งหมด
บันทึกภาพที่สร้างเสร็จทุกภาพ โดยดึงภาพจากทุก URL ที่ส่งกลับมา หรือถอดรหัสเนื้อหา Base64
บันทึกข้อมูลทุกรายการ ถอดรหัส b64_json แต่ละรายการ หรือดึงข้อมูลจาก URL ที่ลงนามแล้วและส่งกลับมาทุกรายการ เลือกนามสกุลไฟล์จาก MIME/ไบต์จริง
เมื่อต้องตรวจสอบการตอบกลับต้นฉบับ
หากผลลัพธ์การสร้างหรือแก้ไขภาพต้องได้รับการตรวจสอบ ให้เก็บ operation_id/X-Client-Request-ID เดิมและข้อมูลผลลัพธ์ที่ส่งกลับมาไว้ กู้คืนผลลัพธ์ที่มีอยู่และเป็นของตนเองผ่านคลังสื่อโดยใช้ค่า task_id หรือ asset_id จริง ห้ามส่งคำขอสร้าง/แก้ไขซ้ำ หรือสร้าง URL สำหรับตรวจสอบสถานะเป็นระยะจาก operation_id
ฟิลด์การตอบกลับ
| ฟิลด์ | ประเภท |
|---|---|
ฟิลด์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
ชื่อพาธเมธอดอื่น
ใช้พาธเมธอดที่แสดงด้านบน
ID ที่เกี่ยวข้องสำหรับเรียกใช้โมเดล
FAQ · wan2.7-image-pro
- มีอินพุตและผลลัพธ์ใดบ้าง?
POST /v1/images/generations·wan2.7-image-pro:text→imagePOST /v1/images/generations·wan-image:text→imagePOST /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:1POST /v1/images/generations·wan-image:n.minimum:1POST /v1/images/generations·wan-image-latest:n.minimum:1