qwen-image-3.0-pro
依據文字生成圖片的模型,著重複雜版面、文字內容及逼真細節。適合海報、分鏡圖、菜單,以及構圖密集的素材。
- Ailoot · 圖片
POST /v1/images/generationsqwen-image-3.0-pro - Ailoot · 圖片
POST /v1/images/generationsqwen-image - Ailoot · 圖片
POST /v1/images/generationsqwen-image-latest
關於模型
此說明介紹模型的能力。Ailoot 可用的輸入、輸出與選項,依所選方法列於下方。
Qwen-Image-3.0-Pro 是 Alibaba 的圖片建立與編輯模型,適用於重視構圖、文字及細小細節的影像。用途包括密集版面、圖中圖、報紙排版、分鏡圖、菜單與學習單。目前 Ailoot 卡片提供依據文字任務描述生成圖片的模式。Alibaba 也提供編輯及參考圖片處理;這些操作須另行支援圖片輸入,並非目前卡片方法所提供的功能。
圖片中的文字與細節
模型開發商著重最長 4.5 千個 Token 的長任務描述、12 種語言的圖片文字,以及多種字體的處理。這是所描述的任務處理能力,不是公布的正式脈絡視窗大小。宣稱的特性包括呈現 10 像素大小的小字、皮膚與毛髮紋理,以及細微的臉部表情變化。準備需近距離觀看的素材時,這些細節尤其有用。
Qwen-Image-3.0-Pro 也適用於網頁、遊戲及直播畫面的視覺概念。結果可結合插畫、畫面結構及經過設計的文字。模型產生的是版面示意圖片;可運作的應用程式仍須另行實作。
Alibaba 規格中的編輯模式
Alibaba 的編輯模式可使用一至三張圖片。在此方式中,模型開發商允許將物件連結到參考圖編號,並描述素材的組合方式。支援新增、刪除及移動物件,以及變更動作、風格、細節與文字。負面描述可用來指出不希望出現的元素。
模型開發商的編輯模式接受 JPG、JPEG、PNG、BMP、TIFF、WEBP 及 GIF 輸入素材。動畫 GIF 使用第一個影格。每個檔案大小上限為 10 MB;模型開發商建議圖片各邊介於 384 至 3072 像素。這些是輸入素材建議,不是完成結果的尺寸。
模型開發商規格提供每項請求輸出一至六張 PNG 圖片。結果面積範圍為 262 144 至 4 194 304 像素,對應正方形圖片的 512 × 512 至 2048 × 2048 尺寸。允許的長寬比為 1:8 至 8:1,因此狹長構圖的邊長也取決於選定的畫面形狀。生成前可進一步處理任務描述。
Ailoot · 圖片 POST /v1/images/generations qwen-image-3.0-pro
qwen-image-3.0-proqwen-image-3.0-proqwen-imageqwen-image-latest
入門
依據文字生成圖片的模型,著重複雜版面、文字內容及逼真細節。適合海報、分鏡圖、菜單,以及構圖密集的素材。
- 接受的輸入
- 文字
- 結果
- 圖片
Ailoot 可用 · 輸入與方法
Ailoot · 圖片 POST /v1/images/generations
- 輸入
text- 輸出
image- 輸出格式
- 圖片檔案
| 欄位 | 類型 | 要求 | 值與限制 | 預設值 |
|---|---|---|---|---|
欄位model | 類型string | 要求必填 | 值與限制 qwen-image-3.0-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 | 要求不支援 | 值與限制 解碼後位元組數上限: 10,485,760 MIME 類型: image/png, image/jpeg 每個陣列的圖片數上限: 3 條件: 每個 images[] 物件提供一個實際 URL。陣列項目數與此字串葉節點是不同概念。 適用條件: 僅限 JSON images/edits;JSON images/generations 不會解析 images 參考資料。 | 預設值— |
欄位image | 類型file | 要求選填 | 值與限制 解碼後位元組數上限: 10,485,760 MIME 類型: image/png, image/jpeg 適用條件: 以 multipart/form-data 生成 | 預設值— |
欄位image[] | 類型file[] | 要求選填 | 值與限制 項目數上限: 3 解碼後位元組數上限: 10,485,760 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.003 每張輸入圖片
- 輸出
- US$0.04 每張 1K 圖片
- 輸出
- US$0.075 每張 2K 圖片
Ailoot 會在請求前預留估算金額。取得結果後,依實測用量結算最終費用。串流結算採用最終用量紀錄。預留金額與結算的運作方式 →
請求範例
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": "qwen-image-3.0-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': 'qwen-image-3.0-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": "qwen-image-3.0-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 值,透過媒體庫取回自己擁有的既有結果。請勿重新提交生成/編輯請求,也請勿以 operation_id 組成輪詢 URL。
回應欄位
| 欄位 | 類型 |
|---|---|
欄位created | 類型integer |
欄位data[].url | 類型string |
欄位data[].b64_json | 類型base64 string |
欄位usage | 類型object |
錯誤與後續步驟
| 回應 | 條件 | 下一步 |
|---|---|---|
回應400 · invalid_request_error | 條件必要欄位、素材表示方式或參數值無效 | 下一步提出新的建立請求前,先修正指定欄位。 |
回應server_error | 條件回傳的回應表示該作業或結果需要檢查 | 下一步保留原始回傳的作業/任務 ID、請求標頭與回應;繼續以支援的方式讀取該原始作業。請勿重新提交建立請求。 |
別名
模型別名
Ailoot qwen-image-3.0-pro, qwen-image, qwen-image-latest
方法路徑別名
請使用上方列出的 API 方法路徑。
相關呼叫用 ID
Ailoot · 圖片 POST /v1/images/generations qwen-image
qwen-imageqwen-image-3.0-proqwen-imageqwen-image-latest
入門
依據文字生成圖片的模型,著重複雜版面、文字內容及逼真細節。適合海報、分鏡圖、菜單,以及構圖密集的素材。
- 接受的輸入
- 文字
- 結果
- 圖片
Ailoot 可用 · 輸入與方法
Ailoot · 圖片 POST /v1/images/generations
- 輸入
text- 輸出
image- 輸出格式
- 圖片檔案
| 欄位 | 類型 | 要求 | 值與限制 | 預設值 |
|---|---|---|---|---|
欄位model | 類型string | 要求必填 | 值與限制 qwen-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 | 要求不支援 | 值與限制 解碼後位元組數上限: 10,485,760 MIME 類型: image/png, image/jpeg 每個陣列的圖片數上限: 3 條件: 每個 images[] 物件提供一個實際 URL。陣列項目數與此字串葉節點是不同概念。 適用條件: 僅限 JSON images/edits;JSON images/generations 不會解析 images 參考資料。 | 預設值— |
欄位image | 類型file | 要求選填 | 值與限制 解碼後位元組數上限: 10,485,760 MIME 類型: image/png, image/jpeg 適用條件: 以 multipart/form-data 生成 | 預設值— |
欄位image[] | 類型file[] | 要求選填 | 值與限制 項目數上限: 3 解碼後位元組數上限: 10,485,760 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.003 每張輸入圖片
- 輸出
- US$0.04 每張 1K 圖片
- 輸出
- US$0.075 每張 2K 圖片
Ailoot 會在請求前預留估算金額。取得結果後,依實測用量結算最終費用。串流結算採用最終用量紀錄。預留金額與結算的運作方式 →
請求範例
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": "qwen-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': 'qwen-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": "qwen-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 值,透過媒體庫取回自己擁有的既有結果。請勿重新提交生成/編輯請求,也請勿以 operation_id 組成輪詢 URL。
回應欄位
| 欄位 | 類型 |
|---|---|
欄位created | 類型integer |
欄位data[].url | 類型string |
欄位data[].b64_json | 類型base64 string |
欄位usage | 類型object |
錯誤與後續步驟
| 回應 | 條件 | 下一步 |
|---|---|---|
回應400 · invalid_request_error | 條件必要欄位、素材表示方式或參數值無效 | 下一步提出新的建立請求前,先修正指定欄位。 |
回應server_error | 條件回傳的回應表示該作業或結果需要檢查 | 下一步保留原始回傳的作業/任務 ID、請求標頭與回應;繼續以支援的方式讀取該原始作業。請勿重新提交建立請求。 |
別名
模型別名
Ailoot qwen-image-3.0-pro, qwen-image, qwen-image-latest
方法路徑別名
請使用上方列出的 API 方法路徑。
相關呼叫用 ID
Ailoot · 圖片 POST /v1/images/generations qwen-image-latest
qwen-image-latestqwen-image-3.0-proqwen-imageqwen-image-latest
入門
依據文字生成圖片的模型,著重複雜版面、文字內容及逼真細節。適合海報、分鏡圖、菜單,以及構圖密集的素材。
- 接受的輸入
- 文字
- 結果
- 圖片
Ailoot 可用 · 輸入與方法
Ailoot · 圖片 POST /v1/images/generations
- 輸入
text- 輸出
image- 輸出格式
- 圖片檔案
| 欄位 | 類型 | 要求 | 值與限制 | 預設值 |
|---|---|---|---|---|
欄位model | 類型string | 要求必填 | 值與限制 qwen-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 | 要求不支援 | 值與限制 解碼後位元組數上限: 10,485,760 MIME 類型: image/png, image/jpeg 每個陣列的圖片數上限: 3 條件: 每個 images[] 物件提供一個實際 URL。陣列項目數與此字串葉節點是不同概念。 適用條件: 僅限 JSON images/edits;JSON images/generations 不會解析 images 參考資料。 | 預設值— |
欄位image | 類型file | 要求選填 | 值與限制 解碼後位元組數上限: 10,485,760 MIME 類型: image/png, image/jpeg 適用條件: 以 multipart/form-data 生成 | 預設值— |
欄位image[] | 類型file[] | 要求選填 | 值與限制 項目數上限: 3 解碼後位元組數上限: 10,485,760 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.003 每張輸入圖片
- 輸出
- US$0.04 每張 1K 圖片
- 輸出
- US$0.075 每張 2K 圖片
Ailoot 會在請求前預留估算金額。取得結果後,依實測用量結算最終費用。串流結算採用最終用量紀錄。預留金額與結算的運作方式 →
請求範例
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": "qwen-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': 'qwen-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": "qwen-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 值,透過媒體庫取回自己擁有的既有結果。請勿重新提交生成/編輯請求,也請勿以 operation_id 組成輪詢 URL。
回應欄位
| 欄位 | 類型 |
|---|---|
欄位created | 類型integer |
欄位data[].url | 類型string |
欄位data[].b64_json | 類型base64 string |
欄位usage | 類型object |
錯誤與後續步驟
| 回應 | 條件 | 下一步 |
|---|---|---|
回應400 · invalid_request_error | 條件必要欄位、素材表示方式或參數值無效 | 下一步提出新的建立請求前,先修正指定欄位。 |
回應server_error | 條件回傳的回應表示該作業或結果需要檢查 | 下一步保留原始回傳的作業/任務 ID、請求標頭與回應;繼續以支援的方式讀取該原始作業。請勿重新提交建立請求。 |
別名
模型別名
Ailoot qwen-image-3.0-pro, qwen-image, qwen-image-latest
方法路徑別名
請使用上方列出的 API 方法路徑。
相關呼叫用 ID
FAQ · qwen-image-3.0-pro
- 可以使用哪些輸入與結果?
POST /v1/images/generations·qwen-image-3.0-pro:text→imagePOST /v1/images/generations·qwen-image:text→imagePOST /v1/images/generations·qwen-image-latest:text→image- 請求使用哪些欄位?
POST /v1/images/generations·qwen-image-3.0-pro:model,prompt,n,response_format,stream,image,image[]POST /v1/images/generations·qwen-image:model,prompt,n,response_format,stream,image,image[]POST /v1/images/generations·qwen-image-latest:model,prompt,n,response_format,stream,image,image[]- 適用哪些限制?
POST /v1/images/generations·qwen-image-3.0-pro:n.minimum:1POST /v1/images/generations·qwen-image:n.minimum:1POST /v1/images/generations·qwen-image-latest:n.minimum:1