image-01
MiniMax image-01 tạo ảnh từ mô tả văn bản chi tiết; hỗ trợ bố cục vuông, dọc và rộng.
- Ailoot · Ảnh
POST /v1/images/generationsimage-01 - Ailoot · Ảnh
POST /v1/images/generationsminimax-image - Ailoot · Ảnh
POST /v1/images/generationsminimax-image-latest - Ailoot · Ảnh
POST /v1/images/generationsminimax/image-01
Về mô hình
Mô tả này trình bày khả năng của mô hình. Đầu vào, đầu ra và tùy chọn có trên Ailoot được liệt kê bên dưới cho phương thức đã chọn.
Tạo ảnh từ mô tả
MiniMax image-01 tạo ảnh mới từ mô tả văn bản. Có thể xác định nhân vật hoặc đồ vật, môi trường và phong cách hình ảnh trong mô tả. Thẻ Ailoot này nhận văn bản và trả về ảnh; mô tả xác định nội dung và bố cục của cảnh sắp được tạo.
Xử lý diện mạo nhân vật
Khả năng của mô hình ở phía nhà sản xuất còn gồm tạo ảnh với mẫu hình ảnh của nhân vật. Một ảnh nguồn có đối tượng chính rõ ràng giúp chuyển những nét đặc trưng của đối tượng sang cảnh mới cùng mô tả văn bản. Nhà sản xuất khuyến nghị một ảnh chân dung chính diện đơn lẻ; hỗ trợ một ảnh tham chiếu trong mỗi yêu cầu.
Các định dạng được công bố cho ảnh nguồn này là JPG, JPEG và PNG với dung lượng nhỏ hơn 10 MB. Cách tạo ảnh sẵn có trong thẻ này là từ văn bản; khả năng tham chiếu thuộc mô hình image-01 và không tự động mở rộng đầu vào của yêu cầu.
Tỷ lệ và kích thước
image-01 có tám tỷ lệ: 1:1, 16:9, 4:3, 3:2, 2:3, 3:4, 9:16 và 21:9. Chúng bao quát bố cục vuông, ngang, dọc và rộng. Kích thước tiêu chuẩn tương ứng là 1024×1024, 1280×720, 1152×864, 1248×832, 832×1248, 864×1152, 720×1280 và 1344×576 pixel.
Nhà sản xuất còn cho phép đặt đồng thời chiều rộng và chiều cao: mỗi chiều từ 512 đến 2048 pixel, với bước là bội số của 8. Khi đặt cả tỷ lệ và kích thước riêng, tỷ lệ khung hình được ưu tiên.
Số phương án và tham số tạo ảnh
Khả năng của mô hình gồm từ 1 đến 9 ảnh trong mỗi yêu cầu; mặc định tạo một ảnh. Mô tả văn bản giới hạn 1500 ký tự. Có tối ưu mô tả tự động, ban đầu được tắt, và hạt giống ngẫu nhiên: cùng hạt giống với cùng tham số được sử dụng để tái tạo kết quả.
Kết quả tạo ảnh là một ảnh hoặc tập ảnh. Nhà sản xuất cho phép truyền dữ liệu trực tiếp và nhận tệp; nếu một phần phương án không được tạo, số kết quả thành công được tính riêng. Các kích thước và cài đặt được liệt kê mô tả khả năng của mô hình; thẻ Ailoot xác định những tham số sẵn có cho từng yêu cầu cụ thể.
Ailoot · Ảnh POST /v1/images/generations image-01
image-01image-01minimax-imageminimax-image-latestminimax/image-01
Bắt đầu
MiniMax image-01 tạo ảnh từ mô tả văn bản chi tiết; hỗ trợ bố cục vuông, dọc và rộng.
- Đầu vào được chấp nhận
- Văn bản
- Kết quả
- Ảnh
Có trên Ailoot · đầu vào & phương thức
Ailoot · Ảnh POST /v1/images/generations
- Đầu vào
text- Đầu ra
image- Định dạng đầu ra
- Tệp ảnh
| Trường | Loại | Yêu cầu | Giá trị & giới hạn | Mặc định |
|---|---|---|---|---|
Trườngmodel | Loạistring | Yêu cầuBắt buộc | Giá trị & giới hạn image-01 | Mặc định— |
Trườngprompt | Loạistring | Yêu cầuBắt buộc | Giá trị & giới hạn Độ dài tối thiểu: 1 | Mặc định— |
Trườngn | Loạiinteger | Yêu cầuKhông bắt buộc | Giá trị & giới hạn Tối thiểu: 1 | Mặc định1 |
Trườngresponse_format | Loạistring | Yêu cầuKhông bắt buộc | Giá trị & giới hạn url, b64_json | Mặc định— |
Trườngstream | Loạiboolean | Yêu cầuKhông bắt buộc | Giá trị & giới hạn | Mặc địnhfalse |
Trườngsize | Loạistring | Yêu cầuKhông bắt buộc | Giá trị & giới hạn Tùy thuộc vào mô hình | Mặc định— |
Trườngquality | Loạistring | Yêu cầuKhông bắt buộc | Giá trị & giới hạn Tùy thuộc vào mô hình | Mặc định— |
Trườngbackground | Loạistring | Yêu cầuKhông bắt buộc | Giá trị & giới hạn Tùy thuộc vào mô hình | Mặc định— |
Trườngoutput_format | Loạistring | Yêu cầuKhông bắt buộc | Giá trị & giới hạn Tùy thuộc vào mô hình | Mặc định— |
Trườngoutput_compression | Loạiinteger | Yêu cầuKhông bắt buộc | Giá trị & giới hạn Tùy thuộc vào mô hình | Mặc định— |
Trườngmoderation | Loạistring | Yêu cầuKhông bắt buộc | Giá trị & giới hạn Tùy thuộc vào mô hình | Mặc định— |
Trườnginput_fidelity | Loạistring | Yêu cầuKhông bắt buộc | Giá trị & giới hạn Tùy thuộc vào mô hình | Mặc định— |
Trườngstyle | Loạistring | Yêu cầuKhông bắt buộc | Giá trị & giới hạn Tùy thuộc vào mô hình | Mặc định— |
Trườngpartial_images | Loạiinteger | Yêu cầuKhông bắt buộc | Giá trị & giới hạn Tùy thuộc vào mô hình | Mặc định— |
Tổ hợp tư liệu đầu vào
Văn bản thành ảnh · Bắt buộc: prompt
Tham số phương thức và vòng đời
| Tham số | Hợp đồng |
|---|---|
Tham sốmaterial_types | Hợp đồngtext |
Tham sốrequired | Hợp đồngmodel, prompt |
Tham sốoptional_controls | Hợp đồngnull |
Tham sốcontent_type | Hợp đồngapplication/json |
Vòng đời: synchronous_result_then_owned_library
GET /v1/media/tasks/{task_id} · Giá trị task_id thực tế đã trả về hoặc bản ghi trong thư viện nội dung đa phương tiện
GET /v1/media/assets/{asset_id}/content
GET /v1/media/assets
GET /v1/media/assets/{asset_id}
Cấu trúc phương thức và ID là chính xác; khả năng của nhà cung cấp tách biệt với việc cho phép tiếp nhận yêu cầu.
Bảng giá
Mức phí phương thức Ailoot
POST /v1/images/generations- Đầu ra
- 0,0035 US$ mỗi ảnh 1K
- Đầu ra
- 0,0035 US$ mỗi ảnh 2K
Ailoot tạm giữ một khoản ước tính trước yêu cầu. Sau khi có kết quả, phí cuối cùng được quyết toán theo mức sử dụng đo được. Việc quyết toán khi truyền luồng dùng bản ghi mức sử dụng cuối cùng. Cách hoạt động của cơ chế tạm giữ và quyết toán →
Ví dụ yêu cầu
Ailoot · Ảnh
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": "image-01", "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': 'image-01', '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": "image-01", "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");
Nhận và lưu kết quả
Ailoot · Ảnh
Tải xuống từng ảnh trả về hoặc lưu nội dung Base64 của ảnh
GET /v1/media/tasks/{task_id}GET /v1/media/assets/{asset_id}/contentGET /v1/media/assetsGET /v1/media/assets/{asset_id}
Lưu tất cả kết quả đã hoàn tất
Lưu mọi ảnh đã hoàn tất; truy xuất từng URL trả về hoặc giải mã nội dung Base64 của ảnh.
Lưu mọi phần tử dữ liệu. Giải mã từng b64_json hoặc tải xuống từ mọi URL có chữ ký đã trả về. Chọn phần mở rộng tệp dựa trên MIME/nội dung byte thực tế.
Nếu cần kiểm tra phản hồi gốc
Nếu kết quả tạo hoặc chỉnh sửa ảnh cần được kiểm tra, giữ lại operation_id/X-Client-Request-ID gốc và thông tin kết quả đã trả về. Khôi phục các kết quả hiện có thuộc quyền sở hữu của bạn qua thư viện nội dung đa phương tiện bằng các giá trị task_id hoặc asset_id thực tế. Không gửi lại yêu cầu tạo/chỉnh sửa ảnh hoặc tạo URL truy vấn trạng thái từ operation_id.
Trường phản hồi
| Trường | Loại |
|---|---|
Trườngcreated | Loạiinteger |
Trườngdata[].url | Loạistring |
Trườngdata[].b64_json | Loạibase64 string |
Trườngusage | Loạiobject |
Lỗi và bước tiếp theo
| Phản hồi | Điều kiện | Bước tiếp theo |
|---|---|---|
Phản hồi400 · invalid_request_error | Điều kiệnTrường bắt buộc, cách biểu diễn tài liệu hoặc giá trị tham số không hợp lệ | Bước tiếp theoSửa các trường được chỉ ra trước khi gửi yêu cầu tạo mới. |
Phản hồiserver_error | Điều kiệnPhản hồi trả về cho biết thao tác hoặc kết quả cần được kiểm tra | Bước tiếp theoGiữ lại ID thao tác/tác vụ gốc đã trả về, các header của yêu cầu và toàn bộ phản hồi; tiếp tục truy xuất thao tác gốc đó bằng các phương thức được hỗ trợ. Không gửi lại yêu cầu tạo. |
Bí danh
Bí danh mô hình
Ailoot image-01, minimax-image, minimax-image-latest, minimax/image-01
Bí danh đường dẫn phương thức
Dùng các đường dẫn phương thức hiển thị ở trên.
ID gọi liên quan
image-01, minimax-image, minimax-image-latest, minimax/image-01
Ailoot · Ảnh POST /v1/images/generations minimax-image
minimax-imageimage-01minimax-imageminimax-image-latestminimax/image-01
Bắt đầu
MiniMax image-01 tạo ảnh từ mô tả văn bản chi tiết; hỗ trợ bố cục vuông, dọc và rộng.
- Đầu vào được chấp nhận
- Văn bản
- Kết quả
- Ảnh
Có trên Ailoot · đầu vào & phương thức
Ailoot · Ảnh POST /v1/images/generations
- Đầu vào
text- Đầu ra
image- Định dạng đầu ra
- Tệp ảnh
| Trường | Loại | Yêu cầu | Giá trị & giới hạn | Mặc định |
|---|---|---|---|---|
Trườngmodel | Loạistring | Yêu cầuBắt buộc | Giá trị & giới hạn minimax-image | Mặc định— |
Trườngprompt | Loạistring | Yêu cầuBắt buộc | Giá trị & giới hạn Độ dài tối thiểu: 1 | Mặc định— |
Trườngn | Loạiinteger | Yêu cầuKhông bắt buộc | Giá trị & giới hạn Tối thiểu: 1 | Mặc định1 |
Trườngresponse_format | Loạistring | Yêu cầuKhông bắt buộc | Giá trị & giới hạn url, b64_json | Mặc định— |
Trườngstream | Loạiboolean | Yêu cầuKhông bắt buộc | Giá trị & giới hạn | Mặc địnhfalse |
Trườngsize | Loạistring | Yêu cầuKhông bắt buộc | Giá trị & giới hạn Tùy thuộc vào mô hình | Mặc định— |
Trườngquality | Loạistring | Yêu cầuKhông bắt buộc | Giá trị & giới hạn Tùy thuộc vào mô hình | Mặc định— |
Trườngbackground | Loạistring | Yêu cầuKhông bắt buộc | Giá trị & giới hạn Tùy thuộc vào mô hình | Mặc định— |
Trườngoutput_format | Loạistring | Yêu cầuKhông bắt buộc | Giá trị & giới hạn Tùy thuộc vào mô hình | Mặc định— |
Trườngoutput_compression | Loạiinteger | Yêu cầuKhông bắt buộc | Giá trị & giới hạn Tùy thuộc vào mô hình | Mặc định— |
Trườngmoderation | Loạistring | Yêu cầuKhông bắt buộc | Giá trị & giới hạn Tùy thuộc vào mô hình | Mặc định— |
Trườnginput_fidelity | Loạistring | Yêu cầuKhông bắt buộc | Giá trị & giới hạn Tùy thuộc vào mô hình | Mặc định— |
Trườngstyle | Loạistring | Yêu cầuKhông bắt buộc | Giá trị & giới hạn Tùy thuộc vào mô hình | Mặc định— |
Trườngpartial_images | Loạiinteger | Yêu cầuKhông bắt buộc | Giá trị & giới hạn Tùy thuộc vào mô hình | Mặc định— |
Tổ hợp tư liệu đầu vào
Văn bản thành ảnh · Bắt buộc: prompt
Tham số phương thức và vòng đời
| Tham số | Hợp đồng |
|---|---|
Tham sốmaterial_types | Hợp đồngtext |
Tham sốrequired | Hợp đồngmodel, prompt |
Tham sốoptional_controls | Hợp đồngnull |
Tham sốcontent_type | Hợp đồngapplication/json |
Vòng đời: synchronous_result_then_owned_library
GET /v1/media/tasks/{task_id} · Giá trị task_id thực tế đã trả về hoặc bản ghi trong thư viện nội dung đa phương tiện
GET /v1/media/assets/{asset_id}/content
GET /v1/media/assets
GET /v1/media/assets/{asset_id}
Cấu trúc phương thức và ID là chính xác; khả năng của nhà cung cấp tách biệt với việc cho phép tiếp nhận yêu cầu.
Bảng giá
Mức phí phương thức Ailoot
POST /v1/images/generations- Đầu ra
- 0,0035 US$ mỗi ảnh 1K
- Đầu ra
- 0,0035 US$ mỗi ảnh 2K
Ailoot tạm giữ một khoản ước tính trước yêu cầu. Sau khi có kết quả, phí cuối cùng được quyết toán theo mức sử dụng đo được. Việc quyết toán khi truyền luồng dùng bản ghi mức sử dụng cuối cùng. Cách hoạt động của cơ chế tạm giữ và quyết toán →
Ví dụ yêu cầu
Ailoot · Ảnh
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": "minimax-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': 'minimax-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": "minimax-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");
Nhận và lưu kết quả
Ailoot · Ảnh
Tải xuống từng ảnh trả về hoặc lưu nội dung Base64 của ảnh
GET /v1/media/tasks/{task_id}GET /v1/media/assets/{asset_id}/contentGET /v1/media/assetsGET /v1/media/assets/{asset_id}
Lưu tất cả kết quả đã hoàn tất
Lưu mọi ảnh đã hoàn tất; truy xuất từng URL trả về hoặc giải mã nội dung Base64 của ảnh.
Lưu mọi phần tử dữ liệu. Giải mã từng b64_json hoặc tải xuống từ mọi URL có chữ ký đã trả về. Chọn phần mở rộng tệp dựa trên MIME/nội dung byte thực tế.
Nếu cần kiểm tra phản hồi gốc
Nếu kết quả tạo hoặc chỉnh sửa ảnh cần được kiểm tra, giữ lại operation_id/X-Client-Request-ID gốc và thông tin kết quả đã trả về. Khôi phục các kết quả hiện có thuộc quyền sở hữu của bạn qua thư viện nội dung đa phương tiện bằng các giá trị task_id hoặc asset_id thực tế. Không gửi lại yêu cầu tạo/chỉnh sửa ảnh hoặc tạo URL truy vấn trạng thái từ operation_id.
Trường phản hồi
| Trường | Loại |
|---|---|
Trườngcreated | Loạiinteger |
Trườngdata[].url | Loạistring |
Trườngdata[].b64_json | Loạibase64 string |
Trườngusage | Loạiobject |
Lỗi và bước tiếp theo
| Phản hồi | Điều kiện | Bước tiếp theo |
|---|---|---|
Phản hồi400 · invalid_request_error | Điều kiệnTrường bắt buộc, cách biểu diễn tài liệu hoặc giá trị tham số không hợp lệ | Bước tiếp theoSửa các trường được chỉ ra trước khi gửi yêu cầu tạo mới. |
Phản hồiserver_error | Điều kiệnPhản hồi trả về cho biết thao tác hoặc kết quả cần được kiểm tra | Bước tiếp theoGiữ lại ID thao tác/tác vụ gốc đã trả về, các header của yêu cầu và toàn bộ phản hồi; tiếp tục truy xuất thao tác gốc đó bằng các phương thức được hỗ trợ. Không gửi lại yêu cầu tạo. |
Bí danh
Bí danh mô hình
Ailoot image-01, minimax-image, minimax-image-latest, minimax/image-01
Bí danh đường dẫn phương thức
Dùng các đường dẫn phương thức hiển thị ở trên.
ID gọi liên quan
image-01, minimax-image, minimax-image-latest, minimax/image-01
Ailoot · Ảnh POST /v1/images/generations minimax-image-latest
minimax-image-latestimage-01minimax-imageminimax-image-latestminimax/image-01
Bắt đầu
MiniMax image-01 tạo ảnh từ mô tả văn bản chi tiết; hỗ trợ bố cục vuông, dọc và rộng.
- Đầu vào được chấp nhận
- Văn bản
- Kết quả
- Ảnh
Có trên Ailoot · đầu vào & phương thức
Ailoot · Ảnh POST /v1/images/generations
- Đầu vào
text- Đầu ra
image- Định dạng đầu ra
- Tệp ảnh
| Trường | Loại | Yêu cầu | Giá trị & giới hạn | Mặc định |
|---|---|---|---|---|
Trườngmodel | Loạistring | Yêu cầuBắt buộc | Giá trị & giới hạn minimax-image-latest | Mặc định— |
Trườngprompt | Loạistring | Yêu cầuBắt buộc | Giá trị & giới hạn Độ dài tối thiểu: 1 | Mặc định— |
Trườngn | Loạiinteger | Yêu cầuKhông bắt buộc | Giá trị & giới hạn Tối thiểu: 1 | Mặc định1 |
Trườngresponse_format | Loạistring | Yêu cầuKhông bắt buộc | Giá trị & giới hạn url, b64_json | Mặc định— |
Trườngstream | Loạiboolean | Yêu cầuKhông bắt buộc | Giá trị & giới hạn | Mặc địnhfalse |
Trườngsize | Loạistring | Yêu cầuKhông bắt buộc | Giá trị & giới hạn Tùy thuộc vào mô hình | Mặc định— |
Trườngquality | Loạistring | Yêu cầuKhông bắt buộc | Giá trị & giới hạn Tùy thuộc vào mô hình | Mặc định— |
Trườngbackground | Loạistring | Yêu cầuKhông bắt buộc | Giá trị & giới hạn Tùy thuộc vào mô hình | Mặc định— |
Trườngoutput_format | Loạistring | Yêu cầuKhông bắt buộc | Giá trị & giới hạn Tùy thuộc vào mô hình | Mặc định— |
Trườngoutput_compression | Loạiinteger | Yêu cầuKhông bắt buộc | Giá trị & giới hạn Tùy thuộc vào mô hình | Mặc định— |
Trườngmoderation | Loạistring | Yêu cầuKhông bắt buộc | Giá trị & giới hạn Tùy thuộc vào mô hình | Mặc định— |
Trườnginput_fidelity | Loạistring | Yêu cầuKhông bắt buộc | Giá trị & giới hạn Tùy thuộc vào mô hình | Mặc định— |
Trườngstyle | Loạistring | Yêu cầuKhông bắt buộc | Giá trị & giới hạn Tùy thuộc vào mô hình | Mặc định— |
Trườngpartial_images | Loạiinteger | Yêu cầuKhông bắt buộc | Giá trị & giới hạn Tùy thuộc vào mô hình | Mặc định— |
Tổ hợp tư liệu đầu vào
Văn bản thành ảnh · Bắt buộc: prompt
Tham số phương thức và vòng đời
| Tham số | Hợp đồng |
|---|---|
Tham sốmaterial_types | Hợp đồngtext |
Tham sốrequired | Hợp đồngmodel, prompt |
Tham sốoptional_controls | Hợp đồngnull |
Tham sốcontent_type | Hợp đồngapplication/json |
Vòng đời: synchronous_result_then_owned_library
GET /v1/media/tasks/{task_id} · Giá trị task_id thực tế đã trả về hoặc bản ghi trong thư viện nội dung đa phương tiện
GET /v1/media/assets/{asset_id}/content
GET /v1/media/assets
GET /v1/media/assets/{asset_id}
Cấu trúc phương thức và ID là chính xác; khả năng của nhà cung cấp tách biệt với việc cho phép tiếp nhận yêu cầu.
Bảng giá
Mức phí phương thức Ailoot
POST /v1/images/generations- Đầu ra
- 0,0035 US$ mỗi ảnh 1K
- Đầu ra
- 0,0035 US$ mỗi ảnh 2K
Ailoot tạm giữ một khoản ước tính trước yêu cầu. Sau khi có kết quả, phí cuối cùng được quyết toán theo mức sử dụng đo được. Việc quyết toán khi truyền luồng dùng bản ghi mức sử dụng cuối cùng. Cách hoạt động của cơ chế tạm giữ và quyết toán →
Ví dụ yêu cầu
Ailoot · Ảnh
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": "minimax-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': 'minimax-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": "minimax-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");
Nhận và lưu kết quả
Ailoot · Ảnh
Tải xuống từng ảnh trả về hoặc lưu nội dung Base64 của ảnh
GET /v1/media/tasks/{task_id}GET /v1/media/assets/{asset_id}/contentGET /v1/media/assetsGET /v1/media/assets/{asset_id}
Lưu tất cả kết quả đã hoàn tất
Lưu mọi ảnh đã hoàn tất; truy xuất từng URL trả về hoặc giải mã nội dung Base64 của ảnh.
Lưu mọi phần tử dữ liệu. Giải mã từng b64_json hoặc tải xuống từ mọi URL có chữ ký đã trả về. Chọn phần mở rộng tệp dựa trên MIME/nội dung byte thực tế.
Nếu cần kiểm tra phản hồi gốc
Nếu kết quả tạo hoặc chỉnh sửa ảnh cần được kiểm tra, giữ lại operation_id/X-Client-Request-ID gốc và thông tin kết quả đã trả về. Khôi phục các kết quả hiện có thuộc quyền sở hữu của bạn qua thư viện nội dung đa phương tiện bằng các giá trị task_id hoặc asset_id thực tế. Không gửi lại yêu cầu tạo/chỉnh sửa ảnh hoặc tạo URL truy vấn trạng thái từ operation_id.
Trường phản hồi
| Trường | Loại |
|---|---|
Trườngcreated | Loạiinteger |
Trườngdata[].url | Loạistring |
Trườngdata[].b64_json | Loạibase64 string |
Trườngusage | Loạiobject |
Lỗi và bước tiếp theo
| Phản hồi | Điều kiện | Bước tiếp theo |
|---|---|---|
Phản hồi400 · invalid_request_error | Điều kiệnTrường bắt buộc, cách biểu diễn tài liệu hoặc giá trị tham số không hợp lệ | Bước tiếp theoSửa các trường được chỉ ra trước khi gửi yêu cầu tạo mới. |
Phản hồiserver_error | Điều kiệnPhản hồi trả về cho biết thao tác hoặc kết quả cần được kiểm tra | Bước tiếp theoGiữ lại ID thao tác/tác vụ gốc đã trả về, các header của yêu cầu và toàn bộ phản hồi; tiếp tục truy xuất thao tác gốc đó bằng các phương thức được hỗ trợ. Không gửi lại yêu cầu tạo. |
Bí danh
Bí danh mô hình
Ailoot image-01, minimax-image, minimax-image-latest, minimax/image-01
Bí danh đường dẫn phương thức
Dùng các đường dẫn phương thức hiển thị ở trên.
ID gọi liên quan
image-01, minimax-image, minimax-image-latest, minimax/image-01
Ailoot · Ảnh POST /v1/images/generations minimax/image-01
minimax/image-01image-01minimax-imageminimax-image-latestminimax/image-01
Bắt đầu
MiniMax image-01 tạo ảnh từ mô tả văn bản chi tiết; hỗ trợ bố cục vuông, dọc và rộng.
- Đầu vào được chấp nhận
- Văn bản
- Kết quả
- Ảnh
Có trên Ailoot · đầu vào & phương thức
Ailoot · Ảnh POST /v1/images/generations
- Đầu vào
text- Đầu ra
image- Định dạng đầu ra
- Tệp ảnh
| Trường | Loại | Yêu cầu | Giá trị & giới hạn | Mặc định |
|---|---|---|---|---|
Trườngmodel | Loạistring | Yêu cầuBắt buộc | Giá trị & giới hạn minimax/image-01 | Mặc định— |
Trườngprompt | Loạistring | Yêu cầuBắt buộc | Giá trị & giới hạn Độ dài tối thiểu: 1 | Mặc định— |
Trườngn | Loạiinteger | Yêu cầuKhông bắt buộc | Giá trị & giới hạn Tối thiểu: 1 | Mặc định1 |
Trườngresponse_format | Loạistring | Yêu cầuKhông bắt buộc | Giá trị & giới hạn url, b64_json | Mặc định— |
Trườngstream | Loạiboolean | Yêu cầuKhông bắt buộc | Giá trị & giới hạn | Mặc địnhfalse |
Trườngsize | Loạistring | Yêu cầuKhông bắt buộc | Giá trị & giới hạn Tùy thuộc vào mô hình | Mặc định— |
Trườngquality | Loạistring | Yêu cầuKhông bắt buộc | Giá trị & giới hạn Tùy thuộc vào mô hình | Mặc định— |
Trườngbackground | Loạistring | Yêu cầuKhông bắt buộc | Giá trị & giới hạn Tùy thuộc vào mô hình | Mặc định— |
Trườngoutput_format | Loạistring | Yêu cầuKhông bắt buộc | Giá trị & giới hạn Tùy thuộc vào mô hình | Mặc định— |
Trườngoutput_compression | Loạiinteger | Yêu cầuKhông bắt buộc | Giá trị & giới hạn Tùy thuộc vào mô hình | Mặc định— |
Trườngmoderation | Loạistring | Yêu cầuKhông bắt buộc | Giá trị & giới hạn Tùy thuộc vào mô hình | Mặc định— |
Trườnginput_fidelity | Loạistring | Yêu cầuKhông bắt buộc | Giá trị & giới hạn Tùy thuộc vào mô hình | Mặc định— |
Trườngstyle | Loạistring | Yêu cầuKhông bắt buộc | Giá trị & giới hạn Tùy thuộc vào mô hình | Mặc định— |
Trườngpartial_images | Loạiinteger | Yêu cầuKhông bắt buộc | Giá trị & giới hạn Tùy thuộc vào mô hình | Mặc định— |
Tổ hợp tư liệu đầu vào
Văn bản thành ảnh · Bắt buộc: prompt
Tham số phương thức và vòng đời
| Tham số | Hợp đồng |
|---|---|
Tham sốmaterial_types | Hợp đồngtext |
Tham sốrequired | Hợp đồngmodel, prompt |
Tham sốoptional_controls | Hợp đồngnull |
Tham sốcontent_type | Hợp đồngapplication/json |
Vòng đời: synchronous_result_then_owned_library
GET /v1/media/tasks/{task_id} · Giá trị task_id thực tế đã trả về hoặc bản ghi trong thư viện nội dung đa phương tiện
GET /v1/media/assets/{asset_id}/content
GET /v1/media/assets
GET /v1/media/assets/{asset_id}
Cấu trúc phương thức và ID là chính xác; khả năng của nhà cung cấp tách biệt với việc cho phép tiếp nhận yêu cầu.
Bảng giá
Mức phí phương thức Ailoot
POST /v1/images/generations- Đầu ra
- 0,0035 US$ mỗi ảnh 1K
- Đầu ra
- 0,0035 US$ mỗi ảnh 2K
Ailoot tạm giữ một khoản ước tính trước yêu cầu. Sau khi có kết quả, phí cuối cùng được quyết toán theo mức sử dụng đo được. Việc quyết toán khi truyền luồng dùng bản ghi mức sử dụng cuối cùng. Cách hoạt động của cơ chế tạm giữ và quyết toán →
Ví dụ yêu cầu
Ailoot · Ảnh
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": "minimax/image-01", "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': 'minimax/image-01', '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": "minimax/image-01", "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");
Nhận và lưu kết quả
Ailoot · Ảnh
Tải xuống từng ảnh trả về hoặc lưu nội dung Base64 của ảnh
GET /v1/media/tasks/{task_id}GET /v1/media/assets/{asset_id}/contentGET /v1/media/assetsGET /v1/media/assets/{asset_id}
Lưu tất cả kết quả đã hoàn tất
Lưu mọi ảnh đã hoàn tất; truy xuất từng URL trả về hoặc giải mã nội dung Base64 của ảnh.
Lưu mọi phần tử dữ liệu. Giải mã từng b64_json hoặc tải xuống từ mọi URL có chữ ký đã trả về. Chọn phần mở rộng tệp dựa trên MIME/nội dung byte thực tế.
Nếu cần kiểm tra phản hồi gốc
Nếu kết quả tạo hoặc chỉnh sửa ảnh cần được kiểm tra, giữ lại operation_id/X-Client-Request-ID gốc và thông tin kết quả đã trả về. Khôi phục các kết quả hiện có thuộc quyền sở hữu của bạn qua thư viện nội dung đa phương tiện bằng các giá trị task_id hoặc asset_id thực tế. Không gửi lại yêu cầu tạo/chỉnh sửa ảnh hoặc tạo URL truy vấn trạng thái từ operation_id.
Trường phản hồi
| Trường | Loại |
|---|---|
Trườngcreated | Loạiinteger |
Trườngdata[].url | Loạistring |
Trườngdata[].b64_json | Loạibase64 string |
Trườngusage | Loạiobject |
Lỗi và bước tiếp theo
| Phản hồi | Điều kiện | Bước tiếp theo |
|---|---|---|
Phản hồi400 · invalid_request_error | Điều kiệnTrường bắt buộc, cách biểu diễn tài liệu hoặc giá trị tham số không hợp lệ | Bước tiếp theoSửa các trường được chỉ ra trước khi gửi yêu cầu tạo mới. |
Phản hồiserver_error | Điều kiệnPhản hồi trả về cho biết thao tác hoặc kết quả cần được kiểm tra | Bước tiếp theoGiữ lại ID thao tác/tác vụ gốc đã trả về, các header của yêu cầu và toàn bộ phản hồi; tiếp tục truy xuất thao tác gốc đó bằng các phương thức được hỗ trợ. Không gửi lại yêu cầu tạo. |
Bí danh
Bí danh mô hình
Ailoot image-01, minimax-image, minimax-image-latest, minimax/image-01
Bí danh đường dẫn phương thức
Dùng các đường dẫn phương thức hiển thị ở trên.
ID gọi liên quan
image-01, minimax-image, minimax-image-latest, minimax/image-01
FAQ · image-01
- Có những đầu vào và kết quả nào?
POST /v1/images/generations·image-01:text→imagePOST /v1/images/generations·minimax-image:text→imagePOST /v1/images/generations·minimax-image-latest:text→imagePOST /v1/images/generations·minimax/image-01:text→image- Yêu cầu sử dụng những trường nào?
POST /v1/images/generations·image-01:model,prompt,n,response_format,streamPOST /v1/images/generations·minimax-image:model,prompt,n,response_format,streamPOST /v1/images/generations·minimax-image-latest:model,prompt,n,response_format,streamPOST /v1/images/generations·minimax/image-01:model,prompt,n,response_format,stream- Áp dụng những giới hạn nào?
POST /v1/images/generations·image-01:n.minimum:1POST /v1/images/generations·minimax-image:n.minimum:1POST /v1/images/generations·minimax-image-latest:n.minimum:1POST /v1/images/generations·minimax/image-01:n.minimum:1