{
  "aboutHtml": "<p>Wan2.7-Image-Pro là mô hình của Alibaba để tạo ảnh từ văn bản. Thẻ Ailoot hiện tại công bố đầu vào văn bản và kết quả dạng ảnh. Nhà sản xuất còn cung cấp chỉnh sửa, kết hợp ảnh tham chiếu và thay đổi cục bộ; các cách này cần hỗ trợ đầu vào ảnh riêng và không được cung cấp qua phương thức hiện tại của thẻ.</p><p>Trong chế độ dùng ảnh tham chiếu của nhà sản xuất, có thể gửi tối đa chín ảnh nguồn và mô tả những yếu tố cần sử dụng từ mỗi ảnh. Khi chỉnh sửa, mô hình giữ đối tượng chính, thay đổi các chi tiết đã chọn hoặc ghép nhiều tư liệu thành bố cục mới. Để định hướng thay đổi chính xác hơn, có thể xác định tối đa hai vùng hình chữ nhật trên một ảnh đầu vào.</p><h4>Bảng màu và yêu cầu phức tạp</h4><p>Ngoài các chuỗi liên tiếp, có thể đặt bảng màu gồm 3–10 màu. Chế độ suy luận dành cho việc tạo ảnh thông thường từ văn bản, không dùng ảnh tham chiếu hoặc chuỗi liên tiếp: mô hình phân tích trước mô tả của cảnh.</p><p>Trong đặc tả Alibaba, đầu ra thông thường gồm từ một đến bốn ảnh. Với chuỗi theo cốt truyện, có thể đặt giới hạn trên tối đa 12 ảnh; mô hình chọn số lượng thực tế theo yêu cầu. Chuỗi có thể sử dụng văn bản và ảnh tham chiếu để giữ các đặc điểm chung của nhân vật và diễn biến câu chuyện liền mạch. Bảng màu và suy luận không được áp dụng ở chế độ này.</p><h4>Độ phân giải phụ thuộc vào chế độ</h4><p>Mức 4K được hỗ trợ khi tạo ảnh thông thường từ văn bản, không dùng ảnh tham chiếu hoặc chuỗi liên tiếp. Chỉnh sửa dựa trên ảnh và chuỗi liên tiếp bị giới hạn ở mức 2K. Các ký hiệu này xác định diện tích pixel, không phải độ dài bằng nhau của mỗi cạnh. Có thể chọn tỷ lệ khung hình từ 1:8 đến 8:1; khi chỉnh sửa với độ phân giải đặt sẵn, tỷ lệ khung hình theo ảnh tham chiếu cuối cùng. Kết quả được lưu ở định dạng PNG.</p><p>Với những cách sử dụng ảnh đầu vào, Alibaba chấp nhận JPEG, JPG, PNG không có độ trong suốt, BMP và WEBP. Các giới hạn là 20 MB mỗi tệp, từ 240 đến 8000 pixel cho mỗi chiều và tỷ lệ từ 1:8 đến 8:1. Yêu cầu bằng văn bản hỗ trợ tiếng Trung và tiếng Anh; tối đa 5000 ký tự, phần dư bị cắt bỏ. Phiên bản này không có mô tả phủ định hoặc mở rộng yêu cầu. Hạt giống ngẫu nhiên giúp giữ nét tương đồng giữa các phương án, nhưng không bảo đảm lặp lại chính xác.</p>",
  "aboutText": "Wan2.7-Image-Pro là mô hình của Alibaba để tạo ảnh từ văn bản. Thẻ Ailoot hiện tại công bố đầu vào văn bản và kết quả dạng ảnh. Nhà sản xuất còn cung cấp chỉnh sửa, kết hợp ảnh tham chiếu và thay đổi cục bộ; các cách này cần hỗ trợ đầu vào ảnh riêng và không được cung cấp qua phương thức hiện tại của thẻ.\n\nTrong chế độ dùng ảnh tham chiếu của nhà sản xuất, có thể gửi tối đa chín ảnh nguồn và mô tả những yếu tố cần sử dụng từ mỗi ảnh. Khi chỉnh sửa, mô hình giữ đối tượng chính, thay đổi các chi tiết đã chọn hoặc ghép nhiều tư liệu thành bố cục mới. Để định hướng thay đổi chính xác hơn, có thể xác định tối đa hai vùng hình chữ nhật trên một ảnh đầu vào.\n\n### Bảng màu và yêu cầu phức tạp\n\nNgoài các chuỗi liên tiếp, có thể đặt bảng màu gồm 3–10 màu. Chế độ suy luận dành cho việc tạo ảnh thông thường từ văn bản, không dùng ảnh tham chiếu hoặc chuỗi liên tiếp: mô hình phân tích trước mô tả của cảnh.\n\nTrong đặc tả Alibaba, đầu ra thông thường gồm từ một đến bốn ảnh. Với chuỗi theo cốt truyện, có thể đặt giới hạn trên tối đa 12 ảnh; mô hình chọn số lượng thực tế theo yêu cầu. Chuỗi có thể sử dụng văn bản và ảnh tham chiếu để giữ các đặc điểm chung của nhân vật và diễn biến câu chuyện liền mạch. Bảng màu và suy luận không được áp dụng ở chế độ này.\n\n### Độ phân giải phụ thuộc vào chế độ\n\nMức 4K được hỗ trợ khi tạo ảnh thông thường từ văn bản, không dùng ảnh tham chiếu hoặc chuỗi liên tiếp. Chỉnh sửa dựa trên ảnh và chuỗi liên tiếp bị giới hạn ở mức 2K. Các ký hiệu này xác định diện tích pixel, không phải độ dài bằng nhau của mỗi cạnh. Có thể chọn tỷ lệ khung hình từ 1:8 đến 8:1; khi chỉnh sửa với độ phân giải đặt sẵn, tỷ lệ khung hình theo ảnh tham chiếu cuối cùng. Kết quả được lưu ở định dạng PNG.\n\nVới những cách sử dụng ảnh đầu vào, Alibaba chấp nhận JPEG, JPG, PNG không có độ trong suốt, BMP và WEBP. Các giới hạn là 20 MB mỗi tệp, từ 240 đến 8000 pixel cho mỗi chiều và tỷ lệ từ 1:8 đến 8:1. Yêu cầu bằng văn bản hỗ trợ tiếng Trung và tiếng Anh; tối đa 5000 ký tự, phần dư bị cắt bỏ. Phiên bản này không có mô tả phủ định hoặc mở rộng yêu cầu. Hạt giống ngẫu nhiên giúp giữ nét tương đồng giữa các phương án, nhưng không bảo đảm lặp lại chính xác.",
  "editorialOverlay": {
    "copy_fields": null,
    "copy_sha256": null,
    "copy_source": null,
    "html_sha256": "96c0a5821084b07c92ae402f36dfb191a4776314d40fb6dfa71e55d3fd726f43",
    "module_sha256": "ee9dc1c50b1e6a8fb7fa062030fcb4646b9aaaeb08be513b723a5a92a7290f06",
    "raw_model_unchanged": true,
    "schema": "ailoot-native-model-editorial-v1"
  },
  "locale": "vi",
  "methods": [
    {
      "html": "<div class=\"sheet-head\"><span class=\"mav\" aria-hidden=\"true\">Al</span><h2 id=\"sheet-title\">wan2.7-image-pro</h2><button class=\"icon-btn\" type=\"button\" data-close-sheet aria-label=\"Đóng\">×</button></div><div class=\"idline\"><span>Alibaba /</span><code>wan2.7-image-pro</code><button type=\"button\" id=\"copy-id\">Sao chép ID</button></div><nav class=\"card-jump-nav\" aria-label=\"Các phần của thẻ mô hình\"><button type=\"button\" data-card-jump=\"overview\">Bắt đầu</button><button type=\"button\" data-card-jump=\"methods\">Đầu vào &amp; phương thức</button><button type=\"button\" data-card-jump=\"pricing\">Bảng giá</button><button type=\"button\" data-card-jump=\"examples\">Ví dụ</button><button type=\"button\" data-card-jump=\"results\">Kết quả</button><button type=\"button\" data-card-jump=\"aliases\">Bí danh</button></nav><div class=\"card-method-tabs\" role=\"tablist\" aria-label=\"Phương thức API\"><button type=\"button\" role=\"tab\" tabindex=\"0\" aria-controls=\"card-method-content\" aria-selected=\"true\" id=\"card-method-tab-0\" data-card-method=\"Core|images|/v1/images/generations|wan2.7-image-pro\">Ảnh</button></div><div class=\"idline\"><label for=\"card-model-id\">ID mô hình</label><select class=\"sel\" id=\"card-model-id\" style=\"min-width:0;max-width:100%\"><option value=\"Core|images|/v1/images/generations|wan2.7-image-pro\" selected>wan2.7-image-pro</option><option value=\"Core|images|/v1/images/generations|wan-image\">wan-image</option><option value=\"Core|images|/v1/images/generations|wan-image-latest\">wan-image-latest</option></select></div><div id=\"card-method-content\" role=\"tabpanel\" aria-labelledby=\"card-method-tab-0\"><section class=\"card-section\" data-card-section=\"overview\"><h3 tabindex=\"-1\">Bắt đầu</h3><p class=\"mdesc-full\">Mô hình tạo ảnh từ yêu cầu bằng văn bản. Nhà sản xuất cho phép điều khiển bảng màu và độ phân giải tối đa 4K khi tạo ảnh thông thường từ văn bản.</p><dl class=\"card-io\" data-card-io><div><dt>Đầu vào được chấp nhận</dt><dd>Văn bản</dd></div><div><dt>Kết quả</dt><dd>Ảnh</dd></div></dl><details class=\"card-about\"><summary>Về mô hình</summary><p class=\"note-s\" data-model-method-boundary>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.</p><div class=\"mabout\" id=\"m-about\"><p>Wan2.7-Image-Pro là mô hình của Alibaba để tạo ảnh từ văn bản. Thẻ Ailoot hiện tại công bố đầu vào văn bản và kết quả dạng ảnh. Nhà sản xuất còn cung cấp chỉnh sửa, kết hợp ảnh tham chiếu và thay đổi cục bộ; các cách này cần hỗ trợ đầu vào ảnh riêng và không được cung cấp qua phương thức hiện tại của thẻ.</p><p>Trong chế độ dùng ảnh tham chiếu của nhà sản xuất, có thể gửi tối đa chín ảnh nguồn và mô tả những yếu tố cần sử dụng từ mỗi ảnh. Khi chỉnh sửa, mô hình giữ đối tượng chính, thay đổi các chi tiết đã chọn hoặc ghép nhiều tư liệu thành bố cục mới. Để định hướng thay đổi chính xác hơn, có thể xác định tối đa hai vùng hình chữ nhật trên một ảnh đầu vào.</p><h4>Bảng màu và yêu cầu phức tạp</h4><p>Ngoài các chuỗi liên tiếp, có thể đặt bảng màu gồm 3–10 màu. Chế độ suy luận dành cho việc tạo ảnh thông thường từ văn bản, không dùng ảnh tham chiếu hoặc chuỗi liên tiếp: mô hình phân tích trước mô tả của cảnh.</p><p>Trong đặc tả Alibaba, đầu ra thông thường gồm từ một đến bốn ảnh. Với chuỗi theo cốt truyện, có thể đặt giới hạn trên tối đa 12 ảnh; mô hình chọn số lượng thực tế theo yêu cầu. Chuỗi có thể sử dụng văn bản và ảnh tham chiếu để giữ các đặc điểm chung của nhân vật và diễn biến câu chuyện liền mạch. Bảng màu và suy luận không được áp dụng ở chế độ này.</p><h4>Độ phân giải phụ thuộc vào chế độ</h4><p>Mức 4K được hỗ trợ khi tạo ảnh thông thường từ văn bản, không dùng ảnh tham chiếu hoặc chuỗi liên tiếp. Chỉnh sửa dựa trên ảnh và chuỗi liên tiếp bị giới hạn ở mức 2K. Các ký hiệu này xác định diện tích pixel, không phải độ dài bằng nhau của mỗi cạnh. Có thể chọn tỷ lệ khung hình từ 1:8 đến 8:1; khi chỉnh sửa với độ phân giải đặt sẵn, tỷ lệ khung hình theo ảnh tham chiếu cuối cùng. Kết quả được lưu ở định dạng PNG.</p><p>Với những cách sử dụng ảnh đầu vào, Alibaba chấp nhận JPEG, JPG, PNG không có độ trong suốt, BMP và WEBP. Các giới hạn là 20 MB mỗi tệp, từ 240 đến 8000 pixel cho mỗi chiều và tỷ lệ từ 1:8 đến 8:1. Yêu cầu bằng văn bản hỗ trợ tiếng Trung và tiếng Anh; tối đa 5000 ký tự, phần dư bị cắt bỏ. Phiên bản này không có mô tả phủ định hoặc mở rộng yêu cầu. Hạt giống ngẫu nhiên giúp giữ nét tương đồng giữa các phương án, nhưng không bảo đảm lặp lại chính xác.</p></div></details></section><section class=\"card-section\" data-card-section=\"methods\"><h3 tabindex=\"-1\">Có trên Ailoot · đầu vào &amp; phương thức</h3><details class=\"card-method\" open><summary><b>Ailoot · Ảnh</b> <code>POST /v1/images/generations</code></summary><dl class=\"method-capabilities\"><div><dt>Đầu vào</dt><dd><code>text</code></dd></div><div><dt>Đầu ra</dt><dd><code>image</code></dd></div><div><dt>Định dạng đầu ra</dt><dd>Tệp ảnh</dd></div></dl><div class=\"tw\" data-card-parameters data-typed-parameters><table><thead><tr><th>Trường</th><th>Loại</th><th>Yêu cầu</th><th>Giá trị &amp; giới hạn</th><th>Mặc định</th></tr></thead><tbody><tr data-parameter-availability=\"source_interface\"><th data-cell-label=\"Trường\" scope=\"row\"><span class=\"card-cell-label\">Trường</span><code class=\"card-field-name\">model</code></th><td data-cell-label=\"Loại\" data-field-type><span class=\"card-cell-label\">Loại</span><code>string</code></td><td data-cell-label=\"Yêu cầu\"><span class=\"card-cell-label\">Yêu cầu</span>Bắt buộc</td><td data-cell-label=\"Giá trị &amp; giới hạn\"><span class=\"card-cell-label\">Giá trị &amp; giới hạn</span><div>wan2.7-image-pro</div></td><td data-cell-label=\"Mặc định\" data-default=\"unspecified\"><span class=\"card-cell-label\">Mặc định</span>—</td></tr><tr data-parameter-availability=\"source_interface\"><th data-cell-label=\"Trường\" scope=\"row\"><span class=\"card-cell-label\">Trường</span><code class=\"card-field-name\">prompt</code></th><td data-cell-label=\"Loại\" data-field-type><span class=\"card-cell-label\">Loại</span><code>string</code></td><td data-cell-label=\"Yêu cầu\"><span class=\"card-cell-label\">Yêu cầu</span>Bắt buộc</td><td data-cell-label=\"Giá trị &amp; giới hạn\"><span class=\"card-cell-label\">Giá trị &amp; giới hạn</span><div>Độ dài tối thiểu: 1</div></td><td data-cell-label=\"Mặc định\" data-default=\"unspecified\"><span class=\"card-cell-label\">Mặc định</span>—</td></tr><tr data-parameter-availability=\"source_interface\"><th data-cell-label=\"Trường\" scope=\"row\"><span class=\"card-cell-label\">Trường</span><code class=\"card-field-name\">n</code></th><td data-cell-label=\"Loại\" data-field-type><span class=\"card-cell-label\">Loại</span><code>integer</code></td><td data-cell-label=\"Yêu cầu\"><span class=\"card-cell-label\">Yêu cầu</span>Không bắt buộc</td><td data-cell-label=\"Giá trị &amp; giới hạn\"><span class=\"card-cell-label\">Giá trị &amp; giới hạn</span><div>Tối thiểu: 1</div></td><td data-cell-label=\"Mặc định\" data-default=\"known\"><span class=\"card-cell-label\">Mặc định</span>1</td></tr><tr data-parameter-availability=\"source_interface\"><th data-cell-label=\"Trường\" scope=\"row\"><span class=\"card-cell-label\">Trường</span><code class=\"card-field-name\">response_format</code></th><td data-cell-label=\"Loại\" data-field-type><span class=\"card-cell-label\">Loại</span><code>string</code></td><td data-cell-label=\"Yêu cầu\"><span class=\"card-cell-label\">Yêu cầu</span>Không bắt buộc</td><td data-cell-label=\"Giá trị &amp; giới hạn\"><span class=\"card-cell-label\">Giá trị &amp; giới hạn</span><div>url, b64_json</div></td><td data-cell-label=\"Mặc định\" data-default=\"unspecified\"><span class=\"card-cell-label\">Mặc định</span>—</td></tr><tr data-parameter-availability=\"source_interface\"><th data-cell-label=\"Trường\" scope=\"row\"><span class=\"card-cell-label\">Trường</span><code class=\"card-field-name\">stream</code></th><td data-cell-label=\"Loại\" data-field-type><span class=\"card-cell-label\">Loại</span><code>boolean</code></td><td data-cell-label=\"Yêu cầu\"><span class=\"card-cell-label\">Yêu cầu</span>Không bắt buộc</td><td data-cell-label=\"Giá trị &amp; giới hạn\"><span class=\"card-cell-label\">Giá trị &amp; giới hạn</span></td><td data-cell-label=\"Mặc định\" data-default=\"known\"><span class=\"card-cell-label\">Mặc định</span>false</td></tr><tr data-parameter-availability=\"model_dependent\"><th data-cell-label=\"Trường\" scope=\"row\"><span class=\"card-cell-label\">Trường</span><code class=\"card-field-name\">size</code></th><td data-cell-label=\"Loại\" data-field-type><span class=\"card-cell-label\">Loại</span><code>string</code></td><td data-cell-label=\"Yêu cầu\"><span class=\"card-cell-label\">Yêu cầu</span>Không bắt buộc</td><td data-cell-label=\"Giá trị &amp; giới hạn\"><span class=\"card-cell-label\">Giá trị &amp; giới hạn</span><div class=\"note-s\">Tùy thuộc vào mô hình</div></td><td data-cell-label=\"Mặc định\" data-default=\"unspecified\"><span class=\"card-cell-label\">Mặc định</span>—</td></tr><tr data-parameter-availability=\"model_dependent\"><th data-cell-label=\"Trường\" scope=\"row\"><span class=\"card-cell-label\">Trường</span><code class=\"card-field-name\">partial_images</code></th><td data-cell-label=\"Loại\" data-field-type><span class=\"card-cell-label\">Loại</span><code>integer</code></td><td data-cell-label=\"Yêu cầu\"><span class=\"card-cell-label\">Yêu cầu</span>Không bắt buộc</td><td data-cell-label=\"Giá trị &amp; giới hạn\"><span class=\"card-cell-label\">Giá trị &amp; giới hạn</span><div class=\"note-s\">Tùy thuộc vào mô hình</div></td><td data-cell-label=\"Mặc định\" data-default=\"unspecified\"><span class=\"card-cell-label\">Mặc định</span>—</td></tr><tr data-parameter-availability=\"different_method\"><th data-cell-label=\"Trường\" scope=\"row\"><span class=\"card-cell-label\">Trường</span><code class=\"card-field-name\">images[].image_url</code></th><td data-cell-label=\"Loại\" data-field-type><span class=\"card-cell-label\">Loại</span><code>string</code></td><td data-cell-label=\"Yêu cầu\"><span class=\"card-cell-label\">Yêu cầu</span>Không hỗ trợ</td><td data-cell-label=\"Giá trị &amp; giới hạn\"><span class=\"card-cell-label\">Giá trị &amp; giới hạn</span><div>Số byte tối đa sau giải mã: 20.971.520</div><div>Loại MIME: image/png, image/jpeg</div><div>Số ảnh tối đa mỗi mảng: 9</div><div>Điều kiện: Một URL thực tế cho mỗi đối tượng images[]. Số phần tử mảng khác với nút lá dạng chuỗi này.</div><div>Áp dụng khi: Chỉ JSON images/edits; JSON images/generations không phân tích các tham chiếu images.</div></td><td data-cell-label=\"Mặc định\" data-default=\"unspecified\"><span class=\"card-cell-label\">Mặc định</span>—</td></tr><tr data-parameter-availability=\"source_interface\"><th data-cell-label=\"Trường\" scope=\"row\"><span class=\"card-cell-label\">Trường</span><code class=\"card-field-name\">image</code></th><td data-cell-label=\"Loại\" data-field-type><span class=\"card-cell-label\">Loại</span><code>file</code></td><td data-cell-label=\"Yêu cầu\"><span class=\"card-cell-label\">Yêu cầu</span>Không bắt buộc</td><td data-cell-label=\"Giá trị &amp; giới hạn\"><span class=\"card-cell-label\">Giá trị &amp; giới hạn</span><div>Số byte tối đa sau giải mã: 20.971.520</div><div>Loại MIME: image/png, image/jpeg</div><div>Áp dụng khi: tạo bằng multipart/form-data</div></td><td data-cell-label=\"Mặc định\" data-default=\"unspecified\"><span class=\"card-cell-label\">Mặc định</span>—</td></tr><tr data-parameter-availability=\"source_interface\"><th data-cell-label=\"Trường\" scope=\"row\"><span class=\"card-cell-label\">Trường</span><code class=\"card-field-name\">image[]</code></th><td data-cell-label=\"Loại\" data-field-type><span class=\"card-cell-label\">Loại</span><code>file[]</code></td><td data-cell-label=\"Yêu cầu\"><span class=\"card-cell-label\">Yêu cầu</span>Không bắt buộc</td><td data-cell-label=\"Giá trị &amp; giới hạn\"><span class=\"card-cell-label\">Giá trị &amp; giới hạn</span><div>Số mục tối đa: 9</div><div>Số byte tối đa sau giải mã: 20.971.520</div><div>Loại MIME: image/png, image/jpeg</div><div>Áp dụng khi: tạo bằng multipart/form-data</div></td><td data-cell-label=\"Mặc định\" data-default=\"unspecified\"><span class=\"card-cell-label\">Mặc định</span>—</td></tr></tbody></table></div><details class=\"card-about\" data-material-combinations><summary>Tổ hợp tư liệu đầu vào</summary><p class=\"note-s\"><b>Văn bản thành ảnh</b> · Bắt buộc: prompt</p><p class=\"note-s\"><b>reference_images_generation</b> · Bắt buộc: prompt</p></details><details class=\"note-s\" data-method-contract><summary>Tham số phương thức và vòng đời</summary><div class=\"tw\" data-card-table=\"contract\"><table><thead><tr><th>Tham số</th><th>Hợp đồng</th></tr></thead><tbody><tr><th data-cell-label=\"Tham số\" scope=\"row\"><span class=\"card-cell-label\">Tham số</span><code>material_types</code></th><td data-cell-label=\"Hợp đồng\"><span class=\"card-cell-label\">Hợp đồng</span>text</td></tr><tr><th data-cell-label=\"Tham số\" scope=\"row\"><span class=\"card-cell-label\">Tham số</span><code>required</code></th><td data-cell-label=\"Hợp đồng\"><span class=\"card-cell-label\">Hợp đồng</span>model, prompt</td></tr><tr><th data-cell-label=\"Tham số\" scope=\"row\"><span class=\"card-cell-label\">Tham số</span><code>optional_controls</code></th><td data-cell-label=\"Hợp đồng\"><span class=\"card-cell-label\">Hợp đồng</span>null</td></tr><tr><th data-cell-label=\"Tham số\" scope=\"row\"><span class=\"card-cell-label\">Tham số</span><code>content_type</code></th><td data-cell-label=\"Hợp đồng\"><span class=\"card-cell-label\">Hợp đồng</span>application/json</td></tr></tbody></table></div><p>Vòng đời: <code>synchronous_result_then_owned_library</code></p><p class=\"note-s\"><code>GET /v1/media/tasks/{task_id}</code> · 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</p><p class=\"note-s\"><code>GET /v1/media/assets/{asset_id}/content</code></p><p class=\"note-s\"><code>GET /v1/media/assets</code></p><p class=\"note-s\"><code>GET /v1/media/assets/{asset_id}</code></p><p class=\"note-s\">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.</p></details></details></section><section class=\"card-section\" data-card-section=\"pricing\"><h3 tabindex=\"-1\">Bảng giá</h3><h4>Mức phí phương thức Ailoot</h4><section class=\"meth\" data-route=\"Core\"><header><b><span class=\"alias\">Ailoot</span> Ảnh</b><code>POST /v1/images/generations</code></header><dl><div><dt>Đầu ra</dt><dd>0,075 US$ <em>mỗi ảnh 1K</em></dd></div><div><dt>Đầu ra</dt><dd>0,075 US$ <em>mỗi ảnh 2K</em></dd></div></dl></section><p class=\"note-s\">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. <a href=\"/docs/vi/billing/reserve/\">Cách hoạt động của cơ chế tạm giữ và quyết toán →</a></p><div data-declared-reference-pricing><h4>Chi tiết giá cước tham chiếu</h4><p class=\"note-s\">Biểu tham chiếu cấp mô hình không thay đổi việc chọn phương thức, báo giá hoặc khoản phí. Khoản phí đang áp dụng dùng mức phí phương thức Ailoot đã chọn.</p><details class=\"card-price-reference\" data-declared-reference-group data-client-selectable=\"false\"><summary>wan2.7-image-pro</summary><h4>Giá theo cấu hình</h4><div class=\"tw\" data-pricing-profiles><table><thead><tr><th>Cấu hình</th><th>Điều kiện tính phí</th><th>Phí</th></tr></thead><tbody><tr><th data-cell-label=\"Cấu hình\" scope=\"row\"><span class=\"card-cell-label\">Cấu hình</span>wan2.7-image-pro · Cấu hình mặc định</th><td data-cell-label=\"Điều kiện tính phí\"><span class=\"card-cell-label\">Điều kiện tính phí</span>Cấu hình mặc định</td><td data-cell-label=\"Phí\"><span class=\"card-cell-label\">Phí</span><div><span>Đầu vào · Đầu vào</span> <b>0,00 US$</b> <span class=\"price-unit\">mỗi lần gọi</span></div><div><span>Đầu ra · Đầu ra</span> <b>0,16 US$</b> <span class=\"price-unit\">mỗi lần gọi</span></div></td></tr></tbody></table></div></details></div></section><section class=\"card-section\" data-card-section=\"examples\"><h3 tabindex=\"-1\">Ví dụ yêu cầu</h3><h4>Ailoot · Ảnh</h4><div class=\"code-group\"><div class=\"cg-bar\"><div class=\"cg-tabs\" role=\"tablist\" aria-label=\"Các phiên bản mã\"><button class=\"cg-tab\" id=\"model-code-104-tab-0\" role=\"tab\" type=\"button\" aria-controls=\"model-code-104-panel-0\" aria-selected=\"true\" tabindex=\"0\">curl</button><button class=\"cg-tab\" id=\"model-code-104-tab-1\" role=\"tab\" type=\"button\" aria-controls=\"model-code-104-panel-1\" aria-selected=\"false\" tabindex=\"-1\">Python SDK</button><button class=\"cg-tab\" id=\"model-code-104-tab-2\" role=\"tab\" type=\"button\" aria-controls=\"model-code-104-panel-2\" aria-selected=\"false\" tabindex=\"-1\">Node.js SDK</button></div><div class=\"cg-tools\"><button class=\"cg-btn cg-copy\" type=\"button\" aria-label=\"Sao chép mã\"><svg class=\"cp\" viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.4\"><rect x=\"5.25\" y=\"5.25\" width=\"8.5\" height=\"8.5\" rx=\"1.75\"/><path d=\"M10.75 5.25V3.5a1.25 1.25 0 0 0-1.25-1.25H3.5A1.25 1.25 0 0 0 2.25 3.5v6a1.25 1.25 0 0 0 1.25 1.25h1.75\"/></svg><svg class=\"ok\" viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.4\"><path d=\"m3 8.5 3.25 3.25L13 5\"/></svg></button></div></div><div class=\"cg-body\"><div class=\"cg-pane\" id=\"model-code-104-panel-0\" role=\"tabpanel\" aria-labelledby=\"model-code-104-tab-0\"><pre data-lang=\"bash\"><code>set -eu\n: &quot;${AILOOT_API_KEY:?Set your Ailoot API key}&quot;\nexport AILOOT_API_KEY\nexport AILOOT_API_KEY\n: &quot;${AILOOT_PROMPT_FILE:?Set your actual UTF-8 image brief}&quot;\nexport AILOOT_PROMPT_FILE\npython3 - &lt;&lt;&#39;PY_REQUEST&#39;\nimport json,os\nfrom pathlib import Path\np=json.loads(&#39;{&quot;model&quot;: &quot;wan2.7-image-pro&quot;, &quot;prompt&quot;: &quot;&quot;}&#39;)\nf=Path(os.environ[&quot;AILOOT_PROMPT_FILE&quot;])\nif not f.is_file():raise SystemExit(&quot;Choose your actual UTF-8 brief&quot;)\np[&#39;prompt&#39;]=f.read_text(encoding=&quot;utf-8&quot;)\nif not p[&#39;prompt&#39;].strip():raise SystemExit(&quot;Brief must contain text&quot;)\nPath(&quot;request.json&quot;).write_text(json.dumps(p,ensure_ascii=False))\nPY_REQUEST\ncurl --fail-with-body --silent --show-error https://api.ailoot.ai/v1/images/generations \\\n  -H &quot;Authorization: Bearer $AILOOT_API_KEY&quot; -H &#39;Content-Type: application/json&#39; \\\n  --data-binary @request.json -D response-headers.txt -o result.json\npython3 - &lt;&lt;&#39;PY_RESULT&#39;\nimport base64, json, os, subprocess\nfrom pathlib import Path\nfrom urllib.parse import urlsplit, urljoin\n\ndef save_images(items):\n    if not items: raise SystemExit(&quot;No completed images; retain the full response&quot;)\n    for index, item in enumerate(items):\n        encoded=item.get(&quot;b64_json&quot;)\n        uri=item.get(&quot;url&quot;, &quot;&quot;)\n        if not encoded and uri.startswith(&quot;data:image/&quot;):\n            header, separator, encoded=uri.partition(&quot;,&quot;)\n            if not separator or &quot;;base64&quot; not in header: raise SystemExit(&quot;Unsupported image data URI&quot;)\n        if encoded:\n            raw=base64.b64decode(encoded,validate=True)\n        elif uri:\n            uri=urljoin(&quot;https://api.ailoot.ai&quot;,uri)\n            parsed=urlsplit(uri)\n            if parsed.scheme!=&quot;https&quot; or not parsed.netloc or parsed.username or parsed.password:\n                raise SystemExit(&quot;Invalid returned image URL&quot;)\n            owned=parsed.netloc==&quot;api.ailoot.ai&quot; and parsed.path.startswith(&quot;/v1/media/assets/&quot;) and parsed.path.endswith(&quot;/content&quot;)\n            args=[&quot;curl&quot;,&quot;--fail-with-body&quot;,&quot;--silent&quot;,&quot;--show-error&quot;,uri]\n            if owned: args += [&quot;-H&quot;,&quot;Authorization: Bearer &quot;+os.environ[&quot;AILOOT_API_KEY&quot;]]\n            temporary=Path(f&quot;image-{index}.bin&quot;)\n            subprocess.run(args+[&quot;-o&quot;,str(temporary)],check=True)\n            raw=temporary.read_bytes()\n            temporary.unlink()\n        else: raise SystemExit(&quot;Image has neither bytes nor URL&quot;)\n        if not raw: raise SystemExit(&quot;Empty image result&quot;)\n        ext=&quot;png&quot; if raw.startswith(b&quot;\\x89PNG&quot;) else &quot;jpg&quot; if raw.startswith(b&quot;\\xff\\xd8&quot;) else &quot;webp&quot; if raw[:4]==b&quot;RIFF&quot; and raw[8:12]==b&quot;WEBP&quot; else &quot;svg&quot; if raw.lstrip().startswith((b&quot;&lt;svg&quot;,b&quot;&lt;?xml&quot;)) else &quot;bin&quot;\n        Path(f&quot;image-{index}.{ext}&quot;).write_bytes(raw)\n    print(&quot;Every returned image saved; complete response metadata retained&quot;)\nsave_images(json.loads(Path(&quot;result.json&quot;).read_text())[&quot;data&quot;])\nPY_RESULT\n</code></pre></div><div class=\"cg-pane\" id=\"model-code-104-panel-1\" role=\"tabpanel\" aria-labelledby=\"model-code-104-tab-1\" hidden><pre data-lang=\"python\"><code>from openai import OpenAI\nimport base64, json, os, subprocess\nfrom pathlib import Path\nfrom urllib.parse import urlsplit, urljoin\n\ndef save_images(items):\n    if not items: raise SystemExit(&quot;No completed images; retain the full response&quot;)\n    for index, item in enumerate(items):\n        encoded=item.get(&quot;b64_json&quot;)\n        uri=item.get(&quot;url&quot;, &quot;&quot;)\n        if not encoded and uri.startswith(&quot;data:image/&quot;):\n            header, separator, encoded=uri.partition(&quot;,&quot;)\n            if not separator or &quot;;base64&quot; not in header: raise SystemExit(&quot;Unsupported image data URI&quot;)\n        if encoded:\n            raw=base64.b64decode(encoded,validate=True)\n        elif uri:\n            uri=urljoin(&quot;https://api.ailoot.ai&quot;,uri)\n            parsed=urlsplit(uri)\n            if parsed.scheme!=&quot;https&quot; or not parsed.netloc or parsed.username or parsed.password:\n                raise SystemExit(&quot;Invalid returned image URL&quot;)\n            owned=parsed.netloc==&quot;api.ailoot.ai&quot; and parsed.path.startswith(&quot;/v1/media/assets/&quot;) and parsed.path.endswith(&quot;/content&quot;)\n            args=[&quot;curl&quot;,&quot;--fail-with-body&quot;,&quot;--silent&quot;,&quot;--show-error&quot;,uri]\n            if owned: args += [&quot;-H&quot;,&quot;Authorization: Bearer &quot;+os.environ[&quot;AILOOT_API_KEY&quot;]]\n            temporary=Path(f&quot;image-{index}.bin&quot;)\n            subprocess.run(args+[&quot;-o&quot;,str(temporary)],check=True)\n            raw=temporary.read_bytes()\n            temporary.unlink()\n        else: raise SystemExit(&quot;Image has neither bytes nor URL&quot;)\n        if not raw: raise SystemExit(&quot;Empty image result&quot;)\n        ext=&quot;png&quot; if raw.startswith(b&quot;\\x89PNG&quot;) else &quot;jpg&quot; if raw.startswith(b&quot;\\xff\\xd8&quot;) else &quot;webp&quot; if raw[:4]==b&quot;RIFF&quot; and raw[8:12]==b&quot;WEBP&quot; else &quot;svg&quot; if raw.lstrip().startswith((b&quot;&lt;svg&quot;,b&quot;&lt;?xml&quot;)) else &quot;bin&quot;\n        Path(f&quot;image-{index}.{ext}&quot;).write_bytes(raw)\n    print(&quot;Every returned image saved; complete response metadata retained&quot;)\n\nf=Path(os.environ[&quot;AILOOT_PROMPT_FILE&quot;])\nif not f.is_file():raise SystemExit(&quot;Set your actual UTF-8 image brief file&quot;)\nrequest={&#39;model&#39;: &#39;wan2.7-image-pro&#39;, &#39;prompt&#39;: &#39;&#39;}\nrequest[&quot;prompt&quot;]=f.read_text(encoding=&quot;utf-8&quot;)\nclient=OpenAI(base_url=&quot;https://api.ailoot.ai/v1&quot;,api_key=os.environ[&quot;AILOOT_API_KEY&quot;],max_retries=0)\nresult=client.images.generate(**request)\nPath(&quot;sdk-result.txt&quot;).write_text(str(result),encoding=&quot;utf-8&quot;)\nsave_images([{&quot;b64_json&quot;:getattr(item,&quot;b64_json&quot;,None),&quot;url&quot;:getattr(item,&quot;url&quot;,None)} for item in result.data])\n</code></pre></div><div class=\"cg-pane\" id=\"model-code-104-panel-2\" role=\"tabpanel\" aria-labelledby=\"model-code-104-tab-2\" hidden><pre data-lang=\"js\"><code>import OpenAI from &quot;openai&quot;;\nimport { readFileSync, writeFileSync } from &quot;node:fs&quot;;\nconst key=process.env.AILOOT_API_KEY;\nif(!key) throw new Error(&quot;Set your actual Ailoot API key&quot;);\nconst client=new OpenAI({baseURL:&quot;https://api.ailoot.ai/v1&quot;,apiKey:key,maxRetries:0});\nconst request={&quot;model&quot;: &quot;wan2.7-image-pro&quot;, &quot;prompt&quot;: &quot;&quot;};\nif(!process.env.AILOOT_PROMPT_FILE)throw new Error(&quot;Set your actual UTF-8 image brief file&quot;);\nrequest.prompt=readFileSync(process.env.AILOOT_PROMPT_FILE,&quot;utf8&quot;);\nconst result=await client.images.generate(request);\nwriteFileSync(&quot;sdk-result.json&quot;,JSON.stringify(result,null,2));\nif(!result.data?.length) throw new Error(&quot;No completed images&quot;);\nfor(let index=0;index&lt;result.data.length;index++) {\n  const item=result.data[index];let encoded=item.b64_json,uri=item.url||&quot;&quot;,raw;\n  if(!encoded &amp;&amp; uri.startsWith(&quot;data:image/&quot;)) {\n    const comma=uri.indexOf(&quot;,&quot;);if(comma&lt;0 || !uri.slice(0,comma).includes(&quot;;base64&quot;)) throw new Error(&quot;Unsupported image data URI&quot;);\n    encoded=uri.slice(comma+1);\n  }\n  if(encoded) {\n    if(encoded.length%4!==0 || !/^[A-Za-z0-9+/]*={0,2}$/.test(encoded)) throw new Error(&quot;Invalid Base64&quot;);\n    raw=Buffer.from(encoded,&quot;base64&quot;);\n  } else if(uri) {\n    const u=new URL(uri,&quot;https://api.ailoot.ai&quot;);\n    if(u.protocol!==&quot;https:&quot; || u.username || u.password) throw new Error(&quot;Invalid returned URL&quot;);\n    const owned=u.origin===&quot;https://api.ailoot.ai&quot; &amp;&amp; u.pathname.startsWith(&quot;/v1/media/assets/&quot;) &amp;&amp; u.pathname.endsWith(&quot;/content&quot;);\n    const response=await fetch(u,{headers:owned?{Authorization:&quot;Bearer &quot;+key}:{},redirect:&quot;manual&quot;});\n    if(!response.ok) throw new Error(&quot;Image content download failed: &quot;+response.status);\n    raw=Buffer.from(await response.arrayBuffer());\n  } else throw new Error(&quot;Image has neither bytes nor URL&quot;);\n  if(!raw.length) throw new Error(&quot;Empty image result&quot;);\n  const ext=raw.subarray(0,4).equals(Buffer.from([137,80,78,71]))?&quot;png&quot;:raw[0]===255&amp;&amp;raw[1]===216?&quot;jpg&quot;:raw.toString(&quot;ascii&quot;,0,4)===&quot;RIFF&quot;&amp;&amp;raw.toString(&quot;ascii&quot;,8,12)===&quot;WEBP&quot;?&quot;webp&quot;:raw.toString(&quot;utf8&quot;).trimStart().startsWith(&quot;&lt;svg&quot;)||raw.toString(&quot;utf8&quot;).trimStart().startsWith(&quot;&lt;?xml&quot;)?&quot;svg&quot;:&quot;bin&quot;;\n  writeFileSync(`image-${index}.${ext}`,raw);\n}\nconsole.log(&quot;Every returned image saved; sdk-result.json retains complete metadata&quot;);\n</code></pre></div></div></div></section><section class=\"card-section\" data-card-section=\"results\"><h3 tabindex=\"-1\">Nhận và lưu kết quả</h3><h4>Ailoot · Ảnh</h4><p class=\"note-s\">Tải xuống từng ảnh trả về hoặc lưu nội dung Base64 của ảnh</p><ul class=\"card-result-paths\"><li><code>GET /v1/media/tasks/{task_id}</code></li><li><code>GET /v1/media/assets/{asset_id}/content</code></li><li><code>GET /v1/media/assets</code></li><li><code>GET /v1/media/assets/{asset_id}</code></li></ul><div class=\"card-result-process\" data-all-results><h5>Lưu tất cả kết quả đã hoàn tất</h5><p class=\"note-s\">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.</p><p class=\"note-s\">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ế.</p></div><div class=\"card-result-process\" data-unknown-recovery><h5>Nếu cần kiểm tra phản hồi gốc</h5><p class=\"note-s\">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.</p></div><details class=\"card-about\" data-output-fields><summary>Trường phản hồi</summary><div class=\"tw\" data-card-table=\"output\"><table><thead><tr><th>Trường</th><th>Loại</th></tr></thead><tbody><tr><th data-cell-label=\"Trường\" scope=\"row\"><span class=\"card-cell-label\">Trường</span><code class=\"card-field-name\">created</code></th><td data-cell-label=\"Loại\" data-field-type><span class=\"card-cell-label\">Loại</span>integer</td></tr><tr><th data-cell-label=\"Trường\" scope=\"row\"><span class=\"card-cell-label\">Trường</span><code class=\"card-field-name\">data[].url</code></th><td data-cell-label=\"Loại\" data-field-type><span class=\"card-cell-label\">Loại</span>string</td></tr><tr><th data-cell-label=\"Trường\" scope=\"row\"><span class=\"card-cell-label\">Trường</span><code class=\"card-field-name\">data[].b64_json</code></th><td data-cell-label=\"Loại\" data-field-type><span class=\"card-cell-label\">Loại</span>base64 string</td></tr><tr><th data-cell-label=\"Trường\" scope=\"row\"><span class=\"card-cell-label\">Trường</span><code class=\"card-field-name\">usage</code></th><td data-cell-label=\"Loại\" data-field-type><span class=\"card-cell-label\">Loại</span>object</td></tr></tbody></table></div></details><details class=\"card-about\" data-method-errors><summary>Lỗi và bước tiếp theo</summary><div class=\"tw\" data-card-table=\"errors\"><table><thead><tr><th>Phản hồi</th><th>Điều kiện</th><th>Bước tiếp theo</th></tr></thead><tbody><tr><th data-cell-label=\"Phản hồi\" scope=\"row\"><span class=\"card-cell-label\">Phản hồi</span>400 · <code>invalid_request_error</code></th><td data-cell-label=\"Điều kiện\"><span class=\"card-cell-label\">Điều kiện</span>Trườ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ệ</td><td data-cell-label=\"Bước tiếp theo\"><span class=\"card-cell-label\">Bước tiếp theo</span>Sửa các trường được chỉ ra trước khi gửi yêu cầu tạo mới.</td></tr><tr><th data-cell-label=\"Phản hồi\" scope=\"row\"><span class=\"card-cell-label\">Phản hồi</span><code>server_error</code></th><td data-cell-label=\"Điều kiện\"><span class=\"card-cell-label\">Điều kiện</span>Phản hồi trả về cho biết thao tác hoặc kết quả cần được kiểm tra</td><td data-cell-label=\"Bước tiếp theo\"><span class=\"card-cell-label\">Bước tiếp theo</span>Giữ 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.</td></tr></tbody></table></div></details></section><section class=\"card-section\" data-card-section=\"aliases\"><h3 tabindex=\"-1\">Bí danh</h3><h4>Bí danh mô hình</h4><p class=\"note-s\"><span data-model-alias-route=\"Core\"><b>Ailoot</b> <a href=\"#m=wan2.7-image-pro&amp;route=Core&amp;caller=wan2.7-image-pro&amp;fmt=images\"><code>wan2.7-image-pro</code></a>, <a href=\"#m=wan2.7-image-pro&amp;route=Core&amp;caller=wan-image&amp;fmt=images\"><code>wan-image</code></a>, <a href=\"#m=wan2.7-image-pro&amp;route=Core&amp;caller=wan-image-latest&amp;fmt=images\"><code>wan-image-latest</code></a></span></p><h4>Bí danh đường dẫn phương thức</h4><p class=\"note-s\">Dùng các đường dẫn phương thức hiển thị ở trên.</p><h4>ID gọi liên quan</h4><p class=\"note-s\"><a href=\"#m=wan2.7-image-pro&amp;route=Core&amp;caller=wan2.7-image-pro&amp;fmt=images\"><code>wan2.7-image-pro</code></a>, <a href=\"#m=wan2.7-image-pro&amp;route=Core&amp;caller=wan-image&amp;fmt=images\"><code>wan-image</code></a>, <a href=\"#m=wan2.7-image-pro&amp;route=Core&amp;caller=wan-image-latest&amp;fmt=images\"><code>wan-image-latest</code></a></p></section></div>",
      "method_identity": {
        "effective_request_model_id": "wan2.7-image-pro",
        "fmt": "images",
        "http": "POST",
        "path": "/v1/images/generations",
        "request_model_id": "wan2.7-image-pro",
        "route_label": "Core"
      },
      "method_key": "Core|images|/v1/images/generations|wan2.7-image-pro",
      "ordinal": 0,
      "rawMethod": {
        "cache_read": null,
        "cache_write": null,
        "cache_write_1h": null,
        "cache_write_5m": null,
        "conditional_meter": null,
        "contract": {
          "data": {
            "all_results": "Save every data item. Decode each b64_json or fetch every returned signed URL. Select a filename extension from the actual MIME/bytes.",
            "errors": [
              {
                "code": null,
                "condition": "Trườ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ệ",
                "http_status": 400,
                "recovery": "Sửa các trường được chỉ ra trước khi gửi yêu cầu tạo mới.",
                "type": "invalid_request_error"
              },
              {
                "code": null,
                "condition": "Phản hồi trả về cho biết thao tác hoặc kết quả cần được kiểm tra",
                "http_status": null,
                "recovery": "Giữ 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.",
                "type": "server_error"
              }
            ],
            "hints": [
              "Qwen defaultsize1024*1024; Wan defaultsize1K. Wan2.7 Pro4K is supported only without reference inputs.",
              "Explicit dimensions must be positive, at most4096 peraxis, within8:1..1:8 aspect, and the exact model/input area range.",
              "The Alibaba image adapter rejects mask input and streaming before sending the request.",
              "For this generation method, actual image references are supported as multipart image files. JSONimages[].image_url is read only on images/edits; the leaf value is a string."
            ],
            "ignored_fields": [
              "quality",
              "background",
              "style",
              "output_format",
              "output_compression",
              "moderation",
              "input_fidelity",
              "partial_images without streaming"
            ],
            "lifecycle": {
              "all_results": "Follow everyactualreturnedoutputandownedasset; no result is discardedbecauseindex0orcontent_urlalreadyexists.",
              "assets": [
                {
                  "http": "GET",
                  "path": "/v1/media/assets"
                },
                {
                  "http": "GET",
                  "path": "/v1/media/assets/{asset_id}"
                }
              ],
              "content": [
                {
                  "http": "GET",
                  "path": "/v1/media/assets/{asset_id}/content",
                  "url_source": "exact returned signed URL; never construct token"
                }
              ],
              "mode": "synchronous_result_then_owned_library",
              "operation_id_is_not_task_id": true,
              "status": [
                {
                  "http": "GET",
                  "id_source": "actual returned task_id or media library record",
                  "path": "/v1/media/tasks/{task_id}"
                }
              ],
              "unknown": "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."
            },
            "material_combinations": [
              {
                "content_type": "application/json",
                "ignored_reference_field": "JSONgeneration images[] is not parsed; images[].image_url belongs to a separately supported JSONedit profile.",
                "mask": false,
                "mode": "text_to_image",
                "reference_images": false,
                "required": [
                  "prompt"
                ],
                "supplied_materials": [
                  "UTF8 prompt"
                ]
              },
              {
                "content_type": "multipart/form-data",
                "mask": false,
                "maximum_decoded_bytes_per_image": 20971520,
                "maximum_reference_images": 9,
                "mime_types": [
                  "image/png",
                  "image/jpeg"
                ],
                "minimum_reference_images": 0,
                "mode": "reference_images_generation",
                "optional_file_fields": [
                  "image",
                  "image[]",
                  "image[index]"
                ],
                "reference_images": true,
                "required": [
                  "prompt"
                ],
                "supplied_materials": [
                  "UTF8 prompt",
                  "actual PNG/JPEG file references"
                ]
              }
            ],
            "media_library": {
              "asset": {
                "fields": [
                  {
                    "description": null,
                    "name": "asset_id",
                    "type": "string"
                  },
                  {
                    "description": null,
                    "name": "task_id",
                    "type": "string"
                  },
                  {
                    "description": null,
                    "name": "output_key",
                    "type": "string"
                  },
                  {
                    "description": null,
                    "name": "family",
                    "type": "string"
                  },
                  {
                    "description": null,
                    "name": "model",
                    "type": "string"
                  },
                  {
                    "description": null,
                    "name": "method",
                    "type": "string"
                  },
                  {
                    "description": null,
                    "name": "status",
                    "type": "string"
                  },
                  {
                    "description": null,
                    "name": "content_type",
                    "type": "string"
                  },
                  {
                    "description": null,
                    "name": "sha256",
                    "type": "string"
                  },
                  {
                    "description": null,
                    "name": "size_bytes",
                    "type": "integer"
                  },
                  {
                    "description": null,
                    "name": "content_url",
                    "type": "string"
                  }
                ],
                "http": "GET",
                "id_source": "actual returned asset_id",
                "path": "/v1/media/assets/{asset_id}"
              },
              "content": {
                "http": "GET",
                "path": "/v1/media/assets/{asset_id}/content",
                "range_header_supported": true,
                "url_source": "Use exact returned signed content_url including its token; do not construct a token."
              },
              "expired_link": {
                "code": "link_expired",
                "http_status": 404,
                "recovery": "Read the asset again to obtain its refreshed signed content_url, then fetch that URL. Do not regenerate."
              },
              "list": {
                "all_pages": "Follow every returned next_cursor, then select records by their actual task_id/output_key.",
                "http": "GET",
                "output_fields": [
                  {
                    "description": null,
                    "name": "object",
                    "type": "string"
                  },
                  {
                    "description": null,
                    "name": "data",
                    "type": "asset[]"
                  },
                  {
                    "description": null,
                    "name": "next_cursor",
                    "type": "string|null"
                  }
                ],
                "parameters": [
                  {
                    "availability": "source_interface",
                    "default": null,
                    "default_known": false,
                    "enum": null,
                    "enum_known": false,
                    "name": "family",
                    "required": false,
                    "type": "string"
                  },
                  {
                    "availability": "source_interface",
                    "default": null,
                    "default_known": false,
                    "enum": null,
                    "enum_known": false,
                    "name": "cursor",
                    "required": false,
                    "type": "string"
                  },
                  {
                    "availability": "source_interface",
                    "default": 20,
                    "default_known": true,
                    "enum": null,
                    "enum_known": false,
                    "maximum": 100,
                    "minimum": 1,
                    "name": "limit",
                    "required": false,
                    "type": "integer"
                  }
                ],
                "path": "/v1/media/assets"
              },
              "revoke": {
                "http": "DELETE",
                "meaning": "Revokes/deletes the existing owned file; this is not generation cancellation.",
                "path": "/v1/media/assets/{asset_id}",
                "pending_status": "revoking",
                "success_statuses": [
                  202,
                  204
                ]
              },
              "task": {
                "http": "GET",
                "id_source": "actual returned task_id or media library record; operation_id is not task_id",
                "path": "/v1/media/tasks/{task_id}"
              }
            },
            "operation_modes": [
              "text_to_image",
              "reference_images_generation_via_multipart"
            ],
            "outputs": {
              "all_results": "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ế.",
              "family": "image",
              "fields": [
                {
                  "description": null,
                  "name": "created",
                  "type": "integer"
                },
                {
                  "description": null,
                  "name": "data[].url",
                  "type": "string"
                },
                {
                  "description": null,
                  "name": "data[].b64_json",
                  "type": "base64 string"
                },
                {
                  "description": null,
                  "name": "usage",
                  "type": "object"
                }
              ],
              "format": "actual validated raster MIME"
            },
            "parameter_conditions": {
              "size": {
                "aspect_ratio_range": [
                  "1:8",
                  "8:1"
                ],
                "default": "1K",
                "max_area_4k_condition": "WanPro and no inputimages",
                "max_dimension": 4096,
                "maximum_area": 16777216,
                "minimum_area": 589824
              }
            },
            "parameters": [
              {
                "availability": "source_interface",
                "default": null,
                "default_known": false,
                "enum": [
                  "wan2.7-image-pro"
                ],
                "enum_known": true,
                "name": "model",
                "required": true,
                "type": "string"
              },
              {
                "availability": "source_interface",
                "default": null,
                "default_known": false,
                "enum": null,
                "enum_known": false,
                "min_length": 1,
                "name": "prompt",
                "required": true,
                "type": "string"
              },
              {
                "availability": "source_interface",
                "default": 1,
                "default_known": true,
                "enum": null,
                "enum_known": false,
                "minimum": 1,
                "name": "n",
                "required": false,
                "type": "integer"
              },
              {
                "availability": "source_interface",
                "default": null,
                "default_known": false,
                "enum": [
                  "url",
                  "b64_json"
                ],
                "enum_known": true,
                "name": "response_format",
                "required": false,
                "type": "string"
              },
              {
                "availability": "source_interface",
                "default": false,
                "default_known": true,
                "enum": null,
                "enum_known": false,
                "name": "stream",
                "required": false,
                "type": "boolean"
              },
              {
                "availability": "model_dependent",
                "default": null,
                "default_known": false,
                "enum": null,
                "enum_known": false,
                "name": "size",
                "required": false,
                "type": "string"
              },
              {
                "availability": "model_dependent",
                "default": null,
                "default_known": false,
                "enum": null,
                "enum_known": false,
                "name": "partial_images",
                "required": false,
                "type": "integer"
              },
              {
                "availability": "different_method",
                "conditions": "Một URL thực tế cho mỗi đối tượng images[]. Số phần tử mảng khác với nút lá dạng chuỗi này.",
                "decoded_max_bytes": 20971520,
                "default": null,
                "default_known": false,
                "enum": null,
                "enum_known": false,
                "maximum_images_per_array": 9,
                "mime_types": [
                  "image/png",
                  "image/jpeg"
                ],
                "name": "images[].image_url",
                "required": false,
                "type": "string",
                "when": "Chỉ JSON images/edits; JSON images/generations không phân tích các tham chiếu images."
              },
              {
                "availability": "source_interface",
                "default": null,
                "default_known": false,
                "enum": null,
                "enum_known": false,
                "maximum_decoded_bytes": 20971520,
                "mime_types": [
                  "image/png",
                  "image/jpeg"
                ],
                "name": "image",
                "required": false,
                "type": "file",
                "when": "tạo bằng multipart/form-data"
              },
              {
                "availability": "source_interface",
                "default": null,
                "default_known": false,
                "enum": null,
                "enum_known": false,
                "maximum_decoded_bytes": 20971520,
                "maximum_items": 9,
                "mime_types": [
                  "image/png",
                  "image/jpeg"
                ],
                "name": "image[]",
                "required": false,
                "type": "file[]",
                "when": "tạo bằng multipart/form-data"
              }
            ],
            "profile_binding": "Exact existing Ailoot model and method; interface constraints below do not assert provider qualification.",
            "unsupported": [
              "images[].file_id",
              "mask.file_id",
              "mask",
              "stream=true",
              "mask input is rejected by this Alibaba adapter"
            ]
          },
          "hints": [
            "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."
          ],
          "input": {
            "content_type": "application/json",
            "material_types": [
              "text"
            ],
            "optional_controls": null,
            "required": [
              "model",
              "prompt"
            ]
          },
          "lifecycle": {
            "assets": [
              {
                "http": "GET",
                "path": "/v1/media/assets"
              },
              {
                "http": "GET",
                "path": "/v1/media/assets/{asset_id}"
              }
            ],
            "content": [
              {
                "http": "GET",
                "path": "/v1/media/assets/{asset_id}/content",
                "url_source": "exact returned signed URL; never construct token"
              }
            ],
            "mode": "synchronous_result_then_owned_library",
            "operation_id_is_not_task_id": true,
            "status": [
              {
                "http": "GET",
                "id_source": "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",
                "path": "/v1/media/tasks/{task_id}"
              }
            ],
            "unknown": "If an image generation or edit result requires a check, keep the original operation_id/X-Client-Request-ID and returned result information. Recover existing owned results through the media library using actual task_id or asset_id values. Do not resubmit the generation/edit request or construct a polling URL from operation_id."
          },
          "method": {
            "http": "POST",
            "path": "/v1/images/generations"
          },
          "operation_modes": [
            "images"
          ],
          "output": {
            "family": [
              "image"
            ],
            "format": null,
            "multioutputs": "retain every actual response output"
          }
        },
        "ctx": null,
        "examples": [
          {
            "code": "set -eu\n: \"${AILOOT_API_KEY:?Set your Ailoot API key}\"\nexport AILOOT_API_KEY\nexport AILOOT_API_KEY\n: \"${AILOOT_PROMPT_FILE:?Set your actual UTF-8 image brief}\"\nexport AILOOT_PROMPT_FILE\npython3 - <<'PY_REQUEST'\nimport json,os\nfrom pathlib import Path\np=json.loads('{\"model\": \"wan2.7-image-pro\", \"prompt\": \"\"}')\nf=Path(os.environ[\"AILOOT_PROMPT_FILE\"])\nif not f.is_file():raise SystemExit(\"Choose your actual UTF-8 brief\")\np['prompt']=f.read_text(encoding=\"utf-8\")\nif not p['prompt'].strip():raise SystemExit(\"Brief must contain text\")\nPath(\"request.json\").write_text(json.dumps(p,ensure_ascii=False))\nPY_REQUEST\ncurl --fail-with-body --silent --show-error https://api.ailoot.ai/v1/images/generations \\\n  -H \"Authorization: Bearer $AILOOT_API_KEY\" -H 'Content-Type: application/json' \\\n  --data-binary @request.json -D response-headers.txt -o result.json\npython3 - <<'PY_RESULT'\nimport base64, json, os, subprocess\nfrom pathlib import Path\nfrom urllib.parse import urlsplit, urljoin\n\ndef save_images(items):\n    if not items: raise SystemExit(\"No completed images; retain the full response\")\n    for index, item in enumerate(items):\n        encoded=item.get(\"b64_json\")\n        uri=item.get(\"url\", \"\")\n        if not encoded and uri.startswith(\"data:image/\"):\n            header, separator, encoded=uri.partition(\",\")\n            if not separator or \";base64\" not in header: raise SystemExit(\"Unsupported image data URI\")\n        if encoded:\n            raw=base64.b64decode(encoded,validate=True)\n        elif uri:\n            uri=urljoin(\"https://api.ailoot.ai\",uri)\n            parsed=urlsplit(uri)\n            if parsed.scheme!=\"https\" or not parsed.netloc or parsed.username or parsed.password:\n                raise SystemExit(\"Invalid returned image URL\")\n            owned=parsed.netloc==\"api.ailoot.ai\" and parsed.path.startswith(\"/v1/media/assets/\") and parsed.path.endswith(\"/content\")\n            args=[\"curl\",\"--fail-with-body\",\"--silent\",\"--show-error\",uri]\n            if owned: args += [\"-H\",\"Authorization: Bearer \"+os.environ[\"AILOOT_API_KEY\"]]\n            temporary=Path(f\"image-{index}.bin\")\n            subprocess.run(args+[\"-o\",str(temporary)],check=True)\n            raw=temporary.read_bytes()\n            temporary.unlink()\n        else: raise SystemExit(\"Image has neither bytes nor URL\")\n        if not raw: raise SystemExit(\"Empty image result\")\n        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\"\n        Path(f\"image-{index}.{ext}\").write_bytes(raw)\n    print(\"Every returned image saved; complete response metadata retained\")\nsave_images(json.loads(Path(\"result.json\").read_text())[\"data\"])\nPY_RESULT\n",
            "label": "Create and save every image",
            "language": "bash"
          },
          {
            "code": "from openai import OpenAI\nimport base64, json, os, subprocess\nfrom pathlib import Path\nfrom urllib.parse import urlsplit, urljoin\n\ndef save_images(items):\n    if not items: raise SystemExit(\"No completed images; retain the full response\")\n    for index, item in enumerate(items):\n        encoded=item.get(\"b64_json\")\n        uri=item.get(\"url\", \"\")\n        if not encoded and uri.startswith(\"data:image/\"):\n            header, separator, encoded=uri.partition(\",\")\n            if not separator or \";base64\" not in header: raise SystemExit(\"Unsupported image data URI\")\n        if encoded:\n            raw=base64.b64decode(encoded,validate=True)\n        elif uri:\n            uri=urljoin(\"https://api.ailoot.ai\",uri)\n            parsed=urlsplit(uri)\n            if parsed.scheme!=\"https\" or not parsed.netloc or parsed.username or parsed.password:\n                raise SystemExit(\"Invalid returned image URL\")\n            owned=parsed.netloc==\"api.ailoot.ai\" and parsed.path.startswith(\"/v1/media/assets/\") and parsed.path.endswith(\"/content\")\n            args=[\"curl\",\"--fail-with-body\",\"--silent\",\"--show-error\",uri]\n            if owned: args += [\"-H\",\"Authorization: Bearer \"+os.environ[\"AILOOT_API_KEY\"]]\n            temporary=Path(f\"image-{index}.bin\")\n            subprocess.run(args+[\"-o\",str(temporary)],check=True)\n            raw=temporary.read_bytes()\n            temporary.unlink()\n        else: raise SystemExit(\"Image has neither bytes nor URL\")\n        if not raw: raise SystemExit(\"Empty image result\")\n        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\"\n        Path(f\"image-{index}.{ext}\").write_bytes(raw)\n    print(\"Every returned image saved; complete response metadata retained\")\n\nf=Path(os.environ[\"AILOOT_PROMPT_FILE\"])\nif not f.is_file():raise SystemExit(\"Set your actual UTF-8 image brief file\")\nrequest={'model': 'wan2.7-image-pro', 'prompt': ''}\nrequest[\"prompt\"]=f.read_text(encoding=\"utf-8\")\nclient=OpenAI(base_url=\"https://api.ailoot.ai/v1\",api_key=os.environ[\"AILOOT_API_KEY\"],max_retries=0)\nresult=client.images.generate(**request)\nPath(\"sdk-result.txt\").write_text(str(result),encoding=\"utf-8\")\nsave_images([{\"b64_json\":getattr(item,\"b64_json\",None),\"url\":getattr(item,\"url\",None)} for item in result.data])\n",
            "label": "Python SDK · save all image outputs",
            "language": "python"
          },
          {
            "code": "import OpenAI from \"openai\";\nimport { readFileSync, writeFileSync } from \"node:fs\";\nconst key=process.env.AILOOT_API_KEY;\nif(!key) throw new Error(\"Set your actual Ailoot API key\");\nconst client=new OpenAI({baseURL:\"https://api.ailoot.ai/v1\",apiKey:key,maxRetries:0});\nconst request={\"model\": \"wan2.7-image-pro\", \"prompt\": \"\"};\nif(!process.env.AILOOT_PROMPT_FILE)throw new Error(\"Set your actual UTF-8 image brief file\");\nrequest.prompt=readFileSync(process.env.AILOOT_PROMPT_FILE,\"utf8\");\nconst result=await client.images.generate(request);\nwriteFileSync(\"sdk-result.json\",JSON.stringify(result,null,2));\nif(!result.data?.length) throw new Error(\"No completed images\");\nfor(let index=0;index<result.data.length;index++) {\n  const item=result.data[index];let encoded=item.b64_json,uri=item.url||\"\",raw;\n  if(!encoded && uri.startsWith(\"data:image/\")) {\n    const comma=uri.indexOf(\",\");if(comma<0 || !uri.slice(0,comma).includes(\";base64\")) throw new Error(\"Unsupported image data URI\");\n    encoded=uri.slice(comma+1);\n  }\n  if(encoded) {\n    if(encoded.length%4!==0 || !/^[A-Za-z0-9+/]*={0,2}$/.test(encoded)) throw new Error(\"Invalid Base64\");\n    raw=Buffer.from(encoded,\"base64\");\n  } else if(uri) {\n    const u=new URL(uri,\"https://api.ailoot.ai\");\n    if(u.protocol!==\"https:\" || u.username || u.password) throw new Error(\"Invalid returned URL\");\n    const owned=u.origin===\"https://api.ailoot.ai\" && u.pathname.startsWith(\"/v1/media/assets/\") && u.pathname.endsWith(\"/content\");\n    const response=await fetch(u,{headers:owned?{Authorization:\"Bearer \"+key}:{},redirect:\"manual\"});\n    if(!response.ok) throw new Error(\"Image content download failed: \"+response.status);\n    raw=Buffer.from(await response.arrayBuffer());\n  } else throw new Error(\"Image has neither bytes nor URL\");\n  if(!raw.length) throw new Error(\"Empty image result\");\n  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\";\n  writeFileSync(`image-${index}.${ext}`,raw);\n}\nconsole.log(\"Every returned image saved; sdk-result.json retains complete metadata\");\n",
            "label": "Node SDK · save all image outputs",
            "language": "js"
          }
        ],
        "family": "openai",
        "fast_multiplier": null,
        "flex_multiplier": null,
        "fmt": "images",
        "http": "POST",
        "img_in": null,
        "img_out": null,
        "in": null,
        "input": [
          "text"
        ],
        "label": "Ảnh",
        "max_out": null,
        "max_tool_calls": null,
        "out": null,
        "output": [
          "image"
        ],
        "path": "/v1/images/generations",
        "pricing_profiles": [
          {
            "dimensions": {},
            "label": "Core",
            "units": [
              {
                "amount": 0.075,
                "amount_unit": "usd_per_display_unit",
                "key": "image_output_1k",
                "label": "per 1K image",
                "side": "out"
              },
              {
                "amount": 0.075,
                "amount_unit": "usd_per_display_unit",
                "key": "image_output_2k",
                "label": "per 2K image",
                "side": "out"
              }
            ]
          }
        ],
        "request_model_id": "wan2.7-image-pro",
        "route_label": "Core",
        "status_reads": [],
        "tiers": [],
        "tool_prices": null,
        "unit": "conditional",
        "units": [
          {
            "key": "image_output_1k",
            "label": "per 1K image",
            "side": "out",
            "usd": 0.075
          },
          {
            "key": "image_output_2k",
            "label": "per 2K image",
            "side": "out",
            "usd": 0.075
          }
        ]
      }
    },
    {
      "html": "<div class=\"sheet-head\"><span class=\"mav\" aria-hidden=\"true\">Al</span><h2 id=\"sheet-title\">wan2.7-image-pro</h2><button class=\"icon-btn\" type=\"button\" data-close-sheet aria-label=\"Đóng\">×</button></div><div class=\"idline\"><span>Alibaba /</span><code>wan-image</code><button type=\"button\" id=\"copy-id\">Sao chép ID</button></div><nav class=\"card-jump-nav\" aria-label=\"Các phần của thẻ mô hình\"><button type=\"button\" data-card-jump=\"overview\">Bắt đầu</button><button type=\"button\" data-card-jump=\"methods\">Đầu vào &amp; phương thức</button><button type=\"button\" data-card-jump=\"pricing\">Bảng giá</button><button type=\"button\" data-card-jump=\"examples\">Ví dụ</button><button type=\"button\" data-card-jump=\"results\">Kết quả</button><button type=\"button\" data-card-jump=\"aliases\">Bí danh</button></nav><div class=\"card-method-tabs\" role=\"tablist\" aria-label=\"Phương thức API\"><button type=\"button\" role=\"tab\" tabindex=\"0\" aria-controls=\"card-method-content\" aria-selected=\"true\" id=\"card-method-tab-0\" data-card-method=\"Core|images|/v1/images/generations|wan-image\">Ảnh</button></div><div class=\"idline\"><label for=\"card-model-id\">ID mô hình</label><select class=\"sel\" id=\"card-model-id\" style=\"min-width:0;max-width:100%\"><option value=\"Core|images|/v1/images/generations|wan2.7-image-pro\">wan2.7-image-pro</option><option value=\"Core|images|/v1/images/generations|wan-image\" selected>wan-image</option><option value=\"Core|images|/v1/images/generations|wan-image-latest\">wan-image-latest</option></select></div><div id=\"card-method-content\" role=\"tabpanel\" aria-labelledby=\"card-method-tab-0\"><section class=\"card-section\" data-card-section=\"overview\"><h3 tabindex=\"-1\">Bắt đầu</h3><p class=\"mdesc-full\">Mô hình tạo ảnh từ yêu cầu bằng văn bản. Nhà sản xuất cho phép điều khiển bảng màu và độ phân giải tối đa 4K khi tạo ảnh thông thường từ văn bản.</p><dl class=\"card-io\" data-card-io><div><dt>Đầu vào được chấp nhận</dt><dd>Văn bản</dd></div><div><dt>Kết quả</dt><dd>Ảnh</dd></div></dl><details class=\"card-about\"><summary>Về mô hình</summary><p class=\"note-s\" data-model-method-boundary>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.</p><div class=\"mabout\" id=\"m-about\"><p>Wan2.7-Image-Pro là mô hình của Alibaba để tạo ảnh từ văn bản. Thẻ Ailoot hiện tại công bố đầu vào văn bản và kết quả dạng ảnh. Nhà sản xuất còn cung cấp chỉnh sửa, kết hợp ảnh tham chiếu và thay đổi cục bộ; các cách này cần hỗ trợ đầu vào ảnh riêng và không được cung cấp qua phương thức hiện tại của thẻ.</p><p>Trong chế độ dùng ảnh tham chiếu của nhà sản xuất, có thể gửi tối đa chín ảnh nguồn và mô tả những yếu tố cần sử dụng từ mỗi ảnh. Khi chỉnh sửa, mô hình giữ đối tượng chính, thay đổi các chi tiết đã chọn hoặc ghép nhiều tư liệu thành bố cục mới. Để định hướng thay đổi chính xác hơn, có thể xác định tối đa hai vùng hình chữ nhật trên một ảnh đầu vào.</p><h4>Bảng màu và yêu cầu phức tạp</h4><p>Ngoài các chuỗi liên tiếp, có thể đặt bảng màu gồm 3–10 màu. Chế độ suy luận dành cho việc tạo ảnh thông thường từ văn bản, không dùng ảnh tham chiếu hoặc chuỗi liên tiếp: mô hình phân tích trước mô tả của cảnh.</p><p>Trong đặc tả Alibaba, đầu ra thông thường gồm từ một đến bốn ảnh. Với chuỗi theo cốt truyện, có thể đặt giới hạn trên tối đa 12 ảnh; mô hình chọn số lượng thực tế theo yêu cầu. Chuỗi có thể sử dụng văn bản và ảnh tham chiếu để giữ các đặc điểm chung của nhân vật và diễn biến câu chuyện liền mạch. Bảng màu và suy luận không được áp dụng ở chế độ này.</p><h4>Độ phân giải phụ thuộc vào chế độ</h4><p>Mức 4K được hỗ trợ khi tạo ảnh thông thường từ văn bản, không dùng ảnh tham chiếu hoặc chuỗi liên tiếp. Chỉnh sửa dựa trên ảnh và chuỗi liên tiếp bị giới hạn ở mức 2K. Các ký hiệu này xác định diện tích pixel, không phải độ dài bằng nhau của mỗi cạnh. Có thể chọn tỷ lệ khung hình từ 1:8 đến 8:1; khi chỉnh sửa với độ phân giải đặt sẵn, tỷ lệ khung hình theo ảnh tham chiếu cuối cùng. Kết quả được lưu ở định dạng PNG.</p><p>Với những cách sử dụng ảnh đầu vào, Alibaba chấp nhận JPEG, JPG, PNG không có độ trong suốt, BMP và WEBP. Các giới hạn là 20 MB mỗi tệp, từ 240 đến 8000 pixel cho mỗi chiều và tỷ lệ từ 1:8 đến 8:1. Yêu cầu bằng văn bản hỗ trợ tiếng Trung và tiếng Anh; tối đa 5000 ký tự, phần dư bị cắt bỏ. Phiên bản này không có mô tả phủ định hoặc mở rộng yêu cầu. Hạt giống ngẫu nhiên giúp giữ nét tương đồng giữa các phương án, nhưng không bảo đảm lặp lại chính xác.</p></div></details></section><section class=\"card-section\" data-card-section=\"methods\"><h3 tabindex=\"-1\">Có trên Ailoot · đầu vào &amp; phương thức</h3><details class=\"card-method\" open><summary><b>Ailoot · Ảnh</b> <code>POST /v1/images/generations</code></summary><dl class=\"method-capabilities\"><div><dt>Đầu vào</dt><dd><code>text</code></dd></div><div><dt>Đầu ra</dt><dd><code>image</code></dd></div><div><dt>Định dạng đầu ra</dt><dd>Tệp ảnh</dd></div></dl><div class=\"tw\" data-card-parameters data-typed-parameters><table><thead><tr><th>Trường</th><th>Loại</th><th>Yêu cầu</th><th>Giá trị &amp; giới hạn</th><th>Mặc định</th></tr></thead><tbody><tr data-parameter-availability=\"source_interface\"><th data-cell-label=\"Trường\" scope=\"row\"><span class=\"card-cell-label\">Trường</span><code class=\"card-field-name\">model</code></th><td data-cell-label=\"Loại\" data-field-type><span class=\"card-cell-label\">Loại</span><code>string</code></td><td data-cell-label=\"Yêu cầu\"><span class=\"card-cell-label\">Yêu cầu</span>Bắt buộc</td><td data-cell-label=\"Giá trị &amp; giới hạn\"><span class=\"card-cell-label\">Giá trị &amp; giới hạn</span><div>wan-image</div></td><td data-cell-label=\"Mặc định\" data-default=\"unspecified\"><span class=\"card-cell-label\">Mặc định</span>—</td></tr><tr data-parameter-availability=\"source_interface\"><th data-cell-label=\"Trường\" scope=\"row\"><span class=\"card-cell-label\">Trường</span><code class=\"card-field-name\">prompt</code></th><td data-cell-label=\"Loại\" data-field-type><span class=\"card-cell-label\">Loại</span><code>string</code></td><td data-cell-label=\"Yêu cầu\"><span class=\"card-cell-label\">Yêu cầu</span>Bắt buộc</td><td data-cell-label=\"Giá trị &amp; giới hạn\"><span class=\"card-cell-label\">Giá trị &amp; giới hạn</span><div>Độ dài tối thiểu: 1</div></td><td data-cell-label=\"Mặc định\" data-default=\"unspecified\"><span class=\"card-cell-label\">Mặc định</span>—</td></tr><tr data-parameter-availability=\"source_interface\"><th data-cell-label=\"Trường\" scope=\"row\"><span class=\"card-cell-label\">Trường</span><code class=\"card-field-name\">n</code></th><td data-cell-label=\"Loại\" data-field-type><span class=\"card-cell-label\">Loại</span><code>integer</code></td><td data-cell-label=\"Yêu cầu\"><span class=\"card-cell-label\">Yêu cầu</span>Không bắt buộc</td><td data-cell-label=\"Giá trị &amp; giới hạn\"><span class=\"card-cell-label\">Giá trị &amp; giới hạn</span><div>Tối thiểu: 1</div></td><td data-cell-label=\"Mặc định\" data-default=\"known\"><span class=\"card-cell-label\">Mặc định</span>1</td></tr><tr data-parameter-availability=\"source_interface\"><th data-cell-label=\"Trường\" scope=\"row\"><span class=\"card-cell-label\">Trường</span><code class=\"card-field-name\">response_format</code></th><td data-cell-label=\"Loại\" data-field-type><span class=\"card-cell-label\">Loại</span><code>string</code></td><td data-cell-label=\"Yêu cầu\"><span class=\"card-cell-label\">Yêu cầu</span>Không bắt buộc</td><td data-cell-label=\"Giá trị &amp; giới hạn\"><span class=\"card-cell-label\">Giá trị &amp; giới hạn</span><div>url, b64_json</div></td><td data-cell-label=\"Mặc định\" data-default=\"unspecified\"><span class=\"card-cell-label\">Mặc định</span>—</td></tr><tr data-parameter-availability=\"source_interface\"><th data-cell-label=\"Trường\" scope=\"row\"><span class=\"card-cell-label\">Trường</span><code class=\"card-field-name\">stream</code></th><td data-cell-label=\"Loại\" data-field-type><span class=\"card-cell-label\">Loại</span><code>boolean</code></td><td data-cell-label=\"Yêu cầu\"><span class=\"card-cell-label\">Yêu cầu</span>Không bắt buộc</td><td data-cell-label=\"Giá trị &amp; giới hạn\"><span class=\"card-cell-label\">Giá trị &amp; giới hạn</span></td><td data-cell-label=\"Mặc định\" data-default=\"known\"><span class=\"card-cell-label\">Mặc định</span>false</td></tr><tr data-parameter-availability=\"model_dependent\"><th data-cell-label=\"Trường\" scope=\"row\"><span class=\"card-cell-label\">Trường</span><code class=\"card-field-name\">size</code></th><td data-cell-label=\"Loại\" data-field-type><span class=\"card-cell-label\">Loại</span><code>string</code></td><td data-cell-label=\"Yêu cầu\"><span class=\"card-cell-label\">Yêu cầu</span>Không bắt buộc</td><td data-cell-label=\"Giá trị &amp; giới hạn\"><span class=\"card-cell-label\">Giá trị &amp; giới hạn</span><div class=\"note-s\">Tùy thuộc vào mô hình</div></td><td data-cell-label=\"Mặc định\" data-default=\"unspecified\"><span class=\"card-cell-label\">Mặc định</span>—</td></tr><tr data-parameter-availability=\"model_dependent\"><th data-cell-label=\"Trường\" scope=\"row\"><span class=\"card-cell-label\">Trường</span><code class=\"card-field-name\">partial_images</code></th><td data-cell-label=\"Loại\" data-field-type><span class=\"card-cell-label\">Loại</span><code>integer</code></td><td data-cell-label=\"Yêu cầu\"><span class=\"card-cell-label\">Yêu cầu</span>Không bắt buộc</td><td data-cell-label=\"Giá trị &amp; giới hạn\"><span class=\"card-cell-label\">Giá trị &amp; giới hạn</span><div class=\"note-s\">Tùy thuộc vào mô hình</div></td><td data-cell-label=\"Mặc định\" data-default=\"unspecified\"><span class=\"card-cell-label\">Mặc định</span>—</td></tr><tr data-parameter-availability=\"different_method\"><th data-cell-label=\"Trường\" scope=\"row\"><span class=\"card-cell-label\">Trường</span><code class=\"card-field-name\">images[].image_url</code></th><td data-cell-label=\"Loại\" data-field-type><span class=\"card-cell-label\">Loại</span><code>string</code></td><td data-cell-label=\"Yêu cầu\"><span class=\"card-cell-label\">Yêu cầu</span>Không hỗ trợ</td><td data-cell-label=\"Giá trị &amp; giới hạn\"><span class=\"card-cell-label\">Giá trị &amp; giới hạn</span><div>Số byte tối đa sau giải mã: 20.971.520</div><div>Loại MIME: image/png, image/jpeg</div><div>Số ảnh tối đa mỗi mảng: 9</div><div>Điều kiện: Một URL thực tế cho mỗi đối tượng images[]. Số phần tử mảng khác với nút lá dạng chuỗi này.</div><div>Áp dụng khi: Chỉ JSON images/edits; JSON images/generations không phân tích các tham chiếu images.</div></td><td data-cell-label=\"Mặc định\" data-default=\"unspecified\"><span class=\"card-cell-label\">Mặc định</span>—</td></tr><tr data-parameter-availability=\"source_interface\"><th data-cell-label=\"Trường\" scope=\"row\"><span class=\"card-cell-label\">Trường</span><code class=\"card-field-name\">image</code></th><td data-cell-label=\"Loại\" data-field-type><span class=\"card-cell-label\">Loại</span><code>file</code></td><td data-cell-label=\"Yêu cầu\"><span class=\"card-cell-label\">Yêu cầu</span>Không bắt buộc</td><td data-cell-label=\"Giá trị &amp; giới hạn\"><span class=\"card-cell-label\">Giá trị &amp; giới hạn</span><div>Số byte tối đa sau giải mã: 20.971.520</div><div>Loại MIME: image/png, image/jpeg</div><div>Áp dụng khi: tạo bằng multipart/form-data</div></td><td data-cell-label=\"Mặc định\" data-default=\"unspecified\"><span class=\"card-cell-label\">Mặc định</span>—</td></tr><tr data-parameter-availability=\"source_interface\"><th data-cell-label=\"Trường\" scope=\"row\"><span class=\"card-cell-label\">Trường</span><code class=\"card-field-name\">image[]</code></th><td data-cell-label=\"Loại\" data-field-type><span class=\"card-cell-label\">Loại</span><code>file[]</code></td><td data-cell-label=\"Yêu cầu\"><span class=\"card-cell-label\">Yêu cầu</span>Không bắt buộc</td><td data-cell-label=\"Giá trị &amp; giới hạn\"><span class=\"card-cell-label\">Giá trị &amp; giới hạn</span><div>Số mục tối đa: 9</div><div>Số byte tối đa sau giải mã: 20.971.520</div><div>Loại MIME: image/png, image/jpeg</div><div>Áp dụng khi: tạo bằng multipart/form-data</div></td><td data-cell-label=\"Mặc định\" data-default=\"unspecified\"><span class=\"card-cell-label\">Mặc định</span>—</td></tr></tbody></table></div><details class=\"card-about\" data-material-combinations><summary>Tổ hợp tư liệu đầu vào</summary><p class=\"note-s\"><b>Văn bản thành ảnh</b> · Bắt buộc: prompt</p><p class=\"note-s\"><b>reference_images_generation</b> · Bắt buộc: prompt</p></details><details class=\"note-s\" data-method-contract><summary>Tham số phương thức và vòng đời</summary><div class=\"tw\" data-card-table=\"contract\"><table><thead><tr><th>Tham số</th><th>Hợp đồng</th></tr></thead><tbody><tr><th data-cell-label=\"Tham số\" scope=\"row\"><span class=\"card-cell-label\">Tham số</span><code>material_types</code></th><td data-cell-label=\"Hợp đồng\"><span class=\"card-cell-label\">Hợp đồng</span>text</td></tr><tr><th data-cell-label=\"Tham số\" scope=\"row\"><span class=\"card-cell-label\">Tham số</span><code>required</code></th><td data-cell-label=\"Hợp đồng\"><span class=\"card-cell-label\">Hợp đồng</span>model, prompt</td></tr><tr><th data-cell-label=\"Tham số\" scope=\"row\"><span class=\"card-cell-label\">Tham số</span><code>optional_controls</code></th><td data-cell-label=\"Hợp đồng\"><span class=\"card-cell-label\">Hợp đồng</span>null</td></tr><tr><th data-cell-label=\"Tham số\" scope=\"row\"><span class=\"card-cell-label\">Tham số</span><code>content_type</code></th><td data-cell-label=\"Hợp đồng\"><span class=\"card-cell-label\">Hợp đồng</span>application/json</td></tr></tbody></table></div><p>Vòng đời: <code>synchronous_result_then_owned_library</code></p><p class=\"note-s\"><code>GET /v1/media/tasks/{task_id}</code> · 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</p><p class=\"note-s\"><code>GET /v1/media/assets/{asset_id}/content</code></p><p class=\"note-s\"><code>GET /v1/media/assets</code></p><p class=\"note-s\"><code>GET /v1/media/assets/{asset_id}</code></p><p class=\"note-s\">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.</p></details></details></section><section class=\"card-section\" data-card-section=\"pricing\"><h3 tabindex=\"-1\">Bảng giá</h3><h4>Mức phí phương thức Ailoot</h4><section class=\"meth\" data-route=\"Core\"><header><b><span class=\"alias\">Ailoot</span> Ảnh</b><code>POST /v1/images/generations</code></header><dl><div><dt>Đầu ra</dt><dd>0,075 US$ <em>mỗi ảnh 1K</em></dd></div><div><dt>Đầu ra</dt><dd>0,075 US$ <em>mỗi ảnh 2K</em></dd></div></dl></section><p class=\"note-s\">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. <a href=\"/docs/vi/billing/reserve/\">Cách hoạt động của cơ chế tạm giữ và quyết toán →</a></p><div data-declared-reference-pricing><h4>Chi tiết giá cước tham chiếu</h4><p class=\"note-s\">Biểu tham chiếu cấp mô hình không thay đổi việc chọn phương thức, báo giá hoặc khoản phí. Khoản phí đang áp dụng dùng mức phí phương thức Ailoot đã chọn.</p><details class=\"card-price-reference\" data-declared-reference-group data-client-selectable=\"false\"><summary>wan2.7-image-pro</summary><h4>Giá theo cấu hình</h4><div class=\"tw\" data-pricing-profiles><table><thead><tr><th>Cấu hình</th><th>Điều kiện tính phí</th><th>Phí</th></tr></thead><tbody><tr><th data-cell-label=\"Cấu hình\" scope=\"row\"><span class=\"card-cell-label\">Cấu hình</span>wan2.7-image-pro · Cấu hình mặc định</th><td data-cell-label=\"Điều kiện tính phí\"><span class=\"card-cell-label\">Điều kiện tính phí</span>Cấu hình mặc định</td><td data-cell-label=\"Phí\"><span class=\"card-cell-label\">Phí</span><div><span>Đầu vào · Đầu vào</span> <b>0,00 US$</b> <span class=\"price-unit\">mỗi lần gọi</span></div><div><span>Đầu ra · Đầu ra</span> <b>0,16 US$</b> <span class=\"price-unit\">mỗi lần gọi</span></div></td></tr></tbody></table></div></details></div></section><section class=\"card-section\" data-card-section=\"examples\"><h3 tabindex=\"-1\">Ví dụ yêu cầu</h3><h4>Ailoot · Ảnh</h4><div class=\"code-group\"><div class=\"cg-bar\"><div class=\"cg-tabs\" role=\"tablist\" aria-label=\"Các phiên bản mã\"><button class=\"cg-tab\" id=\"model-code-105-tab-0\" role=\"tab\" type=\"button\" aria-controls=\"model-code-105-panel-0\" aria-selected=\"true\" tabindex=\"0\">curl</button><button class=\"cg-tab\" id=\"model-code-105-tab-1\" role=\"tab\" type=\"button\" aria-controls=\"model-code-105-panel-1\" aria-selected=\"false\" tabindex=\"-1\">Python SDK</button><button class=\"cg-tab\" id=\"model-code-105-tab-2\" role=\"tab\" type=\"button\" aria-controls=\"model-code-105-panel-2\" aria-selected=\"false\" tabindex=\"-1\">Node.js SDK</button></div><div class=\"cg-tools\"><button class=\"cg-btn cg-copy\" type=\"button\" aria-label=\"Sao chép mã\"><svg class=\"cp\" viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.4\"><rect x=\"5.25\" y=\"5.25\" width=\"8.5\" height=\"8.5\" rx=\"1.75\"/><path d=\"M10.75 5.25V3.5a1.25 1.25 0 0 0-1.25-1.25H3.5A1.25 1.25 0 0 0 2.25 3.5v6a1.25 1.25 0 0 0 1.25 1.25h1.75\"/></svg><svg class=\"ok\" viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.4\"><path d=\"m3 8.5 3.25 3.25L13 5\"/></svg></button></div></div><div class=\"cg-body\"><div class=\"cg-pane\" id=\"model-code-105-panel-0\" role=\"tabpanel\" aria-labelledby=\"model-code-105-tab-0\"><pre data-lang=\"bash\"><code>set -eu\n: &quot;${AILOOT_API_KEY:?Set your Ailoot API key}&quot;\nexport AILOOT_API_KEY\nexport AILOOT_API_KEY\n: &quot;${AILOOT_PROMPT_FILE:?Set your actual UTF-8 image brief}&quot;\nexport AILOOT_PROMPT_FILE\npython3 - &lt;&lt;&#39;PY_REQUEST&#39;\nimport json,os\nfrom pathlib import Path\np=json.loads(&#39;{&quot;model&quot;: &quot;wan-image&quot;, &quot;prompt&quot;: &quot;&quot;}&#39;)\nf=Path(os.environ[&quot;AILOOT_PROMPT_FILE&quot;])\nif not f.is_file():raise SystemExit(&quot;Choose your actual UTF-8 brief&quot;)\np[&#39;prompt&#39;]=f.read_text(encoding=&quot;utf-8&quot;)\nif not p[&#39;prompt&#39;].strip():raise SystemExit(&quot;Brief must contain text&quot;)\nPath(&quot;request.json&quot;).write_text(json.dumps(p,ensure_ascii=False))\nPY_REQUEST\ncurl --fail-with-body --silent --show-error https://api.ailoot.ai/v1/images/generations \\\n  -H &quot;Authorization: Bearer $AILOOT_API_KEY&quot; -H &#39;Content-Type: application/json&#39; \\\n  --data-binary @request.json -D response-headers.txt -o result.json\npython3 - &lt;&lt;&#39;PY_RESULT&#39;\nimport base64, json, os, subprocess\nfrom pathlib import Path\nfrom urllib.parse import urlsplit, urljoin\n\ndef save_images(items):\n    if not items: raise SystemExit(&quot;No completed images; retain the full response&quot;)\n    for index, item in enumerate(items):\n        encoded=item.get(&quot;b64_json&quot;)\n        uri=item.get(&quot;url&quot;, &quot;&quot;)\n        if not encoded and uri.startswith(&quot;data:image/&quot;):\n            header, separator, encoded=uri.partition(&quot;,&quot;)\n            if not separator or &quot;;base64&quot; not in header: raise SystemExit(&quot;Unsupported image data URI&quot;)\n        if encoded:\n            raw=base64.b64decode(encoded,validate=True)\n        elif uri:\n            uri=urljoin(&quot;https://api.ailoot.ai&quot;,uri)\n            parsed=urlsplit(uri)\n            if parsed.scheme!=&quot;https&quot; or not parsed.netloc or parsed.username or parsed.password:\n                raise SystemExit(&quot;Invalid returned image URL&quot;)\n            owned=parsed.netloc==&quot;api.ailoot.ai&quot; and parsed.path.startswith(&quot;/v1/media/assets/&quot;) and parsed.path.endswith(&quot;/content&quot;)\n            args=[&quot;curl&quot;,&quot;--fail-with-body&quot;,&quot;--silent&quot;,&quot;--show-error&quot;,uri]\n            if owned: args += [&quot;-H&quot;,&quot;Authorization: Bearer &quot;+os.environ[&quot;AILOOT_API_KEY&quot;]]\n            temporary=Path(f&quot;image-{index}.bin&quot;)\n            subprocess.run(args+[&quot;-o&quot;,str(temporary)],check=True)\n            raw=temporary.read_bytes()\n            temporary.unlink()\n        else: raise SystemExit(&quot;Image has neither bytes nor URL&quot;)\n        if not raw: raise SystemExit(&quot;Empty image result&quot;)\n        ext=&quot;png&quot; if raw.startswith(b&quot;\\x89PNG&quot;) else &quot;jpg&quot; if raw.startswith(b&quot;\\xff\\xd8&quot;) else &quot;webp&quot; if raw[:4]==b&quot;RIFF&quot; and raw[8:12]==b&quot;WEBP&quot; else &quot;svg&quot; if raw.lstrip().startswith((b&quot;&lt;svg&quot;,b&quot;&lt;?xml&quot;)) else &quot;bin&quot;\n        Path(f&quot;image-{index}.{ext}&quot;).write_bytes(raw)\n    print(&quot;Every returned image saved; complete response metadata retained&quot;)\nsave_images(json.loads(Path(&quot;result.json&quot;).read_text())[&quot;data&quot;])\nPY_RESULT\n</code></pre></div><div class=\"cg-pane\" id=\"model-code-105-panel-1\" role=\"tabpanel\" aria-labelledby=\"model-code-105-tab-1\" hidden><pre data-lang=\"python\"><code>from openai import OpenAI\nimport base64, json, os, subprocess\nfrom pathlib import Path\nfrom urllib.parse import urlsplit, urljoin\n\ndef save_images(items):\n    if not items: raise SystemExit(&quot;No completed images; retain the full response&quot;)\n    for index, item in enumerate(items):\n        encoded=item.get(&quot;b64_json&quot;)\n        uri=item.get(&quot;url&quot;, &quot;&quot;)\n        if not encoded and uri.startswith(&quot;data:image/&quot;):\n            header, separator, encoded=uri.partition(&quot;,&quot;)\n            if not separator or &quot;;base64&quot; not in header: raise SystemExit(&quot;Unsupported image data URI&quot;)\n        if encoded:\n            raw=base64.b64decode(encoded,validate=True)\n        elif uri:\n            uri=urljoin(&quot;https://api.ailoot.ai&quot;,uri)\n            parsed=urlsplit(uri)\n            if parsed.scheme!=&quot;https&quot; or not parsed.netloc or parsed.username or parsed.password:\n                raise SystemExit(&quot;Invalid returned image URL&quot;)\n            owned=parsed.netloc==&quot;api.ailoot.ai&quot; and parsed.path.startswith(&quot;/v1/media/assets/&quot;) and parsed.path.endswith(&quot;/content&quot;)\n            args=[&quot;curl&quot;,&quot;--fail-with-body&quot;,&quot;--silent&quot;,&quot;--show-error&quot;,uri]\n            if owned: args += [&quot;-H&quot;,&quot;Authorization: Bearer &quot;+os.environ[&quot;AILOOT_API_KEY&quot;]]\n            temporary=Path(f&quot;image-{index}.bin&quot;)\n            subprocess.run(args+[&quot;-o&quot;,str(temporary)],check=True)\n            raw=temporary.read_bytes()\n            temporary.unlink()\n        else: raise SystemExit(&quot;Image has neither bytes nor URL&quot;)\n        if not raw: raise SystemExit(&quot;Empty image result&quot;)\n        ext=&quot;png&quot; if raw.startswith(b&quot;\\x89PNG&quot;) else &quot;jpg&quot; if raw.startswith(b&quot;\\xff\\xd8&quot;) else &quot;webp&quot; if raw[:4]==b&quot;RIFF&quot; and raw[8:12]==b&quot;WEBP&quot; else &quot;svg&quot; if raw.lstrip().startswith((b&quot;&lt;svg&quot;,b&quot;&lt;?xml&quot;)) else &quot;bin&quot;\n        Path(f&quot;image-{index}.{ext}&quot;).write_bytes(raw)\n    print(&quot;Every returned image saved; complete response metadata retained&quot;)\n\nf=Path(os.environ[&quot;AILOOT_PROMPT_FILE&quot;])\nif not f.is_file():raise SystemExit(&quot;Set your actual UTF-8 image brief file&quot;)\nrequest={&#39;model&#39;: &#39;wan-image&#39;, &#39;prompt&#39;: &#39;&#39;}\nrequest[&quot;prompt&quot;]=f.read_text(encoding=&quot;utf-8&quot;)\nclient=OpenAI(base_url=&quot;https://api.ailoot.ai/v1&quot;,api_key=os.environ[&quot;AILOOT_API_KEY&quot;],max_retries=0)\nresult=client.images.generate(**request)\nPath(&quot;sdk-result.txt&quot;).write_text(str(result),encoding=&quot;utf-8&quot;)\nsave_images([{&quot;b64_json&quot;:getattr(item,&quot;b64_json&quot;,None),&quot;url&quot;:getattr(item,&quot;url&quot;,None)} for item in result.data])\n</code></pre></div><div class=\"cg-pane\" id=\"model-code-105-panel-2\" role=\"tabpanel\" aria-labelledby=\"model-code-105-tab-2\" hidden><pre data-lang=\"js\"><code>import OpenAI from &quot;openai&quot;;\nimport { readFileSync, writeFileSync } from &quot;node:fs&quot;;\nconst key=process.env.AILOOT_API_KEY;\nif(!key) throw new Error(&quot;Set your actual Ailoot API key&quot;);\nconst client=new OpenAI({baseURL:&quot;https://api.ailoot.ai/v1&quot;,apiKey:key,maxRetries:0});\nconst request={&quot;model&quot;: &quot;wan-image&quot;, &quot;prompt&quot;: &quot;&quot;};\nif(!process.env.AILOOT_PROMPT_FILE)throw new Error(&quot;Set your actual UTF-8 image brief file&quot;);\nrequest.prompt=readFileSync(process.env.AILOOT_PROMPT_FILE,&quot;utf8&quot;);\nconst result=await client.images.generate(request);\nwriteFileSync(&quot;sdk-result.json&quot;,JSON.stringify(result,null,2));\nif(!result.data?.length) throw new Error(&quot;No completed images&quot;);\nfor(let index=0;index&lt;result.data.length;index++) {\n  const item=result.data[index];let encoded=item.b64_json,uri=item.url||&quot;&quot;,raw;\n  if(!encoded &amp;&amp; uri.startsWith(&quot;data:image/&quot;)) {\n    const comma=uri.indexOf(&quot;,&quot;);if(comma&lt;0 || !uri.slice(0,comma).includes(&quot;;base64&quot;)) throw new Error(&quot;Unsupported image data URI&quot;);\n    encoded=uri.slice(comma+1);\n  }\n  if(encoded) {\n    if(encoded.length%4!==0 || !/^[A-Za-z0-9+/]*={0,2}$/.test(encoded)) throw new Error(&quot;Invalid Base64&quot;);\n    raw=Buffer.from(encoded,&quot;base64&quot;);\n  } else if(uri) {\n    const u=new URL(uri,&quot;https://api.ailoot.ai&quot;);\n    if(u.protocol!==&quot;https:&quot; || u.username || u.password) throw new Error(&quot;Invalid returned URL&quot;);\n    const owned=u.origin===&quot;https://api.ailoot.ai&quot; &amp;&amp; u.pathname.startsWith(&quot;/v1/media/assets/&quot;) &amp;&amp; u.pathname.endsWith(&quot;/content&quot;);\n    const response=await fetch(u,{headers:owned?{Authorization:&quot;Bearer &quot;+key}:{},redirect:&quot;manual&quot;});\n    if(!response.ok) throw new Error(&quot;Image content download failed: &quot;+response.status);\n    raw=Buffer.from(await response.arrayBuffer());\n  } else throw new Error(&quot;Image has neither bytes nor URL&quot;);\n  if(!raw.length) throw new Error(&quot;Empty image result&quot;);\n  const ext=raw.subarray(0,4).equals(Buffer.from([137,80,78,71]))?&quot;png&quot;:raw[0]===255&amp;&amp;raw[1]===216?&quot;jpg&quot;:raw.toString(&quot;ascii&quot;,0,4)===&quot;RIFF&quot;&amp;&amp;raw.toString(&quot;ascii&quot;,8,12)===&quot;WEBP&quot;?&quot;webp&quot;:raw.toString(&quot;utf8&quot;).trimStart().startsWith(&quot;&lt;svg&quot;)||raw.toString(&quot;utf8&quot;).trimStart().startsWith(&quot;&lt;?xml&quot;)?&quot;svg&quot;:&quot;bin&quot;;\n  writeFileSync(`image-${index}.${ext}`,raw);\n}\nconsole.log(&quot;Every returned image saved; sdk-result.json retains complete metadata&quot;);\n</code></pre></div></div></div></section><section class=\"card-section\" data-card-section=\"results\"><h3 tabindex=\"-1\">Nhận và lưu kết quả</h3><h4>Ailoot · Ảnh</h4><p class=\"note-s\">Tải xuống từng ảnh trả về hoặc lưu nội dung Base64 của ảnh</p><ul class=\"card-result-paths\"><li><code>GET /v1/media/tasks/{task_id}</code></li><li><code>GET /v1/media/assets/{asset_id}/content</code></li><li><code>GET /v1/media/assets</code></li><li><code>GET /v1/media/assets/{asset_id}</code></li></ul><div class=\"card-result-process\" data-all-results><h5>Lưu tất cả kết quả đã hoàn tất</h5><p class=\"note-s\">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.</p><p class=\"note-s\">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ế.</p></div><div class=\"card-result-process\" data-unknown-recovery><h5>Nếu cần kiểm tra phản hồi gốc</h5><p class=\"note-s\">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.</p></div><details class=\"card-about\" data-output-fields><summary>Trường phản hồi</summary><div class=\"tw\" data-card-table=\"output\"><table><thead><tr><th>Trường</th><th>Loại</th></tr></thead><tbody><tr><th data-cell-label=\"Trường\" scope=\"row\"><span class=\"card-cell-label\">Trường</span><code class=\"card-field-name\">created</code></th><td data-cell-label=\"Loại\" data-field-type><span class=\"card-cell-label\">Loại</span>integer</td></tr><tr><th data-cell-label=\"Trường\" scope=\"row\"><span class=\"card-cell-label\">Trường</span><code class=\"card-field-name\">data[].url</code></th><td data-cell-label=\"Loại\" data-field-type><span class=\"card-cell-label\">Loại</span>string</td></tr><tr><th data-cell-label=\"Trường\" scope=\"row\"><span class=\"card-cell-label\">Trường</span><code class=\"card-field-name\">data[].b64_json</code></th><td data-cell-label=\"Loại\" data-field-type><span class=\"card-cell-label\">Loại</span>base64 string</td></tr><tr><th data-cell-label=\"Trường\" scope=\"row\"><span class=\"card-cell-label\">Trường</span><code class=\"card-field-name\">usage</code></th><td data-cell-label=\"Loại\" data-field-type><span class=\"card-cell-label\">Loại</span>object</td></tr></tbody></table></div></details><details class=\"card-about\" data-method-errors><summary>Lỗi và bước tiếp theo</summary><div class=\"tw\" data-card-table=\"errors\"><table><thead><tr><th>Phản hồi</th><th>Điều kiện</th><th>Bước tiếp theo</th></tr></thead><tbody><tr><th data-cell-label=\"Phản hồi\" scope=\"row\"><span class=\"card-cell-label\">Phản hồi</span>400 · <code>invalid_request_error</code></th><td data-cell-label=\"Điều kiện\"><span class=\"card-cell-label\">Điều kiện</span>Trườ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ệ</td><td data-cell-label=\"Bước tiếp theo\"><span class=\"card-cell-label\">Bước tiếp theo</span>Sửa các trường được chỉ ra trước khi gửi yêu cầu tạo mới.</td></tr><tr><th data-cell-label=\"Phản hồi\" scope=\"row\"><span class=\"card-cell-label\">Phản hồi</span><code>server_error</code></th><td data-cell-label=\"Điều kiện\"><span class=\"card-cell-label\">Điều kiện</span>Phản hồi trả về cho biết thao tác hoặc kết quả cần được kiểm tra</td><td data-cell-label=\"Bước tiếp theo\"><span class=\"card-cell-label\">Bước tiếp theo</span>Giữ 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.</td></tr></tbody></table></div></details></section><section class=\"card-section\" data-card-section=\"aliases\"><h3 tabindex=\"-1\">Bí danh</h3><h4>Bí danh mô hình</h4><p class=\"note-s\"><span data-model-alias-route=\"Core\"><b>Ailoot</b> <a href=\"#m=wan2.7-image-pro&amp;route=Core&amp;caller=wan2.7-image-pro&amp;fmt=images\"><code>wan2.7-image-pro</code></a>, <a href=\"#m=wan2.7-image-pro&amp;route=Core&amp;caller=wan-image&amp;fmt=images\"><code>wan-image</code></a>, <a href=\"#m=wan2.7-image-pro&amp;route=Core&amp;caller=wan-image-latest&amp;fmt=images\"><code>wan-image-latest</code></a></span></p><h4>Bí danh đường dẫn phương thức</h4><p class=\"note-s\">Dùng các đường dẫn phương thức hiển thị ở trên.</p><h4>ID gọi liên quan</h4><p class=\"note-s\"><a href=\"#m=wan2.7-image-pro&amp;route=Core&amp;caller=wan2.7-image-pro&amp;fmt=images\"><code>wan2.7-image-pro</code></a>, <a href=\"#m=wan2.7-image-pro&amp;route=Core&amp;caller=wan-image&amp;fmt=images\"><code>wan-image</code></a>, <a href=\"#m=wan2.7-image-pro&amp;route=Core&amp;caller=wan-image-latest&amp;fmt=images\"><code>wan-image-latest</code></a></p></section></div>",
      "method_identity": {
        "effective_request_model_id": "wan-image",
        "fmt": "images",
        "http": "POST",
        "path": "/v1/images/generations",
        "request_model_id": "wan-image",
        "route_label": "Core"
      },
      "method_key": "Core|images|/v1/images/generations|wan-image",
      "ordinal": 1,
      "rawMethod": {
        "cache_read": null,
        "cache_write": null,
        "cache_write_1h": null,
        "cache_write_5m": null,
        "conditional_meter": null,
        "contract": {
          "data": {
            "all_results": "Save every data item. Decode each b64_json or fetch every returned signed URL. Select a filename extension from the actual MIME/bytes.",
            "errors": [
              {
                "code": null,
                "condition": "Trườ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ệ",
                "http_status": 400,
                "recovery": "Sửa các trường được chỉ ra trước khi gửi yêu cầu tạo mới.",
                "type": "invalid_request_error"
              },
              {
                "code": null,
                "condition": "Phản hồi trả về cho biết thao tác hoặc kết quả cần được kiểm tra",
                "http_status": null,
                "recovery": "Giữ 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.",
                "type": "server_error"
              }
            ],
            "hints": [
              "Qwen defaultsize1024*1024; Wan defaultsize1K. Wan2.7 Pro4K is supported only without reference inputs.",
              "Explicit dimensions must be positive, at most4096 peraxis, within8:1..1:8 aspect, and the exact model/input area range.",
              "The Alibaba image adapter rejects mask input and streaming before sending the request.",
              "For this generation method, actual image references are supported as multipart image files. JSONimages[].image_url is read only on images/edits; the leaf value is a string."
            ],
            "ignored_fields": [
              "quality",
              "background",
              "style",
              "output_format",
              "output_compression",
              "moderation",
              "input_fidelity",
              "partial_images without streaming"
            ],
            "lifecycle": {
              "all_results": "Follow everyactualreturnedoutputandownedasset; no result is discardedbecauseindex0orcontent_urlalreadyexists.",
              "assets": [
                {
                  "http": "GET",
                  "path": "/v1/media/assets"
                },
                {
                  "http": "GET",
                  "path": "/v1/media/assets/{asset_id}"
                }
              ],
              "content": [
                {
                  "http": "GET",
                  "path": "/v1/media/assets/{asset_id}/content",
                  "url_source": "exact returned signed URL; never construct token"
                }
              ],
              "mode": "synchronous_result_then_owned_library",
              "operation_id_is_not_task_id": true,
              "status": [
                {
                  "http": "GET",
                  "id_source": "actual returned task_id or media library record",
                  "path": "/v1/media/tasks/{task_id}"
                }
              ],
              "unknown": "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."
            },
            "material_combinations": [
              {
                "content_type": "application/json",
                "ignored_reference_field": "JSONgeneration images[] is not parsed; images[].image_url belongs to a separately supported JSONedit profile.",
                "mask": false,
                "mode": "text_to_image",
                "reference_images": false,
                "required": [
                  "prompt"
                ],
                "supplied_materials": [
                  "UTF8 prompt"
                ]
              },
              {
                "content_type": "multipart/form-data",
                "mask": false,
                "maximum_decoded_bytes_per_image": 20971520,
                "maximum_reference_images": 9,
                "mime_types": [
                  "image/png",
                  "image/jpeg"
                ],
                "minimum_reference_images": 0,
                "mode": "reference_images_generation",
                "optional_file_fields": [
                  "image",
                  "image[]",
                  "image[index]"
                ],
                "reference_images": true,
                "required": [
                  "prompt"
                ],
                "supplied_materials": [
                  "UTF8 prompt",
                  "actual PNG/JPEG file references"
                ]
              }
            ],
            "media_library": {
              "asset": {
                "fields": [
                  {
                    "description": null,
                    "name": "asset_id",
                    "type": "string"
                  },
                  {
                    "description": null,
                    "name": "task_id",
                    "type": "string"
                  },
                  {
                    "description": null,
                    "name": "output_key",
                    "type": "string"
                  },
                  {
                    "description": null,
                    "name": "family",
                    "type": "string"
                  },
                  {
                    "description": null,
                    "name": "model",
                    "type": "string"
                  },
                  {
                    "description": null,
                    "name": "method",
                    "type": "string"
                  },
                  {
                    "description": null,
                    "name": "status",
                    "type": "string"
                  },
                  {
                    "description": null,
                    "name": "content_type",
                    "type": "string"
                  },
                  {
                    "description": null,
                    "name": "sha256",
                    "type": "string"
                  },
                  {
                    "description": null,
                    "name": "size_bytes",
                    "type": "integer"
                  },
                  {
                    "description": null,
                    "name": "content_url",
                    "type": "string"
                  }
                ],
                "http": "GET",
                "id_source": "actual returned asset_id",
                "path": "/v1/media/assets/{asset_id}"
              },
              "content": {
                "http": "GET",
                "path": "/v1/media/assets/{asset_id}/content",
                "range_header_supported": true,
                "url_source": "Use exact returned signed content_url including its token; do not construct a token."
              },
              "expired_link": {
                "code": "link_expired",
                "http_status": 404,
                "recovery": "Read the asset again to obtain its refreshed signed content_url, then fetch that URL. Do not regenerate."
              },
              "list": {
                "all_pages": "Follow every returned next_cursor, then select records by their actual task_id/output_key.",
                "http": "GET",
                "output_fields": [
                  {
                    "description": null,
                    "name": "object",
                    "type": "string"
                  },
                  {
                    "description": null,
                    "name": "data",
                    "type": "asset[]"
                  },
                  {
                    "description": null,
                    "name": "next_cursor",
                    "type": "string|null"
                  }
                ],
                "parameters": [
                  {
                    "availability": "source_interface",
                    "default": null,
                    "default_known": false,
                    "enum": null,
                    "enum_known": false,
                    "name": "family",
                    "required": false,
                    "type": "string"
                  },
                  {
                    "availability": "source_interface",
                    "default": null,
                    "default_known": false,
                    "enum": null,
                    "enum_known": false,
                    "name": "cursor",
                    "required": false,
                    "type": "string"
                  },
                  {
                    "availability": "source_interface",
                    "default": 20,
                    "default_known": true,
                    "enum": null,
                    "enum_known": false,
                    "maximum": 100,
                    "minimum": 1,
                    "name": "limit",
                    "required": false,
                    "type": "integer"
                  }
                ],
                "path": "/v1/media/assets"
              },
              "revoke": {
                "http": "DELETE",
                "meaning": "Revokes/deletes the existing owned file; this is not generation cancellation.",
                "path": "/v1/media/assets/{asset_id}",
                "pending_status": "revoking",
                "success_statuses": [
                  202,
                  204
                ]
              },
              "task": {
                "http": "GET",
                "id_source": "actual returned task_id or media library record; operation_id is not task_id",
                "path": "/v1/media/tasks/{task_id}"
              }
            },
            "operation_modes": [
              "text_to_image",
              "reference_images_generation_via_multipart"
            ],
            "outputs": {
              "all_results": "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ế.",
              "family": "image",
              "fields": [
                {
                  "description": null,
                  "name": "created",
                  "type": "integer"
                },
                {
                  "description": null,
                  "name": "data[].url",
                  "type": "string"
                },
                {
                  "description": null,
                  "name": "data[].b64_json",
                  "type": "base64 string"
                },
                {
                  "description": null,
                  "name": "usage",
                  "type": "object"
                }
              ],
              "format": "actual validated raster MIME"
            },
            "parameter_conditions": {
              "size": {
                "aspect_ratio_range": [
                  "1:8",
                  "8:1"
                ],
                "default": "1K",
                "max_area_4k_condition": "WanPro and no inputimages",
                "max_dimension": 4096,
                "maximum_area": 16777216,
                "minimum_area": 589824
              }
            },
            "parameters": [
              {
                "availability": "source_interface",
                "default": null,
                "default_known": false,
                "enum": [
                  "wan-image"
                ],
                "enum_known": true,
                "name": "model",
                "required": true,
                "type": "string"
              },
              {
                "availability": "source_interface",
                "default": null,
                "default_known": false,
                "enum": null,
                "enum_known": false,
                "min_length": 1,
                "name": "prompt",
                "required": true,
                "type": "string"
              },
              {
                "availability": "source_interface",
                "default": 1,
                "default_known": true,
                "enum": null,
                "enum_known": false,
                "minimum": 1,
                "name": "n",
                "required": false,
                "type": "integer"
              },
              {
                "availability": "source_interface",
                "default": null,
                "default_known": false,
                "enum": [
                  "url",
                  "b64_json"
                ],
                "enum_known": true,
                "name": "response_format",
                "required": false,
                "type": "string"
              },
              {
                "availability": "source_interface",
                "default": false,
                "default_known": true,
                "enum": null,
                "enum_known": false,
                "name": "stream",
                "required": false,
                "type": "boolean"
              },
              {
                "availability": "model_dependent",
                "default": null,
                "default_known": false,
                "enum": null,
                "enum_known": false,
                "name": "size",
                "required": false,
                "type": "string"
              },
              {
                "availability": "model_dependent",
                "default": null,
                "default_known": false,
                "enum": null,
                "enum_known": false,
                "name": "partial_images",
                "required": false,
                "type": "integer"
              },
              {
                "availability": "different_method",
                "conditions": "Một URL thực tế cho mỗi đối tượng images[]. Số phần tử mảng khác với nút lá dạng chuỗi này.",
                "decoded_max_bytes": 20971520,
                "default": null,
                "default_known": false,
                "enum": null,
                "enum_known": false,
                "maximum_images_per_array": 9,
                "mime_types": [
                  "image/png",
                  "image/jpeg"
                ],
                "name": "images[].image_url",
                "required": false,
                "type": "string",
                "when": "Chỉ JSON images/edits; JSON images/generations không phân tích các tham chiếu images."
              },
              {
                "availability": "source_interface",
                "default": null,
                "default_known": false,
                "enum": null,
                "enum_known": false,
                "maximum_decoded_bytes": 20971520,
                "mime_types": [
                  "image/png",
                  "image/jpeg"
                ],
                "name": "image",
                "required": false,
                "type": "file",
                "when": "tạo bằng multipart/form-data"
              },
              {
                "availability": "source_interface",
                "default": null,
                "default_known": false,
                "enum": null,
                "enum_known": false,
                "maximum_decoded_bytes": 20971520,
                "maximum_items": 9,
                "mime_types": [
                  "image/png",
                  "image/jpeg"
                ],
                "name": "image[]",
                "required": false,
                "type": "file[]",
                "when": "tạo bằng multipart/form-data"
              }
            ],
            "profile_binding": "Exact existing Ailoot model and method; interface constraints below do not assert provider qualification.",
            "unsupported": [
              "images[].file_id",
              "mask.file_id",
              "mask",
              "stream=true",
              "mask input is rejected by this Alibaba adapter"
            ]
          },
          "hints": [
            "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."
          ],
          "input": {
            "content_type": "application/json",
            "material_types": [
              "text"
            ],
            "optional_controls": null,
            "required": [
              "model",
              "prompt"
            ]
          },
          "lifecycle": {
            "assets": [
              {
                "http": "GET",
                "path": "/v1/media/assets"
              },
              {
                "http": "GET",
                "path": "/v1/media/assets/{asset_id}"
              }
            ],
            "content": [
              {
                "http": "GET",
                "path": "/v1/media/assets/{asset_id}/content",
                "url_source": "exact returned signed URL; never construct token"
              }
            ],
            "mode": "synchronous_result_then_owned_library",
            "operation_id_is_not_task_id": true,
            "status": [
              {
                "http": "GET",
                "id_source": "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",
                "path": "/v1/media/tasks/{task_id}"
              }
            ],
            "unknown": "If an image generation or edit result requires a check, keep the original operation_id/X-Client-Request-ID and returned result information. Recover existing owned results through the media library using actual task_id or asset_id values. Do not resubmit the generation/edit request or construct a polling URL from operation_id."
          },
          "method": {
            "http": "POST",
            "path": "/v1/images/generations"
          },
          "operation_modes": [
            "images"
          ],
          "output": {
            "family": [
              "image"
            ],
            "format": null,
            "multioutputs": "retain every actual response output"
          }
        },
        "ctx": null,
        "examples": [
          {
            "code": "set -eu\n: \"${AILOOT_API_KEY:?Set your Ailoot API key}\"\nexport AILOOT_API_KEY\nexport AILOOT_API_KEY\n: \"${AILOOT_PROMPT_FILE:?Set your actual UTF-8 image brief}\"\nexport AILOOT_PROMPT_FILE\npython3 - <<'PY_REQUEST'\nimport json,os\nfrom pathlib import Path\np=json.loads('{\"model\": \"wan-image\", \"prompt\": \"\"}')\nf=Path(os.environ[\"AILOOT_PROMPT_FILE\"])\nif not f.is_file():raise SystemExit(\"Choose your actual UTF-8 brief\")\np['prompt']=f.read_text(encoding=\"utf-8\")\nif not p['prompt'].strip():raise SystemExit(\"Brief must contain text\")\nPath(\"request.json\").write_text(json.dumps(p,ensure_ascii=False))\nPY_REQUEST\ncurl --fail-with-body --silent --show-error https://api.ailoot.ai/v1/images/generations \\\n  -H \"Authorization: Bearer $AILOOT_API_KEY\" -H 'Content-Type: application/json' \\\n  --data-binary @request.json -D response-headers.txt -o result.json\npython3 - <<'PY_RESULT'\nimport base64, json, os, subprocess\nfrom pathlib import Path\nfrom urllib.parse import urlsplit, urljoin\n\ndef save_images(items):\n    if not items: raise SystemExit(\"No completed images; retain the full response\")\n    for index, item in enumerate(items):\n        encoded=item.get(\"b64_json\")\n        uri=item.get(\"url\", \"\")\n        if not encoded and uri.startswith(\"data:image/\"):\n            header, separator, encoded=uri.partition(\",\")\n            if not separator or \";base64\" not in header: raise SystemExit(\"Unsupported image data URI\")\n        if encoded:\n            raw=base64.b64decode(encoded,validate=True)\n        elif uri:\n            uri=urljoin(\"https://api.ailoot.ai\",uri)\n            parsed=urlsplit(uri)\n            if parsed.scheme!=\"https\" or not parsed.netloc or parsed.username or parsed.password:\n                raise SystemExit(\"Invalid returned image URL\")\n            owned=parsed.netloc==\"api.ailoot.ai\" and parsed.path.startswith(\"/v1/media/assets/\") and parsed.path.endswith(\"/content\")\n            args=[\"curl\",\"--fail-with-body\",\"--silent\",\"--show-error\",uri]\n            if owned: args += [\"-H\",\"Authorization: Bearer \"+os.environ[\"AILOOT_API_KEY\"]]\n            temporary=Path(f\"image-{index}.bin\")\n            subprocess.run(args+[\"-o\",str(temporary)],check=True)\n            raw=temporary.read_bytes()\n            temporary.unlink()\n        else: raise SystemExit(\"Image has neither bytes nor URL\")\n        if not raw: raise SystemExit(\"Empty image result\")\n        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\"\n        Path(f\"image-{index}.{ext}\").write_bytes(raw)\n    print(\"Every returned image saved; complete response metadata retained\")\nsave_images(json.loads(Path(\"result.json\").read_text())[\"data\"])\nPY_RESULT\n",
            "label": "Create and save every image",
            "language": "bash"
          },
          {
            "code": "from openai import OpenAI\nimport base64, json, os, subprocess\nfrom pathlib import Path\nfrom urllib.parse import urlsplit, urljoin\n\ndef save_images(items):\n    if not items: raise SystemExit(\"No completed images; retain the full response\")\n    for index, item in enumerate(items):\n        encoded=item.get(\"b64_json\")\n        uri=item.get(\"url\", \"\")\n        if not encoded and uri.startswith(\"data:image/\"):\n            header, separator, encoded=uri.partition(\",\")\n            if not separator or \";base64\" not in header: raise SystemExit(\"Unsupported image data URI\")\n        if encoded:\n            raw=base64.b64decode(encoded,validate=True)\n        elif uri:\n            uri=urljoin(\"https://api.ailoot.ai\",uri)\n            parsed=urlsplit(uri)\n            if parsed.scheme!=\"https\" or not parsed.netloc or parsed.username or parsed.password:\n                raise SystemExit(\"Invalid returned image URL\")\n            owned=parsed.netloc==\"api.ailoot.ai\" and parsed.path.startswith(\"/v1/media/assets/\") and parsed.path.endswith(\"/content\")\n            args=[\"curl\",\"--fail-with-body\",\"--silent\",\"--show-error\",uri]\n            if owned: args += [\"-H\",\"Authorization: Bearer \"+os.environ[\"AILOOT_API_KEY\"]]\n            temporary=Path(f\"image-{index}.bin\")\n            subprocess.run(args+[\"-o\",str(temporary)],check=True)\n            raw=temporary.read_bytes()\n            temporary.unlink()\n        else: raise SystemExit(\"Image has neither bytes nor URL\")\n        if not raw: raise SystemExit(\"Empty image result\")\n        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\"\n        Path(f\"image-{index}.{ext}\").write_bytes(raw)\n    print(\"Every returned image saved; complete response metadata retained\")\n\nf=Path(os.environ[\"AILOOT_PROMPT_FILE\"])\nif not f.is_file():raise SystemExit(\"Set your actual UTF-8 image brief file\")\nrequest={'model': 'wan-image', 'prompt': ''}\nrequest[\"prompt\"]=f.read_text(encoding=\"utf-8\")\nclient=OpenAI(base_url=\"https://api.ailoot.ai/v1\",api_key=os.environ[\"AILOOT_API_KEY\"],max_retries=0)\nresult=client.images.generate(**request)\nPath(\"sdk-result.txt\").write_text(str(result),encoding=\"utf-8\")\nsave_images([{\"b64_json\":getattr(item,\"b64_json\",None),\"url\":getattr(item,\"url\",None)} for item in result.data])\n",
            "label": "Python SDK · save all image outputs",
            "language": "python"
          },
          {
            "code": "import OpenAI from \"openai\";\nimport { readFileSync, writeFileSync } from \"node:fs\";\nconst key=process.env.AILOOT_API_KEY;\nif(!key) throw new Error(\"Set your actual Ailoot API key\");\nconst client=new OpenAI({baseURL:\"https://api.ailoot.ai/v1\",apiKey:key,maxRetries:0});\nconst request={\"model\": \"wan-image\", \"prompt\": \"\"};\nif(!process.env.AILOOT_PROMPT_FILE)throw new Error(\"Set your actual UTF-8 image brief file\");\nrequest.prompt=readFileSync(process.env.AILOOT_PROMPT_FILE,\"utf8\");\nconst result=await client.images.generate(request);\nwriteFileSync(\"sdk-result.json\",JSON.stringify(result,null,2));\nif(!result.data?.length) throw new Error(\"No completed images\");\nfor(let index=0;index<result.data.length;index++) {\n  const item=result.data[index];let encoded=item.b64_json,uri=item.url||\"\",raw;\n  if(!encoded && uri.startsWith(\"data:image/\")) {\n    const comma=uri.indexOf(\",\");if(comma<0 || !uri.slice(0,comma).includes(\";base64\")) throw new Error(\"Unsupported image data URI\");\n    encoded=uri.slice(comma+1);\n  }\n  if(encoded) {\n    if(encoded.length%4!==0 || !/^[A-Za-z0-9+/]*={0,2}$/.test(encoded)) throw new Error(\"Invalid Base64\");\n    raw=Buffer.from(encoded,\"base64\");\n  } else if(uri) {\n    const u=new URL(uri,\"https://api.ailoot.ai\");\n    if(u.protocol!==\"https:\" || u.username || u.password) throw new Error(\"Invalid returned URL\");\n    const owned=u.origin===\"https://api.ailoot.ai\" && u.pathname.startsWith(\"/v1/media/assets/\") && u.pathname.endsWith(\"/content\");\n    const response=await fetch(u,{headers:owned?{Authorization:\"Bearer \"+key}:{},redirect:\"manual\"});\n    if(!response.ok) throw new Error(\"Image content download failed: \"+response.status);\n    raw=Buffer.from(await response.arrayBuffer());\n  } else throw new Error(\"Image has neither bytes nor URL\");\n  if(!raw.length) throw new Error(\"Empty image result\");\n  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\";\n  writeFileSync(`image-${index}.${ext}`,raw);\n}\nconsole.log(\"Every returned image saved; sdk-result.json retains complete metadata\");\n",
            "label": "Node SDK · save all image outputs",
            "language": "js"
          }
        ],
        "family": "openai",
        "fast_multiplier": null,
        "flex_multiplier": null,
        "fmt": "images",
        "http": "POST",
        "img_in": null,
        "img_out": null,
        "in": null,
        "input": [
          "text"
        ],
        "label": "Ảnh",
        "max_out": null,
        "max_tool_calls": null,
        "out": null,
        "output": [
          "image"
        ],
        "path": "/v1/images/generations",
        "pricing_profiles": [
          {
            "dimensions": {},
            "label": "Core",
            "units": [
              {
                "amount": 0.075,
                "amount_unit": "usd_per_display_unit",
                "key": "image_output_1k",
                "label": "per 1K image",
                "side": "out"
              },
              {
                "amount": 0.075,
                "amount_unit": "usd_per_display_unit",
                "key": "image_output_2k",
                "label": "per 2K image",
                "side": "out"
              }
            ]
          }
        ],
        "request_model_id": "wan-image",
        "route_label": "Core",
        "status_reads": [],
        "tiers": [],
        "tool_prices": null,
        "unit": "conditional",
        "units": [
          {
            "key": "image_output_1k",
            "label": "per 1K image",
            "side": "out",
            "usd": 0.075
          },
          {
            "key": "image_output_2k",
            "label": "per 2K image",
            "side": "out",
            "usd": 0.075
          }
        ]
      }
    },
    {
      "html": "<div class=\"sheet-head\"><span class=\"mav\" aria-hidden=\"true\">Al</span><h2 id=\"sheet-title\">wan2.7-image-pro</h2><button class=\"icon-btn\" type=\"button\" data-close-sheet aria-label=\"Đóng\">×</button></div><div class=\"idline\"><span>Alibaba /</span><code>wan-image-latest</code><button type=\"button\" id=\"copy-id\">Sao chép ID</button></div><nav class=\"card-jump-nav\" aria-label=\"Các phần của thẻ mô hình\"><button type=\"button\" data-card-jump=\"overview\">Bắt đầu</button><button type=\"button\" data-card-jump=\"methods\">Đầu vào &amp; phương thức</button><button type=\"button\" data-card-jump=\"pricing\">Bảng giá</button><button type=\"button\" data-card-jump=\"examples\">Ví dụ</button><button type=\"button\" data-card-jump=\"results\">Kết quả</button><button type=\"button\" data-card-jump=\"aliases\">Bí danh</button></nav><div class=\"card-method-tabs\" role=\"tablist\" aria-label=\"Phương thức API\"><button type=\"button\" role=\"tab\" tabindex=\"0\" aria-controls=\"card-method-content\" aria-selected=\"true\" id=\"card-method-tab-0\" data-card-method=\"Core|images|/v1/images/generations|wan-image-latest\">Ảnh</button></div><div class=\"idline\"><label for=\"card-model-id\">ID mô hình</label><select class=\"sel\" id=\"card-model-id\" style=\"min-width:0;max-width:100%\"><option value=\"Core|images|/v1/images/generations|wan2.7-image-pro\">wan2.7-image-pro</option><option value=\"Core|images|/v1/images/generations|wan-image\">wan-image</option><option value=\"Core|images|/v1/images/generations|wan-image-latest\" selected>wan-image-latest</option></select></div><div id=\"card-method-content\" role=\"tabpanel\" aria-labelledby=\"card-method-tab-0\"><section class=\"card-section\" data-card-section=\"overview\"><h3 tabindex=\"-1\">Bắt đầu</h3><p class=\"mdesc-full\">Mô hình tạo ảnh từ yêu cầu bằng văn bản. Nhà sản xuất cho phép điều khiển bảng màu và độ phân giải tối đa 4K khi tạo ảnh thông thường từ văn bản.</p><dl class=\"card-io\" data-card-io><div><dt>Đầu vào được chấp nhận</dt><dd>Văn bản</dd></div><div><dt>Kết quả</dt><dd>Ảnh</dd></div></dl><details class=\"card-about\"><summary>Về mô hình</summary><p class=\"note-s\" data-model-method-boundary>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.</p><div class=\"mabout\" id=\"m-about\"><p>Wan2.7-Image-Pro là mô hình của Alibaba để tạo ảnh từ văn bản. Thẻ Ailoot hiện tại công bố đầu vào văn bản và kết quả dạng ảnh. Nhà sản xuất còn cung cấp chỉnh sửa, kết hợp ảnh tham chiếu và thay đổi cục bộ; các cách này cần hỗ trợ đầu vào ảnh riêng và không được cung cấp qua phương thức hiện tại của thẻ.</p><p>Trong chế độ dùng ảnh tham chiếu của nhà sản xuất, có thể gửi tối đa chín ảnh nguồn và mô tả những yếu tố cần sử dụng từ mỗi ảnh. Khi chỉnh sửa, mô hình giữ đối tượng chính, thay đổi các chi tiết đã chọn hoặc ghép nhiều tư liệu thành bố cục mới. Để định hướng thay đổi chính xác hơn, có thể xác định tối đa hai vùng hình chữ nhật trên một ảnh đầu vào.</p><h4>Bảng màu và yêu cầu phức tạp</h4><p>Ngoài các chuỗi liên tiếp, có thể đặt bảng màu gồm 3–10 màu. Chế độ suy luận dành cho việc tạo ảnh thông thường từ văn bản, không dùng ảnh tham chiếu hoặc chuỗi liên tiếp: mô hình phân tích trước mô tả của cảnh.</p><p>Trong đặc tả Alibaba, đầu ra thông thường gồm từ một đến bốn ảnh. Với chuỗi theo cốt truyện, có thể đặt giới hạn trên tối đa 12 ảnh; mô hình chọn số lượng thực tế theo yêu cầu. Chuỗi có thể sử dụng văn bản và ảnh tham chiếu để giữ các đặc điểm chung của nhân vật và diễn biến câu chuyện liền mạch. Bảng màu và suy luận không được áp dụng ở chế độ này.</p><h4>Độ phân giải phụ thuộc vào chế độ</h4><p>Mức 4K được hỗ trợ khi tạo ảnh thông thường từ văn bản, không dùng ảnh tham chiếu hoặc chuỗi liên tiếp. Chỉnh sửa dựa trên ảnh và chuỗi liên tiếp bị giới hạn ở mức 2K. Các ký hiệu này xác định diện tích pixel, không phải độ dài bằng nhau của mỗi cạnh. Có thể chọn tỷ lệ khung hình từ 1:8 đến 8:1; khi chỉnh sửa với độ phân giải đặt sẵn, tỷ lệ khung hình theo ảnh tham chiếu cuối cùng. Kết quả được lưu ở định dạng PNG.</p><p>Với những cách sử dụng ảnh đầu vào, Alibaba chấp nhận JPEG, JPG, PNG không có độ trong suốt, BMP và WEBP. Các giới hạn là 20 MB mỗi tệp, từ 240 đến 8000 pixel cho mỗi chiều và tỷ lệ từ 1:8 đến 8:1. Yêu cầu bằng văn bản hỗ trợ tiếng Trung và tiếng Anh; tối đa 5000 ký tự, phần dư bị cắt bỏ. Phiên bản này không có mô tả phủ định hoặc mở rộng yêu cầu. Hạt giống ngẫu nhiên giúp giữ nét tương đồng giữa các phương án, nhưng không bảo đảm lặp lại chính xác.</p></div></details></section><section class=\"card-section\" data-card-section=\"methods\"><h3 tabindex=\"-1\">Có trên Ailoot · đầu vào &amp; phương thức</h3><details class=\"card-method\" open><summary><b>Ailoot · Ảnh</b> <code>POST /v1/images/generations</code></summary><dl class=\"method-capabilities\"><div><dt>Đầu vào</dt><dd><code>text</code></dd></div><div><dt>Đầu ra</dt><dd><code>image</code></dd></div><div><dt>Định dạng đầu ra</dt><dd>Tệp ảnh</dd></div></dl><div class=\"tw\" data-card-parameters data-typed-parameters><table><thead><tr><th>Trường</th><th>Loại</th><th>Yêu cầu</th><th>Giá trị &amp; giới hạn</th><th>Mặc định</th></tr></thead><tbody><tr data-parameter-availability=\"source_interface\"><th data-cell-label=\"Trường\" scope=\"row\"><span class=\"card-cell-label\">Trường</span><code class=\"card-field-name\">model</code></th><td data-cell-label=\"Loại\" data-field-type><span class=\"card-cell-label\">Loại</span><code>string</code></td><td data-cell-label=\"Yêu cầu\"><span class=\"card-cell-label\">Yêu cầu</span>Bắt buộc</td><td data-cell-label=\"Giá trị &amp; giới hạn\"><span class=\"card-cell-label\">Giá trị &amp; giới hạn</span><div>wan-image-latest</div></td><td data-cell-label=\"Mặc định\" data-default=\"unspecified\"><span class=\"card-cell-label\">Mặc định</span>—</td></tr><tr data-parameter-availability=\"source_interface\"><th data-cell-label=\"Trường\" scope=\"row\"><span class=\"card-cell-label\">Trường</span><code class=\"card-field-name\">prompt</code></th><td data-cell-label=\"Loại\" data-field-type><span class=\"card-cell-label\">Loại</span><code>string</code></td><td data-cell-label=\"Yêu cầu\"><span class=\"card-cell-label\">Yêu cầu</span>Bắt buộc</td><td data-cell-label=\"Giá trị &amp; giới hạn\"><span class=\"card-cell-label\">Giá trị &amp; giới hạn</span><div>Độ dài tối thiểu: 1</div></td><td data-cell-label=\"Mặc định\" data-default=\"unspecified\"><span class=\"card-cell-label\">Mặc định</span>—</td></tr><tr data-parameter-availability=\"source_interface\"><th data-cell-label=\"Trường\" scope=\"row\"><span class=\"card-cell-label\">Trường</span><code class=\"card-field-name\">n</code></th><td data-cell-label=\"Loại\" data-field-type><span class=\"card-cell-label\">Loại</span><code>integer</code></td><td data-cell-label=\"Yêu cầu\"><span class=\"card-cell-label\">Yêu cầu</span>Không bắt buộc</td><td data-cell-label=\"Giá trị &amp; giới hạn\"><span class=\"card-cell-label\">Giá trị &amp; giới hạn</span><div>Tối thiểu: 1</div></td><td data-cell-label=\"Mặc định\" data-default=\"known\"><span class=\"card-cell-label\">Mặc định</span>1</td></tr><tr data-parameter-availability=\"source_interface\"><th data-cell-label=\"Trường\" scope=\"row\"><span class=\"card-cell-label\">Trường</span><code class=\"card-field-name\">response_format</code></th><td data-cell-label=\"Loại\" data-field-type><span class=\"card-cell-label\">Loại</span><code>string</code></td><td data-cell-label=\"Yêu cầu\"><span class=\"card-cell-label\">Yêu cầu</span>Không bắt buộc</td><td data-cell-label=\"Giá trị &amp; giới hạn\"><span class=\"card-cell-label\">Giá trị &amp; giới hạn</span><div>url, b64_json</div></td><td data-cell-label=\"Mặc định\" data-default=\"unspecified\"><span class=\"card-cell-label\">Mặc định</span>—</td></tr><tr data-parameter-availability=\"source_interface\"><th data-cell-label=\"Trường\" scope=\"row\"><span class=\"card-cell-label\">Trường</span><code class=\"card-field-name\">stream</code></th><td data-cell-label=\"Loại\" data-field-type><span class=\"card-cell-label\">Loại</span><code>boolean</code></td><td data-cell-label=\"Yêu cầu\"><span class=\"card-cell-label\">Yêu cầu</span>Không bắt buộc</td><td data-cell-label=\"Giá trị &amp; giới hạn\"><span class=\"card-cell-label\">Giá trị &amp; giới hạn</span></td><td data-cell-label=\"Mặc định\" data-default=\"known\"><span class=\"card-cell-label\">Mặc định</span>false</td></tr><tr data-parameter-availability=\"model_dependent\"><th data-cell-label=\"Trường\" scope=\"row\"><span class=\"card-cell-label\">Trường</span><code class=\"card-field-name\">size</code></th><td data-cell-label=\"Loại\" data-field-type><span class=\"card-cell-label\">Loại</span><code>string</code></td><td data-cell-label=\"Yêu cầu\"><span class=\"card-cell-label\">Yêu cầu</span>Không bắt buộc</td><td data-cell-label=\"Giá trị &amp; giới hạn\"><span class=\"card-cell-label\">Giá trị &amp; giới hạn</span><div class=\"note-s\">Tùy thuộc vào mô hình</div></td><td data-cell-label=\"Mặc định\" data-default=\"unspecified\"><span class=\"card-cell-label\">Mặc định</span>—</td></tr><tr data-parameter-availability=\"model_dependent\"><th data-cell-label=\"Trường\" scope=\"row\"><span class=\"card-cell-label\">Trường</span><code class=\"card-field-name\">partial_images</code></th><td data-cell-label=\"Loại\" data-field-type><span class=\"card-cell-label\">Loại</span><code>integer</code></td><td data-cell-label=\"Yêu cầu\"><span class=\"card-cell-label\">Yêu cầu</span>Không bắt buộc</td><td data-cell-label=\"Giá trị &amp; giới hạn\"><span class=\"card-cell-label\">Giá trị &amp; giới hạn</span><div class=\"note-s\">Tùy thuộc vào mô hình</div></td><td data-cell-label=\"Mặc định\" data-default=\"unspecified\"><span class=\"card-cell-label\">Mặc định</span>—</td></tr><tr data-parameter-availability=\"different_method\"><th data-cell-label=\"Trường\" scope=\"row\"><span class=\"card-cell-label\">Trường</span><code class=\"card-field-name\">images[].image_url</code></th><td data-cell-label=\"Loại\" data-field-type><span class=\"card-cell-label\">Loại</span><code>string</code></td><td data-cell-label=\"Yêu cầu\"><span class=\"card-cell-label\">Yêu cầu</span>Không hỗ trợ</td><td data-cell-label=\"Giá trị &amp; giới hạn\"><span class=\"card-cell-label\">Giá trị &amp; giới hạn</span><div>Số byte tối đa sau giải mã: 20.971.520</div><div>Loại MIME: image/png, image/jpeg</div><div>Số ảnh tối đa mỗi mảng: 9</div><div>Điều kiện: Một URL thực tế cho mỗi đối tượng images[]. Số phần tử mảng khác với nút lá dạng chuỗi này.</div><div>Áp dụng khi: Chỉ JSON images/edits; JSON images/generations không phân tích các tham chiếu images.</div></td><td data-cell-label=\"Mặc định\" data-default=\"unspecified\"><span class=\"card-cell-label\">Mặc định</span>—</td></tr><tr data-parameter-availability=\"source_interface\"><th data-cell-label=\"Trường\" scope=\"row\"><span class=\"card-cell-label\">Trường</span><code class=\"card-field-name\">image</code></th><td data-cell-label=\"Loại\" data-field-type><span class=\"card-cell-label\">Loại</span><code>file</code></td><td data-cell-label=\"Yêu cầu\"><span class=\"card-cell-label\">Yêu cầu</span>Không bắt buộc</td><td data-cell-label=\"Giá trị &amp; giới hạn\"><span class=\"card-cell-label\">Giá trị &amp; giới hạn</span><div>Số byte tối đa sau giải mã: 20.971.520</div><div>Loại MIME: image/png, image/jpeg</div><div>Áp dụng khi: tạo bằng multipart/form-data</div></td><td data-cell-label=\"Mặc định\" data-default=\"unspecified\"><span class=\"card-cell-label\">Mặc định</span>—</td></tr><tr data-parameter-availability=\"source_interface\"><th data-cell-label=\"Trường\" scope=\"row\"><span class=\"card-cell-label\">Trường</span><code class=\"card-field-name\">image[]</code></th><td data-cell-label=\"Loại\" data-field-type><span class=\"card-cell-label\">Loại</span><code>file[]</code></td><td data-cell-label=\"Yêu cầu\"><span class=\"card-cell-label\">Yêu cầu</span>Không bắt buộc</td><td data-cell-label=\"Giá trị &amp; giới hạn\"><span class=\"card-cell-label\">Giá trị &amp; giới hạn</span><div>Số mục tối đa: 9</div><div>Số byte tối đa sau giải mã: 20.971.520</div><div>Loại MIME: image/png, image/jpeg</div><div>Áp dụng khi: tạo bằng multipart/form-data</div></td><td data-cell-label=\"Mặc định\" data-default=\"unspecified\"><span class=\"card-cell-label\">Mặc định</span>—</td></tr></tbody></table></div><details class=\"card-about\" data-material-combinations><summary>Tổ hợp tư liệu đầu vào</summary><p class=\"note-s\"><b>Văn bản thành ảnh</b> · Bắt buộc: prompt</p><p class=\"note-s\"><b>reference_images_generation</b> · Bắt buộc: prompt</p></details><details class=\"note-s\" data-method-contract><summary>Tham số phương thức và vòng đời</summary><div class=\"tw\" data-card-table=\"contract\"><table><thead><tr><th>Tham số</th><th>Hợp đồng</th></tr></thead><tbody><tr><th data-cell-label=\"Tham số\" scope=\"row\"><span class=\"card-cell-label\">Tham số</span><code>material_types</code></th><td data-cell-label=\"Hợp đồng\"><span class=\"card-cell-label\">Hợp đồng</span>text</td></tr><tr><th data-cell-label=\"Tham số\" scope=\"row\"><span class=\"card-cell-label\">Tham số</span><code>required</code></th><td data-cell-label=\"Hợp đồng\"><span class=\"card-cell-label\">Hợp đồng</span>model, prompt</td></tr><tr><th data-cell-label=\"Tham số\" scope=\"row\"><span class=\"card-cell-label\">Tham số</span><code>optional_controls</code></th><td data-cell-label=\"Hợp đồng\"><span class=\"card-cell-label\">Hợp đồng</span>null</td></tr><tr><th data-cell-label=\"Tham số\" scope=\"row\"><span class=\"card-cell-label\">Tham số</span><code>content_type</code></th><td data-cell-label=\"Hợp đồng\"><span class=\"card-cell-label\">Hợp đồng</span>application/json</td></tr></tbody></table></div><p>Vòng đời: <code>synchronous_result_then_owned_library</code></p><p class=\"note-s\"><code>GET /v1/media/tasks/{task_id}</code> · 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</p><p class=\"note-s\"><code>GET /v1/media/assets/{asset_id}/content</code></p><p class=\"note-s\"><code>GET /v1/media/assets</code></p><p class=\"note-s\"><code>GET /v1/media/assets/{asset_id}</code></p><p class=\"note-s\">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.</p></details></details></section><section class=\"card-section\" data-card-section=\"pricing\"><h3 tabindex=\"-1\">Bảng giá</h3><h4>Mức phí phương thức Ailoot</h4><section class=\"meth\" data-route=\"Core\"><header><b><span class=\"alias\">Ailoot</span> Ảnh</b><code>POST /v1/images/generations</code></header><dl><div><dt>Đầu ra</dt><dd>0,075 US$ <em>mỗi ảnh 1K</em></dd></div><div><dt>Đầu ra</dt><dd>0,075 US$ <em>mỗi ảnh 2K</em></dd></div></dl></section><p class=\"note-s\">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. <a href=\"/docs/vi/billing/reserve/\">Cách hoạt động của cơ chế tạm giữ và quyết toán →</a></p><div data-declared-reference-pricing><h4>Chi tiết giá cước tham chiếu</h4><p class=\"note-s\">Biểu tham chiếu cấp mô hình không thay đổi việc chọn phương thức, báo giá hoặc khoản phí. Khoản phí đang áp dụng dùng mức phí phương thức Ailoot đã chọn.</p><details class=\"card-price-reference\" data-declared-reference-group data-client-selectable=\"false\"><summary>wan2.7-image-pro</summary><h4>Giá theo cấu hình</h4><div class=\"tw\" data-pricing-profiles><table><thead><tr><th>Cấu hình</th><th>Điều kiện tính phí</th><th>Phí</th></tr></thead><tbody><tr><th data-cell-label=\"Cấu hình\" scope=\"row\"><span class=\"card-cell-label\">Cấu hình</span>wan2.7-image-pro · Cấu hình mặc định</th><td data-cell-label=\"Điều kiện tính phí\"><span class=\"card-cell-label\">Điều kiện tính phí</span>Cấu hình mặc định</td><td data-cell-label=\"Phí\"><span class=\"card-cell-label\">Phí</span><div><span>Đầu vào · Đầu vào</span> <b>0,00 US$</b> <span class=\"price-unit\">mỗi lần gọi</span></div><div><span>Đầu ra · Đầu ra</span> <b>0,16 US$</b> <span class=\"price-unit\">mỗi lần gọi</span></div></td></tr></tbody></table></div></details></div></section><section class=\"card-section\" data-card-section=\"examples\"><h3 tabindex=\"-1\">Ví dụ yêu cầu</h3><h4>Ailoot · Ảnh</h4><div class=\"code-group\"><div class=\"cg-bar\"><div class=\"cg-tabs\" role=\"tablist\" aria-label=\"Các phiên bản mã\"><button class=\"cg-tab\" id=\"model-code-106-tab-0\" role=\"tab\" type=\"button\" aria-controls=\"model-code-106-panel-0\" aria-selected=\"true\" tabindex=\"0\">curl</button><button class=\"cg-tab\" id=\"model-code-106-tab-1\" role=\"tab\" type=\"button\" aria-controls=\"model-code-106-panel-1\" aria-selected=\"false\" tabindex=\"-1\">Python SDK</button><button class=\"cg-tab\" id=\"model-code-106-tab-2\" role=\"tab\" type=\"button\" aria-controls=\"model-code-106-panel-2\" aria-selected=\"false\" tabindex=\"-1\">Node.js SDK</button></div><div class=\"cg-tools\"><button class=\"cg-btn cg-copy\" type=\"button\" aria-label=\"Sao chép mã\"><svg class=\"cp\" viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.4\"><rect x=\"5.25\" y=\"5.25\" width=\"8.5\" height=\"8.5\" rx=\"1.75\"/><path d=\"M10.75 5.25V3.5a1.25 1.25 0 0 0-1.25-1.25H3.5A1.25 1.25 0 0 0 2.25 3.5v6a1.25 1.25 0 0 0 1.25 1.25h1.75\"/></svg><svg class=\"ok\" viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.4\"><path d=\"m3 8.5 3.25 3.25L13 5\"/></svg></button></div></div><div class=\"cg-body\"><div class=\"cg-pane\" id=\"model-code-106-panel-0\" role=\"tabpanel\" aria-labelledby=\"model-code-106-tab-0\"><pre data-lang=\"bash\"><code>set -eu\n: &quot;${AILOOT_API_KEY:?Set your Ailoot API key}&quot;\nexport AILOOT_API_KEY\nexport AILOOT_API_KEY\n: &quot;${AILOOT_PROMPT_FILE:?Set your actual UTF-8 image brief}&quot;\nexport AILOOT_PROMPT_FILE\npython3 - &lt;&lt;&#39;PY_REQUEST&#39;\nimport json,os\nfrom pathlib import Path\np=json.loads(&#39;{&quot;model&quot;: &quot;wan-image-latest&quot;, &quot;prompt&quot;: &quot;&quot;}&#39;)\nf=Path(os.environ[&quot;AILOOT_PROMPT_FILE&quot;])\nif not f.is_file():raise SystemExit(&quot;Choose your actual UTF-8 brief&quot;)\np[&#39;prompt&#39;]=f.read_text(encoding=&quot;utf-8&quot;)\nif not p[&#39;prompt&#39;].strip():raise SystemExit(&quot;Brief must contain text&quot;)\nPath(&quot;request.json&quot;).write_text(json.dumps(p,ensure_ascii=False))\nPY_REQUEST\ncurl --fail-with-body --silent --show-error https://api.ailoot.ai/v1/images/generations \\\n  -H &quot;Authorization: Bearer $AILOOT_API_KEY&quot; -H &#39;Content-Type: application/json&#39; \\\n  --data-binary @request.json -D response-headers.txt -o result.json\npython3 - &lt;&lt;&#39;PY_RESULT&#39;\nimport base64, json, os, subprocess\nfrom pathlib import Path\nfrom urllib.parse import urlsplit, urljoin\n\ndef save_images(items):\n    if not items: raise SystemExit(&quot;No completed images; retain the full response&quot;)\n    for index, item in enumerate(items):\n        encoded=item.get(&quot;b64_json&quot;)\n        uri=item.get(&quot;url&quot;, &quot;&quot;)\n        if not encoded and uri.startswith(&quot;data:image/&quot;):\n            header, separator, encoded=uri.partition(&quot;,&quot;)\n            if not separator or &quot;;base64&quot; not in header: raise SystemExit(&quot;Unsupported image data URI&quot;)\n        if encoded:\n            raw=base64.b64decode(encoded,validate=True)\n        elif uri:\n            uri=urljoin(&quot;https://api.ailoot.ai&quot;,uri)\n            parsed=urlsplit(uri)\n            if parsed.scheme!=&quot;https&quot; or not parsed.netloc or parsed.username or parsed.password:\n                raise SystemExit(&quot;Invalid returned image URL&quot;)\n            owned=parsed.netloc==&quot;api.ailoot.ai&quot; and parsed.path.startswith(&quot;/v1/media/assets/&quot;) and parsed.path.endswith(&quot;/content&quot;)\n            args=[&quot;curl&quot;,&quot;--fail-with-body&quot;,&quot;--silent&quot;,&quot;--show-error&quot;,uri]\n            if owned: args += [&quot;-H&quot;,&quot;Authorization: Bearer &quot;+os.environ[&quot;AILOOT_API_KEY&quot;]]\n            temporary=Path(f&quot;image-{index}.bin&quot;)\n            subprocess.run(args+[&quot;-o&quot;,str(temporary)],check=True)\n            raw=temporary.read_bytes()\n            temporary.unlink()\n        else: raise SystemExit(&quot;Image has neither bytes nor URL&quot;)\n        if not raw: raise SystemExit(&quot;Empty image result&quot;)\n        ext=&quot;png&quot; if raw.startswith(b&quot;\\x89PNG&quot;) else &quot;jpg&quot; if raw.startswith(b&quot;\\xff\\xd8&quot;) else &quot;webp&quot; if raw[:4]==b&quot;RIFF&quot; and raw[8:12]==b&quot;WEBP&quot; else &quot;svg&quot; if raw.lstrip().startswith((b&quot;&lt;svg&quot;,b&quot;&lt;?xml&quot;)) else &quot;bin&quot;\n        Path(f&quot;image-{index}.{ext}&quot;).write_bytes(raw)\n    print(&quot;Every returned image saved; complete response metadata retained&quot;)\nsave_images(json.loads(Path(&quot;result.json&quot;).read_text())[&quot;data&quot;])\nPY_RESULT\n</code></pre></div><div class=\"cg-pane\" id=\"model-code-106-panel-1\" role=\"tabpanel\" aria-labelledby=\"model-code-106-tab-1\" hidden><pre data-lang=\"python\"><code>from openai import OpenAI\nimport base64, json, os, subprocess\nfrom pathlib import Path\nfrom urllib.parse import urlsplit, urljoin\n\ndef save_images(items):\n    if not items: raise SystemExit(&quot;No completed images; retain the full response&quot;)\n    for index, item in enumerate(items):\n        encoded=item.get(&quot;b64_json&quot;)\n        uri=item.get(&quot;url&quot;, &quot;&quot;)\n        if not encoded and uri.startswith(&quot;data:image/&quot;):\n            header, separator, encoded=uri.partition(&quot;,&quot;)\n            if not separator or &quot;;base64&quot; not in header: raise SystemExit(&quot;Unsupported image data URI&quot;)\n        if encoded:\n            raw=base64.b64decode(encoded,validate=True)\n        elif uri:\n            uri=urljoin(&quot;https://api.ailoot.ai&quot;,uri)\n            parsed=urlsplit(uri)\n            if parsed.scheme!=&quot;https&quot; or not parsed.netloc or parsed.username or parsed.password:\n                raise SystemExit(&quot;Invalid returned image URL&quot;)\n            owned=parsed.netloc==&quot;api.ailoot.ai&quot; and parsed.path.startswith(&quot;/v1/media/assets/&quot;) and parsed.path.endswith(&quot;/content&quot;)\n            args=[&quot;curl&quot;,&quot;--fail-with-body&quot;,&quot;--silent&quot;,&quot;--show-error&quot;,uri]\n            if owned: args += [&quot;-H&quot;,&quot;Authorization: Bearer &quot;+os.environ[&quot;AILOOT_API_KEY&quot;]]\n            temporary=Path(f&quot;image-{index}.bin&quot;)\n            subprocess.run(args+[&quot;-o&quot;,str(temporary)],check=True)\n            raw=temporary.read_bytes()\n            temporary.unlink()\n        else: raise SystemExit(&quot;Image has neither bytes nor URL&quot;)\n        if not raw: raise SystemExit(&quot;Empty image result&quot;)\n        ext=&quot;png&quot; if raw.startswith(b&quot;\\x89PNG&quot;) else &quot;jpg&quot; if raw.startswith(b&quot;\\xff\\xd8&quot;) else &quot;webp&quot; if raw[:4]==b&quot;RIFF&quot; and raw[8:12]==b&quot;WEBP&quot; else &quot;svg&quot; if raw.lstrip().startswith((b&quot;&lt;svg&quot;,b&quot;&lt;?xml&quot;)) else &quot;bin&quot;\n        Path(f&quot;image-{index}.{ext}&quot;).write_bytes(raw)\n    print(&quot;Every returned image saved; complete response metadata retained&quot;)\n\nf=Path(os.environ[&quot;AILOOT_PROMPT_FILE&quot;])\nif not f.is_file():raise SystemExit(&quot;Set your actual UTF-8 image brief file&quot;)\nrequest={&#39;model&#39;: &#39;wan-image-latest&#39;, &#39;prompt&#39;: &#39;&#39;}\nrequest[&quot;prompt&quot;]=f.read_text(encoding=&quot;utf-8&quot;)\nclient=OpenAI(base_url=&quot;https://api.ailoot.ai/v1&quot;,api_key=os.environ[&quot;AILOOT_API_KEY&quot;],max_retries=0)\nresult=client.images.generate(**request)\nPath(&quot;sdk-result.txt&quot;).write_text(str(result),encoding=&quot;utf-8&quot;)\nsave_images([{&quot;b64_json&quot;:getattr(item,&quot;b64_json&quot;,None),&quot;url&quot;:getattr(item,&quot;url&quot;,None)} for item in result.data])\n</code></pre></div><div class=\"cg-pane\" id=\"model-code-106-panel-2\" role=\"tabpanel\" aria-labelledby=\"model-code-106-tab-2\" hidden><pre data-lang=\"js\"><code>import OpenAI from &quot;openai&quot;;\nimport { readFileSync, writeFileSync } from &quot;node:fs&quot;;\nconst key=process.env.AILOOT_API_KEY;\nif(!key) throw new Error(&quot;Set your actual Ailoot API key&quot;);\nconst client=new OpenAI({baseURL:&quot;https://api.ailoot.ai/v1&quot;,apiKey:key,maxRetries:0});\nconst request={&quot;model&quot;: &quot;wan-image-latest&quot;, &quot;prompt&quot;: &quot;&quot;};\nif(!process.env.AILOOT_PROMPT_FILE)throw new Error(&quot;Set your actual UTF-8 image brief file&quot;);\nrequest.prompt=readFileSync(process.env.AILOOT_PROMPT_FILE,&quot;utf8&quot;);\nconst result=await client.images.generate(request);\nwriteFileSync(&quot;sdk-result.json&quot;,JSON.stringify(result,null,2));\nif(!result.data?.length) throw new Error(&quot;No completed images&quot;);\nfor(let index=0;index&lt;result.data.length;index++) {\n  const item=result.data[index];let encoded=item.b64_json,uri=item.url||&quot;&quot;,raw;\n  if(!encoded &amp;&amp; uri.startsWith(&quot;data:image/&quot;)) {\n    const comma=uri.indexOf(&quot;,&quot;);if(comma&lt;0 || !uri.slice(0,comma).includes(&quot;;base64&quot;)) throw new Error(&quot;Unsupported image data URI&quot;);\n    encoded=uri.slice(comma+1);\n  }\n  if(encoded) {\n    if(encoded.length%4!==0 || !/^[A-Za-z0-9+/]*={0,2}$/.test(encoded)) throw new Error(&quot;Invalid Base64&quot;);\n    raw=Buffer.from(encoded,&quot;base64&quot;);\n  } else if(uri) {\n    const u=new URL(uri,&quot;https://api.ailoot.ai&quot;);\n    if(u.protocol!==&quot;https:&quot; || u.username || u.password) throw new Error(&quot;Invalid returned URL&quot;);\n    const owned=u.origin===&quot;https://api.ailoot.ai&quot; &amp;&amp; u.pathname.startsWith(&quot;/v1/media/assets/&quot;) &amp;&amp; u.pathname.endsWith(&quot;/content&quot;);\n    const response=await fetch(u,{headers:owned?{Authorization:&quot;Bearer &quot;+key}:{},redirect:&quot;manual&quot;});\n    if(!response.ok) throw new Error(&quot;Image content download failed: &quot;+response.status);\n    raw=Buffer.from(await response.arrayBuffer());\n  } else throw new Error(&quot;Image has neither bytes nor URL&quot;);\n  if(!raw.length) throw new Error(&quot;Empty image result&quot;);\n  const ext=raw.subarray(0,4).equals(Buffer.from([137,80,78,71]))?&quot;png&quot;:raw[0]===255&amp;&amp;raw[1]===216?&quot;jpg&quot;:raw.toString(&quot;ascii&quot;,0,4)===&quot;RIFF&quot;&amp;&amp;raw.toString(&quot;ascii&quot;,8,12)===&quot;WEBP&quot;?&quot;webp&quot;:raw.toString(&quot;utf8&quot;).trimStart().startsWith(&quot;&lt;svg&quot;)||raw.toString(&quot;utf8&quot;).trimStart().startsWith(&quot;&lt;?xml&quot;)?&quot;svg&quot;:&quot;bin&quot;;\n  writeFileSync(`image-${index}.${ext}`,raw);\n}\nconsole.log(&quot;Every returned image saved; sdk-result.json retains complete metadata&quot;);\n</code></pre></div></div></div></section><section class=\"card-section\" data-card-section=\"results\"><h3 tabindex=\"-1\">Nhận và lưu kết quả</h3><h4>Ailoot · Ảnh</h4><p class=\"note-s\">Tải xuống từng ảnh trả về hoặc lưu nội dung Base64 của ảnh</p><ul class=\"card-result-paths\"><li><code>GET /v1/media/tasks/{task_id}</code></li><li><code>GET /v1/media/assets/{asset_id}/content</code></li><li><code>GET /v1/media/assets</code></li><li><code>GET /v1/media/assets/{asset_id}</code></li></ul><div class=\"card-result-process\" data-all-results><h5>Lưu tất cả kết quả đã hoàn tất</h5><p class=\"note-s\">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.</p><p class=\"note-s\">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ế.</p></div><div class=\"card-result-process\" data-unknown-recovery><h5>Nếu cần kiểm tra phản hồi gốc</h5><p class=\"note-s\">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.</p></div><details class=\"card-about\" data-output-fields><summary>Trường phản hồi</summary><div class=\"tw\" data-card-table=\"output\"><table><thead><tr><th>Trường</th><th>Loại</th></tr></thead><tbody><tr><th data-cell-label=\"Trường\" scope=\"row\"><span class=\"card-cell-label\">Trường</span><code class=\"card-field-name\">created</code></th><td data-cell-label=\"Loại\" data-field-type><span class=\"card-cell-label\">Loại</span>integer</td></tr><tr><th data-cell-label=\"Trường\" scope=\"row\"><span class=\"card-cell-label\">Trường</span><code class=\"card-field-name\">data[].url</code></th><td data-cell-label=\"Loại\" data-field-type><span class=\"card-cell-label\">Loại</span>string</td></tr><tr><th data-cell-label=\"Trường\" scope=\"row\"><span class=\"card-cell-label\">Trường</span><code class=\"card-field-name\">data[].b64_json</code></th><td data-cell-label=\"Loại\" data-field-type><span class=\"card-cell-label\">Loại</span>base64 string</td></tr><tr><th data-cell-label=\"Trường\" scope=\"row\"><span class=\"card-cell-label\">Trường</span><code class=\"card-field-name\">usage</code></th><td data-cell-label=\"Loại\" data-field-type><span class=\"card-cell-label\">Loại</span>object</td></tr></tbody></table></div></details><details class=\"card-about\" data-method-errors><summary>Lỗi và bước tiếp theo</summary><div class=\"tw\" data-card-table=\"errors\"><table><thead><tr><th>Phản hồi</th><th>Điều kiện</th><th>Bước tiếp theo</th></tr></thead><tbody><tr><th data-cell-label=\"Phản hồi\" scope=\"row\"><span class=\"card-cell-label\">Phản hồi</span>400 · <code>invalid_request_error</code></th><td data-cell-label=\"Điều kiện\"><span class=\"card-cell-label\">Điều kiện</span>Trườ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ệ</td><td data-cell-label=\"Bước tiếp theo\"><span class=\"card-cell-label\">Bước tiếp theo</span>Sửa các trường được chỉ ra trước khi gửi yêu cầu tạo mới.</td></tr><tr><th data-cell-label=\"Phản hồi\" scope=\"row\"><span class=\"card-cell-label\">Phản hồi</span><code>server_error</code></th><td data-cell-label=\"Điều kiện\"><span class=\"card-cell-label\">Điều kiện</span>Phản hồi trả về cho biết thao tác hoặc kết quả cần được kiểm tra</td><td data-cell-label=\"Bước tiếp theo\"><span class=\"card-cell-label\">Bước tiếp theo</span>Giữ 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.</td></tr></tbody></table></div></details></section><section class=\"card-section\" data-card-section=\"aliases\"><h3 tabindex=\"-1\">Bí danh</h3><h4>Bí danh mô hình</h4><p class=\"note-s\"><span data-model-alias-route=\"Core\"><b>Ailoot</b> <a href=\"#m=wan2.7-image-pro&amp;route=Core&amp;caller=wan2.7-image-pro&amp;fmt=images\"><code>wan2.7-image-pro</code></a>, <a href=\"#m=wan2.7-image-pro&amp;route=Core&amp;caller=wan-image&amp;fmt=images\"><code>wan-image</code></a>, <a href=\"#m=wan2.7-image-pro&amp;route=Core&amp;caller=wan-image-latest&amp;fmt=images\"><code>wan-image-latest</code></a></span></p><h4>Bí danh đường dẫn phương thức</h4><p class=\"note-s\">Dùng các đường dẫn phương thức hiển thị ở trên.</p><h4>ID gọi liên quan</h4><p class=\"note-s\"><a href=\"#m=wan2.7-image-pro&amp;route=Core&amp;caller=wan2.7-image-pro&amp;fmt=images\"><code>wan2.7-image-pro</code></a>, <a href=\"#m=wan2.7-image-pro&amp;route=Core&amp;caller=wan-image&amp;fmt=images\"><code>wan-image</code></a>, <a href=\"#m=wan2.7-image-pro&amp;route=Core&amp;caller=wan-image-latest&amp;fmt=images\"><code>wan-image-latest</code></a></p></section></div>",
      "method_identity": {
        "effective_request_model_id": "wan-image-latest",
        "fmt": "images",
        "http": "POST",
        "path": "/v1/images/generations",
        "request_model_id": "wan-image-latest",
        "route_label": "Core"
      },
      "method_key": "Core|images|/v1/images/generations|wan-image-latest",
      "ordinal": 2,
      "rawMethod": {
        "cache_read": null,
        "cache_write": null,
        "cache_write_1h": null,
        "cache_write_5m": null,
        "conditional_meter": null,
        "contract": {
          "data": {
            "all_results": "Save every data item. Decode each b64_json or fetch every returned signed URL. Select a filename extension from the actual MIME/bytes.",
            "errors": [
              {
                "code": null,
                "condition": "Trườ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ệ",
                "http_status": 400,
                "recovery": "Sửa các trường được chỉ ra trước khi gửi yêu cầu tạo mới.",
                "type": "invalid_request_error"
              },
              {
                "code": null,
                "condition": "Phản hồi trả về cho biết thao tác hoặc kết quả cần được kiểm tra",
                "http_status": null,
                "recovery": "Giữ 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.",
                "type": "server_error"
              }
            ],
            "hints": [
              "Qwen defaultsize1024*1024; Wan defaultsize1K. Wan2.7 Pro4K is supported only without reference inputs.",
              "Explicit dimensions must be positive, at most4096 peraxis, within8:1..1:8 aspect, and the exact model/input area range.",
              "The Alibaba image adapter rejects mask input and streaming before sending the request.",
              "For this generation method, actual image references are supported as multipart image files. JSONimages[].image_url is read only on images/edits; the leaf value is a string."
            ],
            "ignored_fields": [
              "quality",
              "background",
              "style",
              "output_format",
              "output_compression",
              "moderation",
              "input_fidelity",
              "partial_images without streaming"
            ],
            "lifecycle": {
              "all_results": "Follow everyactualreturnedoutputandownedasset; no result is discardedbecauseindex0orcontent_urlalreadyexists.",
              "assets": [
                {
                  "http": "GET",
                  "path": "/v1/media/assets"
                },
                {
                  "http": "GET",
                  "path": "/v1/media/assets/{asset_id}"
                }
              ],
              "content": [
                {
                  "http": "GET",
                  "path": "/v1/media/assets/{asset_id}/content",
                  "url_source": "exact returned signed URL; never construct token"
                }
              ],
              "mode": "synchronous_result_then_owned_library",
              "operation_id_is_not_task_id": true,
              "status": [
                {
                  "http": "GET",
                  "id_source": "actual returned task_id or media library record",
                  "path": "/v1/media/tasks/{task_id}"
                }
              ],
              "unknown": "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."
            },
            "material_combinations": [
              {
                "content_type": "application/json",
                "ignored_reference_field": "JSONgeneration images[] is not parsed; images[].image_url belongs to a separately supported JSONedit profile.",
                "mask": false,
                "mode": "text_to_image",
                "reference_images": false,
                "required": [
                  "prompt"
                ],
                "supplied_materials": [
                  "UTF8 prompt"
                ]
              },
              {
                "content_type": "multipart/form-data",
                "mask": false,
                "maximum_decoded_bytes_per_image": 20971520,
                "maximum_reference_images": 9,
                "mime_types": [
                  "image/png",
                  "image/jpeg"
                ],
                "minimum_reference_images": 0,
                "mode": "reference_images_generation",
                "optional_file_fields": [
                  "image",
                  "image[]",
                  "image[index]"
                ],
                "reference_images": true,
                "required": [
                  "prompt"
                ],
                "supplied_materials": [
                  "UTF8 prompt",
                  "actual PNG/JPEG file references"
                ]
              }
            ],
            "media_library": {
              "asset": {
                "fields": [
                  {
                    "description": null,
                    "name": "asset_id",
                    "type": "string"
                  },
                  {
                    "description": null,
                    "name": "task_id",
                    "type": "string"
                  },
                  {
                    "description": null,
                    "name": "output_key",
                    "type": "string"
                  },
                  {
                    "description": null,
                    "name": "family",
                    "type": "string"
                  },
                  {
                    "description": null,
                    "name": "model",
                    "type": "string"
                  },
                  {
                    "description": null,
                    "name": "method",
                    "type": "string"
                  },
                  {
                    "description": null,
                    "name": "status",
                    "type": "string"
                  },
                  {
                    "description": null,
                    "name": "content_type",
                    "type": "string"
                  },
                  {
                    "description": null,
                    "name": "sha256",
                    "type": "string"
                  },
                  {
                    "description": null,
                    "name": "size_bytes",
                    "type": "integer"
                  },
                  {
                    "description": null,
                    "name": "content_url",
                    "type": "string"
                  }
                ],
                "http": "GET",
                "id_source": "actual returned asset_id",
                "path": "/v1/media/assets/{asset_id}"
              },
              "content": {
                "http": "GET",
                "path": "/v1/media/assets/{asset_id}/content",
                "range_header_supported": true,
                "url_source": "Use exact returned signed content_url including its token; do not construct a token."
              },
              "expired_link": {
                "code": "link_expired",
                "http_status": 404,
                "recovery": "Read the asset again to obtain its refreshed signed content_url, then fetch that URL. Do not regenerate."
              },
              "list": {
                "all_pages": "Follow every returned next_cursor, then select records by their actual task_id/output_key.",
                "http": "GET",
                "output_fields": [
                  {
                    "description": null,
                    "name": "object",
                    "type": "string"
                  },
                  {
                    "description": null,
                    "name": "data",
                    "type": "asset[]"
                  },
                  {
                    "description": null,
                    "name": "next_cursor",
                    "type": "string|null"
                  }
                ],
                "parameters": [
                  {
                    "availability": "source_interface",
                    "default": null,
                    "default_known": false,
                    "enum": null,
                    "enum_known": false,
                    "name": "family",
                    "required": false,
                    "type": "string"
                  },
                  {
                    "availability": "source_interface",
                    "default": null,
                    "default_known": false,
                    "enum": null,
                    "enum_known": false,
                    "name": "cursor",
                    "required": false,
                    "type": "string"
                  },
                  {
                    "availability": "source_interface",
                    "default": 20,
                    "default_known": true,
                    "enum": null,
                    "enum_known": false,
                    "maximum": 100,
                    "minimum": 1,
                    "name": "limit",
                    "required": false,
                    "type": "integer"
                  }
                ],
                "path": "/v1/media/assets"
              },
              "revoke": {
                "http": "DELETE",
                "meaning": "Revokes/deletes the existing owned file; this is not generation cancellation.",
                "path": "/v1/media/assets/{asset_id}",
                "pending_status": "revoking",
                "success_statuses": [
                  202,
                  204
                ]
              },
              "task": {
                "http": "GET",
                "id_source": "actual returned task_id or media library record; operation_id is not task_id",
                "path": "/v1/media/tasks/{task_id}"
              }
            },
            "operation_modes": [
              "text_to_image",
              "reference_images_generation_via_multipart"
            ],
            "outputs": {
              "all_results": "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ế.",
              "family": "image",
              "fields": [
                {
                  "description": null,
                  "name": "created",
                  "type": "integer"
                },
                {
                  "description": null,
                  "name": "data[].url",
                  "type": "string"
                },
                {
                  "description": null,
                  "name": "data[].b64_json",
                  "type": "base64 string"
                },
                {
                  "description": null,
                  "name": "usage",
                  "type": "object"
                }
              ],
              "format": "actual validated raster MIME"
            },
            "parameter_conditions": {
              "size": {
                "aspect_ratio_range": [
                  "1:8",
                  "8:1"
                ],
                "default": "1K",
                "max_area_4k_condition": "WanPro and no inputimages",
                "max_dimension": 4096,
                "maximum_area": 16777216,
                "minimum_area": 589824
              }
            },
            "parameters": [
              {
                "availability": "source_interface",
                "default": null,
                "default_known": false,
                "enum": [
                  "wan-image-latest"
                ],
                "enum_known": true,
                "name": "model",
                "required": true,
                "type": "string"
              },
              {
                "availability": "source_interface",
                "default": null,
                "default_known": false,
                "enum": null,
                "enum_known": false,
                "min_length": 1,
                "name": "prompt",
                "required": true,
                "type": "string"
              },
              {
                "availability": "source_interface",
                "default": 1,
                "default_known": true,
                "enum": null,
                "enum_known": false,
                "minimum": 1,
                "name": "n",
                "required": false,
                "type": "integer"
              },
              {
                "availability": "source_interface",
                "default": null,
                "default_known": false,
                "enum": [
                  "url",
                  "b64_json"
                ],
                "enum_known": true,
                "name": "response_format",
                "required": false,
                "type": "string"
              },
              {
                "availability": "source_interface",
                "default": false,
                "default_known": true,
                "enum": null,
                "enum_known": false,
                "name": "stream",
                "required": false,
                "type": "boolean"
              },
              {
                "availability": "model_dependent",
                "default": null,
                "default_known": false,
                "enum": null,
                "enum_known": false,
                "name": "size",
                "required": false,
                "type": "string"
              },
              {
                "availability": "model_dependent",
                "default": null,
                "default_known": false,
                "enum": null,
                "enum_known": false,
                "name": "partial_images",
                "required": false,
                "type": "integer"
              },
              {
                "availability": "different_method",
                "conditions": "Một URL thực tế cho mỗi đối tượng images[]. Số phần tử mảng khác với nút lá dạng chuỗi này.",
                "decoded_max_bytes": 20971520,
                "default": null,
                "default_known": false,
                "enum": null,
                "enum_known": false,
                "maximum_images_per_array": 9,
                "mime_types": [
                  "image/png",
                  "image/jpeg"
                ],
                "name": "images[].image_url",
                "required": false,
                "type": "string",
                "when": "Chỉ JSON images/edits; JSON images/generations không phân tích các tham chiếu images."
              },
              {
                "availability": "source_interface",
                "default": null,
                "default_known": false,
                "enum": null,
                "enum_known": false,
                "maximum_decoded_bytes": 20971520,
                "mime_types": [
                  "image/png",
                  "image/jpeg"
                ],
                "name": "image",
                "required": false,
                "type": "file",
                "when": "tạo bằng multipart/form-data"
              },
              {
                "availability": "source_interface",
                "default": null,
                "default_known": false,
                "enum": null,
                "enum_known": false,
                "maximum_decoded_bytes": 20971520,
                "maximum_items": 9,
                "mime_types": [
                  "image/png",
                  "image/jpeg"
                ],
                "name": "image[]",
                "required": false,
                "type": "file[]",
                "when": "tạo bằng multipart/form-data"
              }
            ],
            "profile_binding": "Exact existing Ailoot model and method; interface constraints below do not assert provider qualification.",
            "unsupported": [
              "images[].file_id",
              "mask.file_id",
              "mask",
              "stream=true",
              "mask input is rejected by this Alibaba adapter"
            ]
          },
          "hints": [
            "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."
          ],
          "input": {
            "content_type": "application/json",
            "material_types": [
              "text"
            ],
            "optional_controls": null,
            "required": [
              "model",
              "prompt"
            ]
          },
          "lifecycle": {
            "assets": [
              {
                "http": "GET",
                "path": "/v1/media/assets"
              },
              {
                "http": "GET",
                "path": "/v1/media/assets/{asset_id}"
              }
            ],
            "content": [
              {
                "http": "GET",
                "path": "/v1/media/assets/{asset_id}/content",
                "url_source": "exact returned signed URL; never construct token"
              }
            ],
            "mode": "synchronous_result_then_owned_library",
            "operation_id_is_not_task_id": true,
            "status": [
              {
                "http": "GET",
                "id_source": "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",
                "path": "/v1/media/tasks/{task_id}"
              }
            ],
            "unknown": "If an image generation or edit result requires a check, keep the original operation_id/X-Client-Request-ID and returned result information. Recover existing owned results through the media library using actual task_id or asset_id values. Do not resubmit the generation/edit request or construct a polling URL from operation_id."
          },
          "method": {
            "http": "POST",
            "path": "/v1/images/generations"
          },
          "operation_modes": [
            "images"
          ],
          "output": {
            "family": [
              "image"
            ],
            "format": null,
            "multioutputs": "retain every actual response output"
          }
        },
        "ctx": null,
        "examples": [
          {
            "code": "set -eu\n: \"${AILOOT_API_KEY:?Set your Ailoot API key}\"\nexport AILOOT_API_KEY\nexport AILOOT_API_KEY\n: \"${AILOOT_PROMPT_FILE:?Set your actual UTF-8 image brief}\"\nexport AILOOT_PROMPT_FILE\npython3 - <<'PY_REQUEST'\nimport json,os\nfrom pathlib import Path\np=json.loads('{\"model\": \"wan-image-latest\", \"prompt\": \"\"}')\nf=Path(os.environ[\"AILOOT_PROMPT_FILE\"])\nif not f.is_file():raise SystemExit(\"Choose your actual UTF-8 brief\")\np['prompt']=f.read_text(encoding=\"utf-8\")\nif not p['prompt'].strip():raise SystemExit(\"Brief must contain text\")\nPath(\"request.json\").write_text(json.dumps(p,ensure_ascii=False))\nPY_REQUEST\ncurl --fail-with-body --silent --show-error https://api.ailoot.ai/v1/images/generations \\\n  -H \"Authorization: Bearer $AILOOT_API_KEY\" -H 'Content-Type: application/json' \\\n  --data-binary @request.json -D response-headers.txt -o result.json\npython3 - <<'PY_RESULT'\nimport base64, json, os, subprocess\nfrom pathlib import Path\nfrom urllib.parse import urlsplit, urljoin\n\ndef save_images(items):\n    if not items: raise SystemExit(\"No completed images; retain the full response\")\n    for index, item in enumerate(items):\n        encoded=item.get(\"b64_json\")\n        uri=item.get(\"url\", \"\")\n        if not encoded and uri.startswith(\"data:image/\"):\n            header, separator, encoded=uri.partition(\",\")\n            if not separator or \";base64\" not in header: raise SystemExit(\"Unsupported image data URI\")\n        if encoded:\n            raw=base64.b64decode(encoded,validate=True)\n        elif uri:\n            uri=urljoin(\"https://api.ailoot.ai\",uri)\n            parsed=urlsplit(uri)\n            if parsed.scheme!=\"https\" or not parsed.netloc or parsed.username or parsed.password:\n                raise SystemExit(\"Invalid returned image URL\")\n            owned=parsed.netloc==\"api.ailoot.ai\" and parsed.path.startswith(\"/v1/media/assets/\") and parsed.path.endswith(\"/content\")\n            args=[\"curl\",\"--fail-with-body\",\"--silent\",\"--show-error\",uri]\n            if owned: args += [\"-H\",\"Authorization: Bearer \"+os.environ[\"AILOOT_API_KEY\"]]\n            temporary=Path(f\"image-{index}.bin\")\n            subprocess.run(args+[\"-o\",str(temporary)],check=True)\n            raw=temporary.read_bytes()\n            temporary.unlink()\n        else: raise SystemExit(\"Image has neither bytes nor URL\")\n        if not raw: raise SystemExit(\"Empty image result\")\n        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\"\n        Path(f\"image-{index}.{ext}\").write_bytes(raw)\n    print(\"Every returned image saved; complete response metadata retained\")\nsave_images(json.loads(Path(\"result.json\").read_text())[\"data\"])\nPY_RESULT\n",
            "label": "Create and save every image",
            "language": "bash"
          },
          {
            "code": "from openai import OpenAI\nimport base64, json, os, subprocess\nfrom pathlib import Path\nfrom urllib.parse import urlsplit, urljoin\n\ndef save_images(items):\n    if not items: raise SystemExit(\"No completed images; retain the full response\")\n    for index, item in enumerate(items):\n        encoded=item.get(\"b64_json\")\n        uri=item.get(\"url\", \"\")\n        if not encoded and uri.startswith(\"data:image/\"):\n            header, separator, encoded=uri.partition(\",\")\n            if not separator or \";base64\" not in header: raise SystemExit(\"Unsupported image data URI\")\n        if encoded:\n            raw=base64.b64decode(encoded,validate=True)\n        elif uri:\n            uri=urljoin(\"https://api.ailoot.ai\",uri)\n            parsed=urlsplit(uri)\n            if parsed.scheme!=\"https\" or not parsed.netloc or parsed.username or parsed.password:\n                raise SystemExit(\"Invalid returned image URL\")\n            owned=parsed.netloc==\"api.ailoot.ai\" and parsed.path.startswith(\"/v1/media/assets/\") and parsed.path.endswith(\"/content\")\n            args=[\"curl\",\"--fail-with-body\",\"--silent\",\"--show-error\",uri]\n            if owned: args += [\"-H\",\"Authorization: Bearer \"+os.environ[\"AILOOT_API_KEY\"]]\n            temporary=Path(f\"image-{index}.bin\")\n            subprocess.run(args+[\"-o\",str(temporary)],check=True)\n            raw=temporary.read_bytes()\n            temporary.unlink()\n        else: raise SystemExit(\"Image has neither bytes nor URL\")\n        if not raw: raise SystemExit(\"Empty image result\")\n        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\"\n        Path(f\"image-{index}.{ext}\").write_bytes(raw)\n    print(\"Every returned image saved; complete response metadata retained\")\n\nf=Path(os.environ[\"AILOOT_PROMPT_FILE\"])\nif not f.is_file():raise SystemExit(\"Set your actual UTF-8 image brief file\")\nrequest={'model': 'wan-image-latest', 'prompt': ''}\nrequest[\"prompt\"]=f.read_text(encoding=\"utf-8\")\nclient=OpenAI(base_url=\"https://api.ailoot.ai/v1\",api_key=os.environ[\"AILOOT_API_KEY\"],max_retries=0)\nresult=client.images.generate(**request)\nPath(\"sdk-result.txt\").write_text(str(result),encoding=\"utf-8\")\nsave_images([{\"b64_json\":getattr(item,\"b64_json\",None),\"url\":getattr(item,\"url\",None)} for item in result.data])\n",
            "label": "Python SDK · save all image outputs",
            "language": "python"
          },
          {
            "code": "import OpenAI from \"openai\";\nimport { readFileSync, writeFileSync } from \"node:fs\";\nconst key=process.env.AILOOT_API_KEY;\nif(!key) throw new Error(\"Set your actual Ailoot API key\");\nconst client=new OpenAI({baseURL:\"https://api.ailoot.ai/v1\",apiKey:key,maxRetries:0});\nconst request={\"model\": \"wan-image-latest\", \"prompt\": \"\"};\nif(!process.env.AILOOT_PROMPT_FILE)throw new Error(\"Set your actual UTF-8 image brief file\");\nrequest.prompt=readFileSync(process.env.AILOOT_PROMPT_FILE,\"utf8\");\nconst result=await client.images.generate(request);\nwriteFileSync(\"sdk-result.json\",JSON.stringify(result,null,2));\nif(!result.data?.length) throw new Error(\"No completed images\");\nfor(let index=0;index<result.data.length;index++) {\n  const item=result.data[index];let encoded=item.b64_json,uri=item.url||\"\",raw;\n  if(!encoded && uri.startsWith(\"data:image/\")) {\n    const comma=uri.indexOf(\",\");if(comma<0 || !uri.slice(0,comma).includes(\";base64\")) throw new Error(\"Unsupported image data URI\");\n    encoded=uri.slice(comma+1);\n  }\n  if(encoded) {\n    if(encoded.length%4!==0 || !/^[A-Za-z0-9+/]*={0,2}$/.test(encoded)) throw new Error(\"Invalid Base64\");\n    raw=Buffer.from(encoded,\"base64\");\n  } else if(uri) {\n    const u=new URL(uri,\"https://api.ailoot.ai\");\n    if(u.protocol!==\"https:\" || u.username || u.password) throw new Error(\"Invalid returned URL\");\n    const owned=u.origin===\"https://api.ailoot.ai\" && u.pathname.startsWith(\"/v1/media/assets/\") && u.pathname.endsWith(\"/content\");\n    const response=await fetch(u,{headers:owned?{Authorization:\"Bearer \"+key}:{},redirect:\"manual\"});\n    if(!response.ok) throw new Error(\"Image content download failed: \"+response.status);\n    raw=Buffer.from(await response.arrayBuffer());\n  } else throw new Error(\"Image has neither bytes nor URL\");\n  if(!raw.length) throw new Error(\"Empty image result\");\n  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\";\n  writeFileSync(`image-${index}.${ext}`,raw);\n}\nconsole.log(\"Every returned image saved; sdk-result.json retains complete metadata\");\n",
            "label": "Node SDK · save all image outputs",
            "language": "js"
          }
        ],
        "family": "openai",
        "fast_multiplier": null,
        "flex_multiplier": null,
        "fmt": "images",
        "http": "POST",
        "img_in": null,
        "img_out": null,
        "in": null,
        "input": [
          "text"
        ],
        "label": "Ảnh",
        "max_out": null,
        "max_tool_calls": null,
        "out": null,
        "output": [
          "image"
        ],
        "path": "/v1/images/generations",
        "pricing_profiles": [
          {
            "dimensions": {},
            "label": "Core",
            "units": [
              {
                "amount": 0.075,
                "amount_unit": "usd_per_display_unit",
                "key": "image_output_1k",
                "label": "per 1K image",
                "side": "out"
              },
              {
                "amount": 0.075,
                "amount_unit": "usd_per_display_unit",
                "key": "image_output_2k",
                "label": "per 2K image",
                "side": "out"
              }
            ]
          }
        ],
        "request_model_id": "wan-image-latest",
        "route_label": "Core",
        "status_reads": [],
        "tiers": [],
        "tool_prices": null,
        "unit": "conditional",
        "units": [
          {
            "key": "image_output_1k",
            "label": "per 1K image",
            "side": "out",
            "usd": 0.075
          },
          {
            "key": "image_output_2k",
            "label": "per 2K image",
            "side": "out",
            "usd": 0.075
          }
        ]
      }
    }
  ],
  "model_id": "wan2.7-image-pro",
  "nativeProvenance": {
    "input_facts_canonical_sha256": "0fadfee30cd68068f7dc2682b2a5e364ba18c34be851a577e872685c2e0d693e",
    "input_html_sha256": "049a39804d024677ca4a60222caf8dd604d202b65d6fa7af12d38a1d0fa858a8",
    "private_audit_sha256": "36b7d536dd727a55f3c804bae365f058ffd9f11111b57df861f108fee06ffbdd",
    "role": "historical-normalized-input-audit-hashes",
    "schema": "ailoot-native-model-provenance-v2"
  },
  "page": {
    "canonical": "https://ailoot.ai/models/vi/wan2-7-image-pro/",
    "description": "Mô hình tạo ảnh từ yêu cầu bằng văn bản. Nhà sản xuất cho phép điều khiển bảng màu và độ phân giải tối đa 4K khi tạo ảnh thông thường từ văn bản.",
    "locale": "vi",
    "md_url": "https://ailoot.ai/models/vi/wan2-7-image-pro/index.md",
    "title": "wan2.7-image-pro — Ailoot",
    "url": "https://ailoot.ai/models/vi/wan2-7-image-pro/"
  },
  "rawModel": {
    "about": "Wan2.7-Image-Pro là mô hình của Alibaba để tạo ảnh từ văn bản. Thẻ Ailoot hiện tại công bố đầu vào văn bản và kết quả dạng ảnh. Nhà sản xuất còn cung cấp chỉnh sửa, kết hợp ảnh tham chiếu và thay đổi cục bộ; các cách này cần hỗ trợ đầu vào ảnh riêng và không được cung cấp qua phương thức hiện tại của thẻ.\n\nTrong chế độ dùng ảnh tham chiếu của nhà sản xuất, có thể gửi tối đa chín ảnh nguồn và mô tả những yếu tố cần sử dụng từ mỗi ảnh. Khi chỉnh sửa, mô hình giữ đối tượng chính, thay đổi các chi tiết đã chọn hoặc ghép nhiều tư liệu thành bố cục mới. Để định hướng thay đổi chính xác hơn, có thể xác định tối đa hai vùng hình chữ nhật trên một ảnh đầu vào.\n\n### Bảng màu và yêu cầu phức tạp\n\nNgoài các chuỗi liên tiếp, có thể đặt bảng màu gồm 3–10 màu. Chế độ suy luận dành cho việc tạo ảnh thông thường từ văn bản, không dùng ảnh tham chiếu hoặc chuỗi liên tiếp: mô hình phân tích trước mô tả của cảnh.\n\nTrong đặc tả Alibaba, đầu ra thông thường gồm từ một đến bốn ảnh. Với chuỗi theo cốt truyện, có thể đặt giới hạn trên tối đa 12 ảnh; mô hình chọn số lượng thực tế theo yêu cầu. Chuỗi có thể sử dụng văn bản và ảnh tham chiếu để giữ các đặc điểm chung của nhân vật và diễn biến câu chuyện liền mạch. Bảng màu và suy luận không được áp dụng ở chế độ này.\n\n### Độ phân giải phụ thuộc vào chế độ\n\nMức 4K được hỗ trợ khi tạo ảnh thông thường từ văn bản, không dùng ảnh tham chiếu hoặc chuỗi liên tiếp. Chỉnh sửa dựa trên ảnh và chuỗi liên tiếp bị giới hạn ở mức 2K. Các ký hiệu này xác định diện tích pixel, không phải độ dài bằng nhau của mỗi cạnh. Có thể chọn tỷ lệ khung hình từ 1:8 đến 8:1; khi chỉnh sửa với độ phân giải đặt sẵn, tỷ lệ khung hình theo ảnh tham chiếu cuối cùng. Kết quả được lưu ở định dạng PNG.\n\nVới những cách sử dụng ảnh đầu vào, Alibaba chấp nhận JPEG, JPG, PNG không có độ trong suốt, BMP và WEBP. Các giới hạn là 20 MB mỗi tệp, từ 240 đến 8000 pixel cho mỗi chiều và tỷ lệ từ 1:8 đến 8:1. Yêu cầu bằng văn bản hỗ trợ tiếng Trung và tiếng Anh; tối đa 5000 ký tự, phần dư bị cắt bỏ. Phiên bản này không có mô tả phủ định hoặc mở rộng yêu cầu. Hạt giống ngẫu nhiên giúp giữ nét tương đồng giữa các phương án, nhưng không bảo đảm lặp lại chính xác.",
    "alias_of": null,
    "aliases": [
      "wan-image",
      "wan-image-latest"
    ],
    "author": "Alibaba",
    "ctx": null,
    "declared_tariff_references": [
      {
        "client_selectable": false,
        "key": "b111d879ba5fe816611b",
        "label": "wan2.7-image-pro",
        "profiles": [
          {
            "basis": "",
            "dimensions": {
              "conditions": "Cấu hình mặc định"
            },
            "label": "wan2.7-image-pro · Cấu hình mặc định",
            "units": [
              {
                "amount": "0.0",
                "amount_unit": "usd_per_exact_physical_unit",
                "billing_input": false,
                "key": "a1b2b151bd7fbaedf7d1220d",
                "label": "Input",
                "public_unit_label": "per call",
                "quantity": 1,
                "rate_role": "declared_tariff_rate",
                "side": "in",
                "unit": "次"
              },
              {
                "amount": "0.16",
                "amount_unit": "usd_per_exact_physical_unit",
                "billing_input": false,
                "key": "deb9ebf08920d3c20bf172d3",
                "label": "Output",
                "public_unit_label": "per call",
                "quantity": 1,
                "rate_role": "declared_tariff_rate",
                "side": "out",
                "unit": "次"
              }
            ]
          }
        ]
      }
    ],
    "formats": [
      "images"
    ],
    "id": "wan2.7-image-pro",
    "input": [
      "text"
    ],
    "kind": "image",
    "max_out": null,
    "methods": [
      {
        "cache_read": null,
        "cache_write": null,
        "cache_write_1h": null,
        "cache_write_5m": null,
        "conditional_meter": null,
        "contract": {
          "data": {
            "all_results": "Save every data item. Decode each b64_json or fetch every returned signed URL. Select a filename extension from the actual MIME/bytes.",
            "errors": [
              {
                "code": null,
                "condition": "Trườ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ệ",
                "http_status": 400,
                "recovery": "Sửa các trường được chỉ ra trước khi gửi yêu cầu tạo mới.",
                "type": "invalid_request_error"
              },
              {
                "code": null,
                "condition": "Phản hồi trả về cho biết thao tác hoặc kết quả cần được kiểm tra",
                "http_status": null,
                "recovery": "Giữ 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.",
                "type": "server_error"
              }
            ],
            "hints": [
              "Qwen defaultsize1024*1024; Wan defaultsize1K. Wan2.7 Pro4K is supported only without reference inputs.",
              "Explicit dimensions must be positive, at most4096 peraxis, within8:1..1:8 aspect, and the exact model/input area range.",
              "The Alibaba image adapter rejects mask input and streaming before sending the request.",
              "For this generation method, actual image references are supported as multipart image files. JSONimages[].image_url is read only on images/edits; the leaf value is a string."
            ],
            "ignored_fields": [
              "quality",
              "background",
              "style",
              "output_format",
              "output_compression",
              "moderation",
              "input_fidelity",
              "partial_images without streaming"
            ],
            "lifecycle": {
              "all_results": "Follow everyactualreturnedoutputandownedasset; no result is discardedbecauseindex0orcontent_urlalreadyexists.",
              "assets": [
                {
                  "http": "GET",
                  "path": "/v1/media/assets"
                },
                {
                  "http": "GET",
                  "path": "/v1/media/assets/{asset_id}"
                }
              ],
              "content": [
                {
                  "http": "GET",
                  "path": "/v1/media/assets/{asset_id}/content",
                  "url_source": "exact returned signed URL; never construct token"
                }
              ],
              "mode": "synchronous_result_then_owned_library",
              "operation_id_is_not_task_id": true,
              "status": [
                {
                  "http": "GET",
                  "id_source": "actual returned task_id or media library record",
                  "path": "/v1/media/tasks/{task_id}"
                }
              ],
              "unknown": "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."
            },
            "material_combinations": [
              {
                "content_type": "application/json",
                "ignored_reference_field": "JSONgeneration images[] is not parsed; images[].image_url belongs to a separately supported JSONedit profile.",
                "mask": false,
                "mode": "text_to_image",
                "reference_images": false,
                "required": [
                  "prompt"
                ],
                "supplied_materials": [
                  "UTF8 prompt"
                ]
              },
              {
                "content_type": "multipart/form-data",
                "mask": false,
                "maximum_decoded_bytes_per_image": 20971520,
                "maximum_reference_images": 9,
                "mime_types": [
                  "image/png",
                  "image/jpeg"
                ],
                "minimum_reference_images": 0,
                "mode": "reference_images_generation",
                "optional_file_fields": [
                  "image",
                  "image[]",
                  "image[index]"
                ],
                "reference_images": true,
                "required": [
                  "prompt"
                ],
                "supplied_materials": [
                  "UTF8 prompt",
                  "actual PNG/JPEG file references"
                ]
              }
            ],
            "media_library": {
              "asset": {
                "fields": [
                  {
                    "description": null,
                    "name": "asset_id",
                    "type": "string"
                  },
                  {
                    "description": null,
                    "name": "task_id",
                    "type": "string"
                  },
                  {
                    "description": null,
                    "name": "output_key",
                    "type": "string"
                  },
                  {
                    "description": null,
                    "name": "family",
                    "type": "string"
                  },
                  {
                    "description": null,
                    "name": "model",
                    "type": "string"
                  },
                  {
                    "description": null,
                    "name": "method",
                    "type": "string"
                  },
                  {
                    "description": null,
                    "name": "status",
                    "type": "string"
                  },
                  {
                    "description": null,
                    "name": "content_type",
                    "type": "string"
                  },
                  {
                    "description": null,
                    "name": "sha256",
                    "type": "string"
                  },
                  {
                    "description": null,
                    "name": "size_bytes",
                    "type": "integer"
                  },
                  {
                    "description": null,
                    "name": "content_url",
                    "type": "string"
                  }
                ],
                "http": "GET",
                "id_source": "actual returned asset_id",
                "path": "/v1/media/assets/{asset_id}"
              },
              "content": {
                "http": "GET",
                "path": "/v1/media/assets/{asset_id}/content",
                "range_header_supported": true,
                "url_source": "Use exact returned signed content_url including its token; do not construct a token."
              },
              "expired_link": {
                "code": "link_expired",
                "http_status": 404,
                "recovery": "Read the asset again to obtain its refreshed signed content_url, then fetch that URL. Do not regenerate."
              },
              "list": {
                "all_pages": "Follow every returned next_cursor, then select records by their actual task_id/output_key.",
                "http": "GET",
                "output_fields": [
                  {
                    "description": null,
                    "name": "object",
                    "type": "string"
                  },
                  {
                    "description": null,
                    "name": "data",
                    "type": "asset[]"
                  },
                  {
                    "description": null,
                    "name": "next_cursor",
                    "type": "string|null"
                  }
                ],
                "parameters": [
                  {
                    "availability": "source_interface",
                    "default": null,
                    "default_known": false,
                    "enum": null,
                    "enum_known": false,
                    "name": "family",
                    "required": false,
                    "type": "string"
                  },
                  {
                    "availability": "source_interface",
                    "default": null,
                    "default_known": false,
                    "enum": null,
                    "enum_known": false,
                    "name": "cursor",
                    "required": false,
                    "type": "string"
                  },
                  {
                    "availability": "source_interface",
                    "default": 20,
                    "default_known": true,
                    "enum": null,
                    "enum_known": false,
                    "maximum": 100,
                    "minimum": 1,
                    "name": "limit",
                    "required": false,
                    "type": "integer"
                  }
                ],
                "path": "/v1/media/assets"
              },
              "revoke": {
                "http": "DELETE",
                "meaning": "Revokes/deletes the existing owned file; this is not generation cancellation.",
                "path": "/v1/media/assets/{asset_id}",
                "pending_status": "revoking",
                "success_statuses": [
                  202,
                  204
                ]
              },
              "task": {
                "http": "GET",
                "id_source": "actual returned task_id or media library record; operation_id is not task_id",
                "path": "/v1/media/tasks/{task_id}"
              }
            },
            "operation_modes": [
              "text_to_image",
              "reference_images_generation_via_multipart"
            ],
            "outputs": {
              "all_results": "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ế.",
              "family": "image",
              "fields": [
                {
                  "description": null,
                  "name": "created",
                  "type": "integer"
                },
                {
                  "description": null,
                  "name": "data[].url",
                  "type": "string"
                },
                {
                  "description": null,
                  "name": "data[].b64_json",
                  "type": "base64 string"
                },
                {
                  "description": null,
                  "name": "usage",
                  "type": "object"
                }
              ],
              "format": "actual validated raster MIME"
            },
            "parameter_conditions": {
              "size": {
                "aspect_ratio_range": [
                  "1:8",
                  "8:1"
                ],
                "default": "1K",
                "max_area_4k_condition": "WanPro and no inputimages",
                "max_dimension": 4096,
                "maximum_area": 16777216,
                "minimum_area": 589824
              }
            },
            "parameters": [
              {
                "availability": "source_interface",
                "default": null,
                "default_known": false,
                "enum": [
                  "wan2.7-image-pro"
                ],
                "enum_known": true,
                "name": "model",
                "required": true,
                "type": "string"
              },
              {
                "availability": "source_interface",
                "default": null,
                "default_known": false,
                "enum": null,
                "enum_known": false,
                "min_length": 1,
                "name": "prompt",
                "required": true,
                "type": "string"
              },
              {
                "availability": "source_interface",
                "default": 1,
                "default_known": true,
                "enum": null,
                "enum_known": false,
                "minimum": 1,
                "name": "n",
                "required": false,
                "type": "integer"
              },
              {
                "availability": "source_interface",
                "default": null,
                "default_known": false,
                "enum": [
                  "url",
                  "b64_json"
                ],
                "enum_known": true,
                "name": "response_format",
                "required": false,
                "type": "string"
              },
              {
                "availability": "source_interface",
                "default": false,
                "default_known": true,
                "enum": null,
                "enum_known": false,
                "name": "stream",
                "required": false,
                "type": "boolean"
              },
              {
                "availability": "model_dependent",
                "default": null,
                "default_known": false,
                "enum": null,
                "enum_known": false,
                "name": "size",
                "required": false,
                "type": "string"
              },
              {
                "availability": "model_dependent",
                "default": null,
                "default_known": false,
                "enum": null,
                "enum_known": false,
                "name": "partial_images",
                "required": false,
                "type": "integer"
              },
              {
                "availability": "different_method",
                "conditions": "Một URL thực tế cho mỗi đối tượng images[]. Số phần tử mảng khác với nút lá dạng chuỗi này.",
                "decoded_max_bytes": 20971520,
                "default": null,
                "default_known": false,
                "enum": null,
                "enum_known": false,
                "maximum_images_per_array": 9,
                "mime_types": [
                  "image/png",
                  "image/jpeg"
                ],
                "name": "images[].image_url",
                "required": false,
                "type": "string",
                "when": "Chỉ JSON images/edits; JSON images/generations không phân tích các tham chiếu images."
              },
              {
                "availability": "source_interface",
                "default": null,
                "default_known": false,
                "enum": null,
                "enum_known": false,
                "maximum_decoded_bytes": 20971520,
                "mime_types": [
                  "image/png",
                  "image/jpeg"
                ],
                "name": "image",
                "required": false,
                "type": "file",
                "when": "tạo bằng multipart/form-data"
              },
              {
                "availability": "source_interface",
                "default": null,
                "default_known": false,
                "enum": null,
                "enum_known": false,
                "maximum_decoded_bytes": 20971520,
                "maximum_items": 9,
                "mime_types": [
                  "image/png",
                  "image/jpeg"
                ],
                "name": "image[]",
                "required": false,
                "type": "file[]",
                "when": "tạo bằng multipart/form-data"
              }
            ],
            "profile_binding": "Exact existing Ailoot model and method; interface constraints below do not assert provider qualification.",
            "unsupported": [
              "images[].file_id",
              "mask.file_id",
              "mask",
              "stream=true",
              "mask input is rejected by this Alibaba adapter"
            ]
          },
          "hints": [
            "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."
          ],
          "input": {
            "content_type": "application/json",
            "material_types": [
              "text"
            ],
            "optional_controls": null,
            "required": [
              "model",
              "prompt"
            ]
          },
          "lifecycle": {
            "assets": [
              {
                "http": "GET",
                "path": "/v1/media/assets"
              },
              {
                "http": "GET",
                "path": "/v1/media/assets/{asset_id}"
              }
            ],
            "content": [
              {
                "http": "GET",
                "path": "/v1/media/assets/{asset_id}/content",
                "url_source": "exact returned signed URL; never construct token"
              }
            ],
            "mode": "synchronous_result_then_owned_library",
            "operation_id_is_not_task_id": true,
            "status": [
              {
                "http": "GET",
                "id_source": "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",
                "path": "/v1/media/tasks/{task_id}"
              }
            ],
            "unknown": "If an image generation or edit result requires a check, keep the original operation_id/X-Client-Request-ID and returned result information. Recover existing owned results through the media library using actual task_id or asset_id values. Do not resubmit the generation/edit request or construct a polling URL from operation_id."
          },
          "method": {
            "http": "POST",
            "path": "/v1/images/generations"
          },
          "operation_modes": [
            "images"
          ],
          "output": {
            "family": [
              "image"
            ],
            "format": null,
            "multioutputs": "retain every actual response output"
          }
        },
        "ctx": null,
        "examples": [
          {
            "code": "set -eu\n: \"${AILOOT_API_KEY:?Set your Ailoot API key}\"\nexport AILOOT_API_KEY\nexport AILOOT_API_KEY\n: \"${AILOOT_PROMPT_FILE:?Set your actual UTF-8 image brief}\"\nexport AILOOT_PROMPT_FILE\npython3 - <<'PY_REQUEST'\nimport json,os\nfrom pathlib import Path\np=json.loads('{\"model\": \"wan2.7-image-pro\", \"prompt\": \"\"}')\nf=Path(os.environ[\"AILOOT_PROMPT_FILE\"])\nif not f.is_file():raise SystemExit(\"Choose your actual UTF-8 brief\")\np['prompt']=f.read_text(encoding=\"utf-8\")\nif not p['prompt'].strip():raise SystemExit(\"Brief must contain text\")\nPath(\"request.json\").write_text(json.dumps(p,ensure_ascii=False))\nPY_REQUEST\ncurl --fail-with-body --silent --show-error https://api.ailoot.ai/v1/images/generations \\\n  -H \"Authorization: Bearer $AILOOT_API_KEY\" -H 'Content-Type: application/json' \\\n  --data-binary @request.json -D response-headers.txt -o result.json\npython3 - <<'PY_RESULT'\nimport base64, json, os, subprocess\nfrom pathlib import Path\nfrom urllib.parse import urlsplit, urljoin\n\ndef save_images(items):\n    if not items: raise SystemExit(\"No completed images; retain the full response\")\n    for index, item in enumerate(items):\n        encoded=item.get(\"b64_json\")\n        uri=item.get(\"url\", \"\")\n        if not encoded and uri.startswith(\"data:image/\"):\n            header, separator, encoded=uri.partition(\",\")\n            if not separator or \";base64\" not in header: raise SystemExit(\"Unsupported image data URI\")\n        if encoded:\n            raw=base64.b64decode(encoded,validate=True)\n        elif uri:\n            uri=urljoin(\"https://api.ailoot.ai\",uri)\n            parsed=urlsplit(uri)\n            if parsed.scheme!=\"https\" or not parsed.netloc or parsed.username or parsed.password:\n                raise SystemExit(\"Invalid returned image URL\")\n            owned=parsed.netloc==\"api.ailoot.ai\" and parsed.path.startswith(\"/v1/media/assets/\") and parsed.path.endswith(\"/content\")\n            args=[\"curl\",\"--fail-with-body\",\"--silent\",\"--show-error\",uri]\n            if owned: args += [\"-H\",\"Authorization: Bearer \"+os.environ[\"AILOOT_API_KEY\"]]\n            temporary=Path(f\"image-{index}.bin\")\n            subprocess.run(args+[\"-o\",str(temporary)],check=True)\n            raw=temporary.read_bytes()\n            temporary.unlink()\n        else: raise SystemExit(\"Image has neither bytes nor URL\")\n        if not raw: raise SystemExit(\"Empty image result\")\n        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\"\n        Path(f\"image-{index}.{ext}\").write_bytes(raw)\n    print(\"Every returned image saved; complete response metadata retained\")\nsave_images(json.loads(Path(\"result.json\").read_text())[\"data\"])\nPY_RESULT\n",
            "label": "Create and save every image",
            "language": "bash"
          },
          {
            "code": "from openai import OpenAI\nimport base64, json, os, subprocess\nfrom pathlib import Path\nfrom urllib.parse import urlsplit, urljoin\n\ndef save_images(items):\n    if not items: raise SystemExit(\"No completed images; retain the full response\")\n    for index, item in enumerate(items):\n        encoded=item.get(\"b64_json\")\n        uri=item.get(\"url\", \"\")\n        if not encoded and uri.startswith(\"data:image/\"):\n            header, separator, encoded=uri.partition(\",\")\n            if not separator or \";base64\" not in header: raise SystemExit(\"Unsupported image data URI\")\n        if encoded:\n            raw=base64.b64decode(encoded,validate=True)\n        elif uri:\n            uri=urljoin(\"https://api.ailoot.ai\",uri)\n            parsed=urlsplit(uri)\n            if parsed.scheme!=\"https\" or not parsed.netloc or parsed.username or parsed.password:\n                raise SystemExit(\"Invalid returned image URL\")\n            owned=parsed.netloc==\"api.ailoot.ai\" and parsed.path.startswith(\"/v1/media/assets/\") and parsed.path.endswith(\"/content\")\n            args=[\"curl\",\"--fail-with-body\",\"--silent\",\"--show-error\",uri]\n            if owned: args += [\"-H\",\"Authorization: Bearer \"+os.environ[\"AILOOT_API_KEY\"]]\n            temporary=Path(f\"image-{index}.bin\")\n            subprocess.run(args+[\"-o\",str(temporary)],check=True)\n            raw=temporary.read_bytes()\n            temporary.unlink()\n        else: raise SystemExit(\"Image has neither bytes nor URL\")\n        if not raw: raise SystemExit(\"Empty image result\")\n        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\"\n        Path(f\"image-{index}.{ext}\").write_bytes(raw)\n    print(\"Every returned image saved; complete response metadata retained\")\n\nf=Path(os.environ[\"AILOOT_PROMPT_FILE\"])\nif not f.is_file():raise SystemExit(\"Set your actual UTF-8 image brief file\")\nrequest={'model': 'wan2.7-image-pro', 'prompt': ''}\nrequest[\"prompt\"]=f.read_text(encoding=\"utf-8\")\nclient=OpenAI(base_url=\"https://api.ailoot.ai/v1\",api_key=os.environ[\"AILOOT_API_KEY\"],max_retries=0)\nresult=client.images.generate(**request)\nPath(\"sdk-result.txt\").write_text(str(result),encoding=\"utf-8\")\nsave_images([{\"b64_json\":getattr(item,\"b64_json\",None),\"url\":getattr(item,\"url\",None)} for item in result.data])\n",
            "label": "Python SDK · save all image outputs",
            "language": "python"
          },
          {
            "code": "import OpenAI from \"openai\";\nimport { readFileSync, writeFileSync } from \"node:fs\";\nconst key=process.env.AILOOT_API_KEY;\nif(!key) throw new Error(\"Set your actual Ailoot API key\");\nconst client=new OpenAI({baseURL:\"https://api.ailoot.ai/v1\",apiKey:key,maxRetries:0});\nconst request={\"model\": \"wan2.7-image-pro\", \"prompt\": \"\"};\nif(!process.env.AILOOT_PROMPT_FILE)throw new Error(\"Set your actual UTF-8 image brief file\");\nrequest.prompt=readFileSync(process.env.AILOOT_PROMPT_FILE,\"utf8\");\nconst result=await client.images.generate(request);\nwriteFileSync(\"sdk-result.json\",JSON.stringify(result,null,2));\nif(!result.data?.length) throw new Error(\"No completed images\");\nfor(let index=0;index<result.data.length;index++) {\n  const item=result.data[index];let encoded=item.b64_json,uri=item.url||\"\",raw;\n  if(!encoded && uri.startsWith(\"data:image/\")) {\n    const comma=uri.indexOf(\",\");if(comma<0 || !uri.slice(0,comma).includes(\";base64\")) throw new Error(\"Unsupported image data URI\");\n    encoded=uri.slice(comma+1);\n  }\n  if(encoded) {\n    if(encoded.length%4!==0 || !/^[A-Za-z0-9+/]*={0,2}$/.test(encoded)) throw new Error(\"Invalid Base64\");\n    raw=Buffer.from(encoded,\"base64\");\n  } else if(uri) {\n    const u=new URL(uri,\"https://api.ailoot.ai\");\n    if(u.protocol!==\"https:\" || u.username || u.password) throw new Error(\"Invalid returned URL\");\n    const owned=u.origin===\"https://api.ailoot.ai\" && u.pathname.startsWith(\"/v1/media/assets/\") && u.pathname.endsWith(\"/content\");\n    const response=await fetch(u,{headers:owned?{Authorization:\"Bearer \"+key}:{},redirect:\"manual\"});\n    if(!response.ok) throw new Error(\"Image content download failed: \"+response.status);\n    raw=Buffer.from(await response.arrayBuffer());\n  } else throw new Error(\"Image has neither bytes nor URL\");\n  if(!raw.length) throw new Error(\"Empty image result\");\n  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\";\n  writeFileSync(`image-${index}.${ext}`,raw);\n}\nconsole.log(\"Every returned image saved; sdk-result.json retains complete metadata\");\n",
            "label": "Node SDK · save all image outputs",
            "language": "js"
          }
        ],
        "family": "openai",
        "fast_multiplier": null,
        "flex_multiplier": null,
        "fmt": "images",
        "http": "POST",
        "img_in": null,
        "img_out": null,
        "in": null,
        "input": [
          "text"
        ],
        "label": "Ảnh",
        "max_out": null,
        "max_tool_calls": null,
        "out": null,
        "output": [
          "image"
        ],
        "path": "/v1/images/generations",
        "pricing_profiles": [
          {
            "dimensions": {},
            "label": "Core",
            "units": [
              {
                "amount": 0.075,
                "amount_unit": "usd_per_display_unit",
                "key": "image_output_1k",
                "label": "per 1K image",
                "side": "out"
              },
              {
                "amount": 0.075,
                "amount_unit": "usd_per_display_unit",
                "key": "image_output_2k",
                "label": "per 2K image",
                "side": "out"
              }
            ]
          }
        ],
        "request_model_id": "wan2.7-image-pro",
        "route_label": "Core",
        "status_reads": [],
        "tiers": [],
        "tool_prices": null,
        "unit": "conditional",
        "units": [
          {
            "key": "image_output_1k",
            "label": "per 1K image",
            "side": "out",
            "usd": 0.075
          },
          {
            "key": "image_output_2k",
            "label": "per 2K image",
            "side": "out",
            "usd": 0.075
          }
        ]
      },
      {
        "cache_read": null,
        "cache_write": null,
        "cache_write_1h": null,
        "cache_write_5m": null,
        "conditional_meter": null,
        "contract": {
          "data": {
            "all_results": "Save every data item. Decode each b64_json or fetch every returned signed URL. Select a filename extension from the actual MIME/bytes.",
            "errors": [
              {
                "code": null,
                "condition": "Trườ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ệ",
                "http_status": 400,
                "recovery": "Sửa các trường được chỉ ra trước khi gửi yêu cầu tạo mới.",
                "type": "invalid_request_error"
              },
              {
                "code": null,
                "condition": "Phản hồi trả về cho biết thao tác hoặc kết quả cần được kiểm tra",
                "http_status": null,
                "recovery": "Giữ 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.",
                "type": "server_error"
              }
            ],
            "hints": [
              "Qwen defaultsize1024*1024; Wan defaultsize1K. Wan2.7 Pro4K is supported only without reference inputs.",
              "Explicit dimensions must be positive, at most4096 peraxis, within8:1..1:8 aspect, and the exact model/input area range.",
              "The Alibaba image adapter rejects mask input and streaming before sending the request.",
              "For this generation method, actual image references are supported as multipart image files. JSONimages[].image_url is read only on images/edits; the leaf value is a string."
            ],
            "ignored_fields": [
              "quality",
              "background",
              "style",
              "output_format",
              "output_compression",
              "moderation",
              "input_fidelity",
              "partial_images without streaming"
            ],
            "lifecycle": {
              "all_results": "Follow everyactualreturnedoutputandownedasset; no result is discardedbecauseindex0orcontent_urlalreadyexists.",
              "assets": [
                {
                  "http": "GET",
                  "path": "/v1/media/assets"
                },
                {
                  "http": "GET",
                  "path": "/v1/media/assets/{asset_id}"
                }
              ],
              "content": [
                {
                  "http": "GET",
                  "path": "/v1/media/assets/{asset_id}/content",
                  "url_source": "exact returned signed URL; never construct token"
                }
              ],
              "mode": "synchronous_result_then_owned_library",
              "operation_id_is_not_task_id": true,
              "status": [
                {
                  "http": "GET",
                  "id_source": "actual returned task_id or media library record",
                  "path": "/v1/media/tasks/{task_id}"
                }
              ],
              "unknown": "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."
            },
            "material_combinations": [
              {
                "content_type": "application/json",
                "ignored_reference_field": "JSONgeneration images[] is not parsed; images[].image_url belongs to a separately supported JSONedit profile.",
                "mask": false,
                "mode": "text_to_image",
                "reference_images": false,
                "required": [
                  "prompt"
                ],
                "supplied_materials": [
                  "UTF8 prompt"
                ]
              },
              {
                "content_type": "multipart/form-data",
                "mask": false,
                "maximum_decoded_bytes_per_image": 20971520,
                "maximum_reference_images": 9,
                "mime_types": [
                  "image/png",
                  "image/jpeg"
                ],
                "minimum_reference_images": 0,
                "mode": "reference_images_generation",
                "optional_file_fields": [
                  "image",
                  "image[]",
                  "image[index]"
                ],
                "reference_images": true,
                "required": [
                  "prompt"
                ],
                "supplied_materials": [
                  "UTF8 prompt",
                  "actual PNG/JPEG file references"
                ]
              }
            ],
            "media_library": {
              "asset": {
                "fields": [
                  {
                    "description": null,
                    "name": "asset_id",
                    "type": "string"
                  },
                  {
                    "description": null,
                    "name": "task_id",
                    "type": "string"
                  },
                  {
                    "description": null,
                    "name": "output_key",
                    "type": "string"
                  },
                  {
                    "description": null,
                    "name": "family",
                    "type": "string"
                  },
                  {
                    "description": null,
                    "name": "model",
                    "type": "string"
                  },
                  {
                    "description": null,
                    "name": "method",
                    "type": "string"
                  },
                  {
                    "description": null,
                    "name": "status",
                    "type": "string"
                  },
                  {
                    "description": null,
                    "name": "content_type",
                    "type": "string"
                  },
                  {
                    "description": null,
                    "name": "sha256",
                    "type": "string"
                  },
                  {
                    "description": null,
                    "name": "size_bytes",
                    "type": "integer"
                  },
                  {
                    "description": null,
                    "name": "content_url",
                    "type": "string"
                  }
                ],
                "http": "GET",
                "id_source": "actual returned asset_id",
                "path": "/v1/media/assets/{asset_id}"
              },
              "content": {
                "http": "GET",
                "path": "/v1/media/assets/{asset_id}/content",
                "range_header_supported": true,
                "url_source": "Use exact returned signed content_url including its token; do not construct a token."
              },
              "expired_link": {
                "code": "link_expired",
                "http_status": 404,
                "recovery": "Read the asset again to obtain its refreshed signed content_url, then fetch that URL. Do not regenerate."
              },
              "list": {
                "all_pages": "Follow every returned next_cursor, then select records by their actual task_id/output_key.",
                "http": "GET",
                "output_fields": [
                  {
                    "description": null,
                    "name": "object",
                    "type": "string"
                  },
                  {
                    "description": null,
                    "name": "data",
                    "type": "asset[]"
                  },
                  {
                    "description": null,
                    "name": "next_cursor",
                    "type": "string|null"
                  }
                ],
                "parameters": [
                  {
                    "availability": "source_interface",
                    "default": null,
                    "default_known": false,
                    "enum": null,
                    "enum_known": false,
                    "name": "family",
                    "required": false,
                    "type": "string"
                  },
                  {
                    "availability": "source_interface",
                    "default": null,
                    "default_known": false,
                    "enum": null,
                    "enum_known": false,
                    "name": "cursor",
                    "required": false,
                    "type": "string"
                  },
                  {
                    "availability": "source_interface",
                    "default": 20,
                    "default_known": true,
                    "enum": null,
                    "enum_known": false,
                    "maximum": 100,
                    "minimum": 1,
                    "name": "limit",
                    "required": false,
                    "type": "integer"
                  }
                ],
                "path": "/v1/media/assets"
              },
              "revoke": {
                "http": "DELETE",
                "meaning": "Revokes/deletes the existing owned file; this is not generation cancellation.",
                "path": "/v1/media/assets/{asset_id}",
                "pending_status": "revoking",
                "success_statuses": [
                  202,
                  204
                ]
              },
              "task": {
                "http": "GET",
                "id_source": "actual returned task_id or media library record; operation_id is not task_id",
                "path": "/v1/media/tasks/{task_id}"
              }
            },
            "operation_modes": [
              "text_to_image",
              "reference_images_generation_via_multipart"
            ],
            "outputs": {
              "all_results": "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ế.",
              "family": "image",
              "fields": [
                {
                  "description": null,
                  "name": "created",
                  "type": "integer"
                },
                {
                  "description": null,
                  "name": "data[].url",
                  "type": "string"
                },
                {
                  "description": null,
                  "name": "data[].b64_json",
                  "type": "base64 string"
                },
                {
                  "description": null,
                  "name": "usage",
                  "type": "object"
                }
              ],
              "format": "actual validated raster MIME"
            },
            "parameter_conditions": {
              "size": {
                "aspect_ratio_range": [
                  "1:8",
                  "8:1"
                ],
                "default": "1K",
                "max_area_4k_condition": "WanPro and no inputimages",
                "max_dimension": 4096,
                "maximum_area": 16777216,
                "minimum_area": 589824
              }
            },
            "parameters": [
              {
                "availability": "source_interface",
                "default": null,
                "default_known": false,
                "enum": [
                  "wan-image"
                ],
                "enum_known": true,
                "name": "model",
                "required": true,
                "type": "string"
              },
              {
                "availability": "source_interface",
                "default": null,
                "default_known": false,
                "enum": null,
                "enum_known": false,
                "min_length": 1,
                "name": "prompt",
                "required": true,
                "type": "string"
              },
              {
                "availability": "source_interface",
                "default": 1,
                "default_known": true,
                "enum": null,
                "enum_known": false,
                "minimum": 1,
                "name": "n",
                "required": false,
                "type": "integer"
              },
              {
                "availability": "source_interface",
                "default": null,
                "default_known": false,
                "enum": [
                  "url",
                  "b64_json"
                ],
                "enum_known": true,
                "name": "response_format",
                "required": false,
                "type": "string"
              },
              {
                "availability": "source_interface",
                "default": false,
                "default_known": true,
                "enum": null,
                "enum_known": false,
                "name": "stream",
                "required": false,
                "type": "boolean"
              },
              {
                "availability": "model_dependent",
                "default": null,
                "default_known": false,
                "enum": null,
                "enum_known": false,
                "name": "size",
                "required": false,
                "type": "string"
              },
              {
                "availability": "model_dependent",
                "default": null,
                "default_known": false,
                "enum": null,
                "enum_known": false,
                "name": "partial_images",
                "required": false,
                "type": "integer"
              },
              {
                "availability": "different_method",
                "conditions": "Một URL thực tế cho mỗi đối tượng images[]. Số phần tử mảng khác với nút lá dạng chuỗi này.",
                "decoded_max_bytes": 20971520,
                "default": null,
                "default_known": false,
                "enum": null,
                "enum_known": false,
                "maximum_images_per_array": 9,
                "mime_types": [
                  "image/png",
                  "image/jpeg"
                ],
                "name": "images[].image_url",
                "required": false,
                "type": "string",
                "when": "Chỉ JSON images/edits; JSON images/generations không phân tích các tham chiếu images."
              },
              {
                "availability": "source_interface",
                "default": null,
                "default_known": false,
                "enum": null,
                "enum_known": false,
                "maximum_decoded_bytes": 20971520,
                "mime_types": [
                  "image/png",
                  "image/jpeg"
                ],
                "name": "image",
                "required": false,
                "type": "file",
                "when": "tạo bằng multipart/form-data"
              },
              {
                "availability": "source_interface",
                "default": null,
                "default_known": false,
                "enum": null,
                "enum_known": false,
                "maximum_decoded_bytes": 20971520,
                "maximum_items": 9,
                "mime_types": [
                  "image/png",
                  "image/jpeg"
                ],
                "name": "image[]",
                "required": false,
                "type": "file[]",
                "when": "tạo bằng multipart/form-data"
              }
            ],
            "profile_binding": "Exact existing Ailoot model and method; interface constraints below do not assert provider qualification.",
            "unsupported": [
              "images[].file_id",
              "mask.file_id",
              "mask",
              "stream=true",
              "mask input is rejected by this Alibaba adapter"
            ]
          },
          "hints": [
            "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."
          ],
          "input": {
            "content_type": "application/json",
            "material_types": [
              "text"
            ],
            "optional_controls": null,
            "required": [
              "model",
              "prompt"
            ]
          },
          "lifecycle": {
            "assets": [
              {
                "http": "GET",
                "path": "/v1/media/assets"
              },
              {
                "http": "GET",
                "path": "/v1/media/assets/{asset_id}"
              }
            ],
            "content": [
              {
                "http": "GET",
                "path": "/v1/media/assets/{asset_id}/content",
                "url_source": "exact returned signed URL; never construct token"
              }
            ],
            "mode": "synchronous_result_then_owned_library",
            "operation_id_is_not_task_id": true,
            "status": [
              {
                "http": "GET",
                "id_source": "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",
                "path": "/v1/media/tasks/{task_id}"
              }
            ],
            "unknown": "If an image generation or edit result requires a check, keep the original operation_id/X-Client-Request-ID and returned result information. Recover existing owned results through the media library using actual task_id or asset_id values. Do not resubmit the generation/edit request or construct a polling URL from operation_id."
          },
          "method": {
            "http": "POST",
            "path": "/v1/images/generations"
          },
          "operation_modes": [
            "images"
          ],
          "output": {
            "family": [
              "image"
            ],
            "format": null,
            "multioutputs": "retain every actual response output"
          }
        },
        "ctx": null,
        "examples": [
          {
            "code": "set -eu\n: \"${AILOOT_API_KEY:?Set your Ailoot API key}\"\nexport AILOOT_API_KEY\nexport AILOOT_API_KEY\n: \"${AILOOT_PROMPT_FILE:?Set your actual UTF-8 image brief}\"\nexport AILOOT_PROMPT_FILE\npython3 - <<'PY_REQUEST'\nimport json,os\nfrom pathlib import Path\np=json.loads('{\"model\": \"wan-image\", \"prompt\": \"\"}')\nf=Path(os.environ[\"AILOOT_PROMPT_FILE\"])\nif not f.is_file():raise SystemExit(\"Choose your actual UTF-8 brief\")\np['prompt']=f.read_text(encoding=\"utf-8\")\nif not p['prompt'].strip():raise SystemExit(\"Brief must contain text\")\nPath(\"request.json\").write_text(json.dumps(p,ensure_ascii=False))\nPY_REQUEST\ncurl --fail-with-body --silent --show-error https://api.ailoot.ai/v1/images/generations \\\n  -H \"Authorization: Bearer $AILOOT_API_KEY\" -H 'Content-Type: application/json' \\\n  --data-binary @request.json -D response-headers.txt -o result.json\npython3 - <<'PY_RESULT'\nimport base64, json, os, subprocess\nfrom pathlib import Path\nfrom urllib.parse import urlsplit, urljoin\n\ndef save_images(items):\n    if not items: raise SystemExit(\"No completed images; retain the full response\")\n    for index, item in enumerate(items):\n        encoded=item.get(\"b64_json\")\n        uri=item.get(\"url\", \"\")\n        if not encoded and uri.startswith(\"data:image/\"):\n            header, separator, encoded=uri.partition(\",\")\n            if not separator or \";base64\" not in header: raise SystemExit(\"Unsupported image data URI\")\n        if encoded:\n            raw=base64.b64decode(encoded,validate=True)\n        elif uri:\n            uri=urljoin(\"https://api.ailoot.ai\",uri)\n            parsed=urlsplit(uri)\n            if parsed.scheme!=\"https\" or not parsed.netloc or parsed.username or parsed.password:\n                raise SystemExit(\"Invalid returned image URL\")\n            owned=parsed.netloc==\"api.ailoot.ai\" and parsed.path.startswith(\"/v1/media/assets/\") and parsed.path.endswith(\"/content\")\n            args=[\"curl\",\"--fail-with-body\",\"--silent\",\"--show-error\",uri]\n            if owned: args += [\"-H\",\"Authorization: Bearer \"+os.environ[\"AILOOT_API_KEY\"]]\n            temporary=Path(f\"image-{index}.bin\")\n            subprocess.run(args+[\"-o\",str(temporary)],check=True)\n            raw=temporary.read_bytes()\n            temporary.unlink()\n        else: raise SystemExit(\"Image has neither bytes nor URL\")\n        if not raw: raise SystemExit(\"Empty image result\")\n        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\"\n        Path(f\"image-{index}.{ext}\").write_bytes(raw)\n    print(\"Every returned image saved; complete response metadata retained\")\nsave_images(json.loads(Path(\"result.json\").read_text())[\"data\"])\nPY_RESULT\n",
            "label": "Create and save every image",
            "language": "bash"
          },
          {
            "code": "from openai import OpenAI\nimport base64, json, os, subprocess\nfrom pathlib import Path\nfrom urllib.parse import urlsplit, urljoin\n\ndef save_images(items):\n    if not items: raise SystemExit(\"No completed images; retain the full response\")\n    for index, item in enumerate(items):\n        encoded=item.get(\"b64_json\")\n        uri=item.get(\"url\", \"\")\n        if not encoded and uri.startswith(\"data:image/\"):\n            header, separator, encoded=uri.partition(\",\")\n            if not separator or \";base64\" not in header: raise SystemExit(\"Unsupported image data URI\")\n        if encoded:\n            raw=base64.b64decode(encoded,validate=True)\n        elif uri:\n            uri=urljoin(\"https://api.ailoot.ai\",uri)\n            parsed=urlsplit(uri)\n            if parsed.scheme!=\"https\" or not parsed.netloc or parsed.username or parsed.password:\n                raise SystemExit(\"Invalid returned image URL\")\n            owned=parsed.netloc==\"api.ailoot.ai\" and parsed.path.startswith(\"/v1/media/assets/\") and parsed.path.endswith(\"/content\")\n            args=[\"curl\",\"--fail-with-body\",\"--silent\",\"--show-error\",uri]\n            if owned: args += [\"-H\",\"Authorization: Bearer \"+os.environ[\"AILOOT_API_KEY\"]]\n            temporary=Path(f\"image-{index}.bin\")\n            subprocess.run(args+[\"-o\",str(temporary)],check=True)\n            raw=temporary.read_bytes()\n            temporary.unlink()\n        else: raise SystemExit(\"Image has neither bytes nor URL\")\n        if not raw: raise SystemExit(\"Empty image result\")\n        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\"\n        Path(f\"image-{index}.{ext}\").write_bytes(raw)\n    print(\"Every returned image saved; complete response metadata retained\")\n\nf=Path(os.environ[\"AILOOT_PROMPT_FILE\"])\nif not f.is_file():raise SystemExit(\"Set your actual UTF-8 image brief file\")\nrequest={'model': 'wan-image', 'prompt': ''}\nrequest[\"prompt\"]=f.read_text(encoding=\"utf-8\")\nclient=OpenAI(base_url=\"https://api.ailoot.ai/v1\",api_key=os.environ[\"AILOOT_API_KEY\"],max_retries=0)\nresult=client.images.generate(**request)\nPath(\"sdk-result.txt\").write_text(str(result),encoding=\"utf-8\")\nsave_images([{\"b64_json\":getattr(item,\"b64_json\",None),\"url\":getattr(item,\"url\",None)} for item in result.data])\n",
            "label": "Python SDK · save all image outputs",
            "language": "python"
          },
          {
            "code": "import OpenAI from \"openai\";\nimport { readFileSync, writeFileSync } from \"node:fs\";\nconst key=process.env.AILOOT_API_KEY;\nif(!key) throw new Error(\"Set your actual Ailoot API key\");\nconst client=new OpenAI({baseURL:\"https://api.ailoot.ai/v1\",apiKey:key,maxRetries:0});\nconst request={\"model\": \"wan-image\", \"prompt\": \"\"};\nif(!process.env.AILOOT_PROMPT_FILE)throw new Error(\"Set your actual UTF-8 image brief file\");\nrequest.prompt=readFileSync(process.env.AILOOT_PROMPT_FILE,\"utf8\");\nconst result=await client.images.generate(request);\nwriteFileSync(\"sdk-result.json\",JSON.stringify(result,null,2));\nif(!result.data?.length) throw new Error(\"No completed images\");\nfor(let index=0;index<result.data.length;index++) {\n  const item=result.data[index];let encoded=item.b64_json,uri=item.url||\"\",raw;\n  if(!encoded && uri.startsWith(\"data:image/\")) {\n    const comma=uri.indexOf(\",\");if(comma<0 || !uri.slice(0,comma).includes(\";base64\")) throw new Error(\"Unsupported image data URI\");\n    encoded=uri.slice(comma+1);\n  }\n  if(encoded) {\n    if(encoded.length%4!==0 || !/^[A-Za-z0-9+/]*={0,2}$/.test(encoded)) throw new Error(\"Invalid Base64\");\n    raw=Buffer.from(encoded,\"base64\");\n  } else if(uri) {\n    const u=new URL(uri,\"https://api.ailoot.ai\");\n    if(u.protocol!==\"https:\" || u.username || u.password) throw new Error(\"Invalid returned URL\");\n    const owned=u.origin===\"https://api.ailoot.ai\" && u.pathname.startsWith(\"/v1/media/assets/\") && u.pathname.endsWith(\"/content\");\n    const response=await fetch(u,{headers:owned?{Authorization:\"Bearer \"+key}:{},redirect:\"manual\"});\n    if(!response.ok) throw new Error(\"Image content download failed: \"+response.status);\n    raw=Buffer.from(await response.arrayBuffer());\n  } else throw new Error(\"Image has neither bytes nor URL\");\n  if(!raw.length) throw new Error(\"Empty image result\");\n  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\";\n  writeFileSync(`image-${index}.${ext}`,raw);\n}\nconsole.log(\"Every returned image saved; sdk-result.json retains complete metadata\");\n",
            "label": "Node SDK · save all image outputs",
            "language": "js"
          }
        ],
        "family": "openai",
        "fast_multiplier": null,
        "flex_multiplier": null,
        "fmt": "images",
        "http": "POST",
        "img_in": null,
        "img_out": null,
        "in": null,
        "input": [
          "text"
        ],
        "label": "Ảnh",
        "max_out": null,
        "max_tool_calls": null,
        "out": null,
        "output": [
          "image"
        ],
        "path": "/v1/images/generations",
        "pricing_profiles": [
          {
            "dimensions": {},
            "label": "Core",
            "units": [
              {
                "amount": 0.075,
                "amount_unit": "usd_per_display_unit",
                "key": "image_output_1k",
                "label": "per 1K image",
                "side": "out"
              },
              {
                "amount": 0.075,
                "amount_unit": "usd_per_display_unit",
                "key": "image_output_2k",
                "label": "per 2K image",
                "side": "out"
              }
            ]
          }
        ],
        "request_model_id": "wan-image",
        "route_label": "Core",
        "status_reads": [],
        "tiers": [],
        "tool_prices": null,
        "unit": "conditional",
        "units": [
          {
            "key": "image_output_1k",
            "label": "per 1K image",
            "side": "out",
            "usd": 0.075
          },
          {
            "key": "image_output_2k",
            "label": "per 2K image",
            "side": "out",
            "usd": 0.075
          }
        ]
      },
      {
        "cache_read": null,
        "cache_write": null,
        "cache_write_1h": null,
        "cache_write_5m": null,
        "conditional_meter": null,
        "contract": {
          "data": {
            "all_results": "Save every data item. Decode each b64_json or fetch every returned signed URL. Select a filename extension from the actual MIME/bytes.",
            "errors": [
              {
                "code": null,
                "condition": "Trườ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ệ",
                "http_status": 400,
                "recovery": "Sửa các trường được chỉ ra trước khi gửi yêu cầu tạo mới.",
                "type": "invalid_request_error"
              },
              {
                "code": null,
                "condition": "Phản hồi trả về cho biết thao tác hoặc kết quả cần được kiểm tra",
                "http_status": null,
                "recovery": "Giữ 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.",
                "type": "server_error"
              }
            ],
            "hints": [
              "Qwen defaultsize1024*1024; Wan defaultsize1K. Wan2.7 Pro4K is supported only without reference inputs.",
              "Explicit dimensions must be positive, at most4096 peraxis, within8:1..1:8 aspect, and the exact model/input area range.",
              "The Alibaba image adapter rejects mask input and streaming before sending the request.",
              "For this generation method, actual image references are supported as multipart image files. JSONimages[].image_url is read only on images/edits; the leaf value is a string."
            ],
            "ignored_fields": [
              "quality",
              "background",
              "style",
              "output_format",
              "output_compression",
              "moderation",
              "input_fidelity",
              "partial_images without streaming"
            ],
            "lifecycle": {
              "all_results": "Follow everyactualreturnedoutputandownedasset; no result is discardedbecauseindex0orcontent_urlalreadyexists.",
              "assets": [
                {
                  "http": "GET",
                  "path": "/v1/media/assets"
                },
                {
                  "http": "GET",
                  "path": "/v1/media/assets/{asset_id}"
                }
              ],
              "content": [
                {
                  "http": "GET",
                  "path": "/v1/media/assets/{asset_id}/content",
                  "url_source": "exact returned signed URL; never construct token"
                }
              ],
              "mode": "synchronous_result_then_owned_library",
              "operation_id_is_not_task_id": true,
              "status": [
                {
                  "http": "GET",
                  "id_source": "actual returned task_id or media library record",
                  "path": "/v1/media/tasks/{task_id}"
                }
              ],
              "unknown": "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."
            },
            "material_combinations": [
              {
                "content_type": "application/json",
                "ignored_reference_field": "JSONgeneration images[] is not parsed; images[].image_url belongs to a separately supported JSONedit profile.",
                "mask": false,
                "mode": "text_to_image",
                "reference_images": false,
                "required": [
                  "prompt"
                ],
                "supplied_materials": [
                  "UTF8 prompt"
                ]
              },
              {
                "content_type": "multipart/form-data",
                "mask": false,
                "maximum_decoded_bytes_per_image": 20971520,
                "maximum_reference_images": 9,
                "mime_types": [
                  "image/png",
                  "image/jpeg"
                ],
                "minimum_reference_images": 0,
                "mode": "reference_images_generation",
                "optional_file_fields": [
                  "image",
                  "image[]",
                  "image[index]"
                ],
                "reference_images": true,
                "required": [
                  "prompt"
                ],
                "supplied_materials": [
                  "UTF8 prompt",
                  "actual PNG/JPEG file references"
                ]
              }
            ],
            "media_library": {
              "asset": {
                "fields": [
                  {
                    "description": null,
                    "name": "asset_id",
                    "type": "string"
                  },
                  {
                    "description": null,
                    "name": "task_id",
                    "type": "string"
                  },
                  {
                    "description": null,
                    "name": "output_key",
                    "type": "string"
                  },
                  {
                    "description": null,
                    "name": "family",
                    "type": "string"
                  },
                  {
                    "description": null,
                    "name": "model",
                    "type": "string"
                  },
                  {
                    "description": null,
                    "name": "method",
                    "type": "string"
                  },
                  {
                    "description": null,
                    "name": "status",
                    "type": "string"
                  },
                  {
                    "description": null,
                    "name": "content_type",
                    "type": "string"
                  },
                  {
                    "description": null,
                    "name": "sha256",
                    "type": "string"
                  },
                  {
                    "description": null,
                    "name": "size_bytes",
                    "type": "integer"
                  },
                  {
                    "description": null,
                    "name": "content_url",
                    "type": "string"
                  }
                ],
                "http": "GET",
                "id_source": "actual returned asset_id",
                "path": "/v1/media/assets/{asset_id}"
              },
              "content": {
                "http": "GET",
                "path": "/v1/media/assets/{asset_id}/content",
                "range_header_supported": true,
                "url_source": "Use exact returned signed content_url including its token; do not construct a token."
              },
              "expired_link": {
                "code": "link_expired",
                "http_status": 404,
                "recovery": "Read the asset again to obtain its refreshed signed content_url, then fetch that URL. Do not regenerate."
              },
              "list": {
                "all_pages": "Follow every returned next_cursor, then select records by their actual task_id/output_key.",
                "http": "GET",
                "output_fields": [
                  {
                    "description": null,
                    "name": "object",
                    "type": "string"
                  },
                  {
                    "description": null,
                    "name": "data",
                    "type": "asset[]"
                  },
                  {
                    "description": null,
                    "name": "next_cursor",
                    "type": "string|null"
                  }
                ],
                "parameters": [
                  {
                    "availability": "source_interface",
                    "default": null,
                    "default_known": false,
                    "enum": null,
                    "enum_known": false,
                    "name": "family",
                    "required": false,
                    "type": "string"
                  },
                  {
                    "availability": "source_interface",
                    "default": null,
                    "default_known": false,
                    "enum": null,
                    "enum_known": false,
                    "name": "cursor",
                    "required": false,
                    "type": "string"
                  },
                  {
                    "availability": "source_interface",
                    "default": 20,
                    "default_known": true,
                    "enum": null,
                    "enum_known": false,
                    "maximum": 100,
                    "minimum": 1,
                    "name": "limit",
                    "required": false,
                    "type": "integer"
                  }
                ],
                "path": "/v1/media/assets"
              },
              "revoke": {
                "http": "DELETE",
                "meaning": "Revokes/deletes the existing owned file; this is not generation cancellation.",
                "path": "/v1/media/assets/{asset_id}",
                "pending_status": "revoking",
                "success_statuses": [
                  202,
                  204
                ]
              },
              "task": {
                "http": "GET",
                "id_source": "actual returned task_id or media library record; operation_id is not task_id",
                "path": "/v1/media/tasks/{task_id}"
              }
            },
            "operation_modes": [
              "text_to_image",
              "reference_images_generation_via_multipart"
            ],
            "outputs": {
              "all_results": "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ế.",
              "family": "image",
              "fields": [
                {
                  "description": null,
                  "name": "created",
                  "type": "integer"
                },
                {
                  "description": null,
                  "name": "data[].url",
                  "type": "string"
                },
                {
                  "description": null,
                  "name": "data[].b64_json",
                  "type": "base64 string"
                },
                {
                  "description": null,
                  "name": "usage",
                  "type": "object"
                }
              ],
              "format": "actual validated raster MIME"
            },
            "parameter_conditions": {
              "size": {
                "aspect_ratio_range": [
                  "1:8",
                  "8:1"
                ],
                "default": "1K",
                "max_area_4k_condition": "WanPro and no inputimages",
                "max_dimension": 4096,
                "maximum_area": 16777216,
                "minimum_area": 589824
              }
            },
            "parameters": [
              {
                "availability": "source_interface",
                "default": null,
                "default_known": false,
                "enum": [
                  "wan-image-latest"
                ],
                "enum_known": true,
                "name": "model",
                "required": true,
                "type": "string"
              },
              {
                "availability": "source_interface",
                "default": null,
                "default_known": false,
                "enum": null,
                "enum_known": false,
                "min_length": 1,
                "name": "prompt",
                "required": true,
                "type": "string"
              },
              {
                "availability": "source_interface",
                "default": 1,
                "default_known": true,
                "enum": null,
                "enum_known": false,
                "minimum": 1,
                "name": "n",
                "required": false,
                "type": "integer"
              },
              {
                "availability": "source_interface",
                "default": null,
                "default_known": false,
                "enum": [
                  "url",
                  "b64_json"
                ],
                "enum_known": true,
                "name": "response_format",
                "required": false,
                "type": "string"
              },
              {
                "availability": "source_interface",
                "default": false,
                "default_known": true,
                "enum": null,
                "enum_known": false,
                "name": "stream",
                "required": false,
                "type": "boolean"
              },
              {
                "availability": "model_dependent",
                "default": null,
                "default_known": false,
                "enum": null,
                "enum_known": false,
                "name": "size",
                "required": false,
                "type": "string"
              },
              {
                "availability": "model_dependent",
                "default": null,
                "default_known": false,
                "enum": null,
                "enum_known": false,
                "name": "partial_images",
                "required": false,
                "type": "integer"
              },
              {
                "availability": "different_method",
                "conditions": "Một URL thực tế cho mỗi đối tượng images[]. Số phần tử mảng khác với nút lá dạng chuỗi này.",
                "decoded_max_bytes": 20971520,
                "default": null,
                "default_known": false,
                "enum": null,
                "enum_known": false,
                "maximum_images_per_array": 9,
                "mime_types": [
                  "image/png",
                  "image/jpeg"
                ],
                "name": "images[].image_url",
                "required": false,
                "type": "string",
                "when": "Chỉ JSON images/edits; JSON images/generations không phân tích các tham chiếu images."
              },
              {
                "availability": "source_interface",
                "default": null,
                "default_known": false,
                "enum": null,
                "enum_known": false,
                "maximum_decoded_bytes": 20971520,
                "mime_types": [
                  "image/png",
                  "image/jpeg"
                ],
                "name": "image",
                "required": false,
                "type": "file",
                "when": "tạo bằng multipart/form-data"
              },
              {
                "availability": "source_interface",
                "default": null,
                "default_known": false,
                "enum": null,
                "enum_known": false,
                "maximum_decoded_bytes": 20971520,
                "maximum_items": 9,
                "mime_types": [
                  "image/png",
                  "image/jpeg"
                ],
                "name": "image[]",
                "required": false,
                "type": "file[]",
                "when": "tạo bằng multipart/form-data"
              }
            ],
            "profile_binding": "Exact existing Ailoot model and method; interface constraints below do not assert provider qualification.",
            "unsupported": [
              "images[].file_id",
              "mask.file_id",
              "mask",
              "stream=true",
              "mask input is rejected by this Alibaba adapter"
            ]
          },
          "hints": [
            "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."
          ],
          "input": {
            "content_type": "application/json",
            "material_types": [
              "text"
            ],
            "optional_controls": null,
            "required": [
              "model",
              "prompt"
            ]
          },
          "lifecycle": {
            "assets": [
              {
                "http": "GET",
                "path": "/v1/media/assets"
              },
              {
                "http": "GET",
                "path": "/v1/media/assets/{asset_id}"
              }
            ],
            "content": [
              {
                "http": "GET",
                "path": "/v1/media/assets/{asset_id}/content",
                "url_source": "exact returned signed URL; never construct token"
              }
            ],
            "mode": "synchronous_result_then_owned_library",
            "operation_id_is_not_task_id": true,
            "status": [
              {
                "http": "GET",
                "id_source": "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",
                "path": "/v1/media/tasks/{task_id}"
              }
            ],
            "unknown": "If an image generation or edit result requires a check, keep the original operation_id/X-Client-Request-ID and returned result information. Recover existing owned results through the media library using actual task_id or asset_id values. Do not resubmit the generation/edit request or construct a polling URL from operation_id."
          },
          "method": {
            "http": "POST",
            "path": "/v1/images/generations"
          },
          "operation_modes": [
            "images"
          ],
          "output": {
            "family": [
              "image"
            ],
            "format": null,
            "multioutputs": "retain every actual response output"
          }
        },
        "ctx": null,
        "examples": [
          {
            "code": "set -eu\n: \"${AILOOT_API_KEY:?Set your Ailoot API key}\"\nexport AILOOT_API_KEY\nexport AILOOT_API_KEY\n: \"${AILOOT_PROMPT_FILE:?Set your actual UTF-8 image brief}\"\nexport AILOOT_PROMPT_FILE\npython3 - <<'PY_REQUEST'\nimport json,os\nfrom pathlib import Path\np=json.loads('{\"model\": \"wan-image-latest\", \"prompt\": \"\"}')\nf=Path(os.environ[\"AILOOT_PROMPT_FILE\"])\nif not f.is_file():raise SystemExit(\"Choose your actual UTF-8 brief\")\np['prompt']=f.read_text(encoding=\"utf-8\")\nif not p['prompt'].strip():raise SystemExit(\"Brief must contain text\")\nPath(\"request.json\").write_text(json.dumps(p,ensure_ascii=False))\nPY_REQUEST\ncurl --fail-with-body --silent --show-error https://api.ailoot.ai/v1/images/generations \\\n  -H \"Authorization: Bearer $AILOOT_API_KEY\" -H 'Content-Type: application/json' \\\n  --data-binary @request.json -D response-headers.txt -o result.json\npython3 - <<'PY_RESULT'\nimport base64, json, os, subprocess\nfrom pathlib import Path\nfrom urllib.parse import urlsplit, urljoin\n\ndef save_images(items):\n    if not items: raise SystemExit(\"No completed images; retain the full response\")\n    for index, item in enumerate(items):\n        encoded=item.get(\"b64_json\")\n        uri=item.get(\"url\", \"\")\n        if not encoded and uri.startswith(\"data:image/\"):\n            header, separator, encoded=uri.partition(\",\")\n            if not separator or \";base64\" not in header: raise SystemExit(\"Unsupported image data URI\")\n        if encoded:\n            raw=base64.b64decode(encoded,validate=True)\n        elif uri:\n            uri=urljoin(\"https://api.ailoot.ai\",uri)\n            parsed=urlsplit(uri)\n            if parsed.scheme!=\"https\" or not parsed.netloc or parsed.username or parsed.password:\n                raise SystemExit(\"Invalid returned image URL\")\n            owned=parsed.netloc==\"api.ailoot.ai\" and parsed.path.startswith(\"/v1/media/assets/\") and parsed.path.endswith(\"/content\")\n            args=[\"curl\",\"--fail-with-body\",\"--silent\",\"--show-error\",uri]\n            if owned: args += [\"-H\",\"Authorization: Bearer \"+os.environ[\"AILOOT_API_KEY\"]]\n            temporary=Path(f\"image-{index}.bin\")\n            subprocess.run(args+[\"-o\",str(temporary)],check=True)\n            raw=temporary.read_bytes()\n            temporary.unlink()\n        else: raise SystemExit(\"Image has neither bytes nor URL\")\n        if not raw: raise SystemExit(\"Empty image result\")\n        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\"\n        Path(f\"image-{index}.{ext}\").write_bytes(raw)\n    print(\"Every returned image saved; complete response metadata retained\")\nsave_images(json.loads(Path(\"result.json\").read_text())[\"data\"])\nPY_RESULT\n",
            "label": "Create and save every image",
            "language": "bash"
          },
          {
            "code": "from openai import OpenAI\nimport base64, json, os, subprocess\nfrom pathlib import Path\nfrom urllib.parse import urlsplit, urljoin\n\ndef save_images(items):\n    if not items: raise SystemExit(\"No completed images; retain the full response\")\n    for index, item in enumerate(items):\n        encoded=item.get(\"b64_json\")\n        uri=item.get(\"url\", \"\")\n        if not encoded and uri.startswith(\"data:image/\"):\n            header, separator, encoded=uri.partition(\",\")\n            if not separator or \";base64\" not in header: raise SystemExit(\"Unsupported image data URI\")\n        if encoded:\n            raw=base64.b64decode(encoded,validate=True)\n        elif uri:\n            uri=urljoin(\"https://api.ailoot.ai\",uri)\n            parsed=urlsplit(uri)\n            if parsed.scheme!=\"https\" or not parsed.netloc or parsed.username or parsed.password:\n                raise SystemExit(\"Invalid returned image URL\")\n            owned=parsed.netloc==\"api.ailoot.ai\" and parsed.path.startswith(\"/v1/media/assets/\") and parsed.path.endswith(\"/content\")\n            args=[\"curl\",\"--fail-with-body\",\"--silent\",\"--show-error\",uri]\n            if owned: args += [\"-H\",\"Authorization: Bearer \"+os.environ[\"AILOOT_API_KEY\"]]\n            temporary=Path(f\"image-{index}.bin\")\n            subprocess.run(args+[\"-o\",str(temporary)],check=True)\n            raw=temporary.read_bytes()\n            temporary.unlink()\n        else: raise SystemExit(\"Image has neither bytes nor URL\")\n        if not raw: raise SystemExit(\"Empty image result\")\n        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\"\n        Path(f\"image-{index}.{ext}\").write_bytes(raw)\n    print(\"Every returned image saved; complete response metadata retained\")\n\nf=Path(os.environ[\"AILOOT_PROMPT_FILE\"])\nif not f.is_file():raise SystemExit(\"Set your actual UTF-8 image brief file\")\nrequest={'model': 'wan-image-latest', 'prompt': ''}\nrequest[\"prompt\"]=f.read_text(encoding=\"utf-8\")\nclient=OpenAI(base_url=\"https://api.ailoot.ai/v1\",api_key=os.environ[\"AILOOT_API_KEY\"],max_retries=0)\nresult=client.images.generate(**request)\nPath(\"sdk-result.txt\").write_text(str(result),encoding=\"utf-8\")\nsave_images([{\"b64_json\":getattr(item,\"b64_json\",None),\"url\":getattr(item,\"url\",None)} for item in result.data])\n",
            "label": "Python SDK · save all image outputs",
            "language": "python"
          },
          {
            "code": "import OpenAI from \"openai\";\nimport { readFileSync, writeFileSync } from \"node:fs\";\nconst key=process.env.AILOOT_API_KEY;\nif(!key) throw new Error(\"Set your actual Ailoot API key\");\nconst client=new OpenAI({baseURL:\"https://api.ailoot.ai/v1\",apiKey:key,maxRetries:0});\nconst request={\"model\": \"wan-image-latest\", \"prompt\": \"\"};\nif(!process.env.AILOOT_PROMPT_FILE)throw new Error(\"Set your actual UTF-8 image brief file\");\nrequest.prompt=readFileSync(process.env.AILOOT_PROMPT_FILE,\"utf8\");\nconst result=await client.images.generate(request);\nwriteFileSync(\"sdk-result.json\",JSON.stringify(result,null,2));\nif(!result.data?.length) throw new Error(\"No completed images\");\nfor(let index=0;index<result.data.length;index++) {\n  const item=result.data[index];let encoded=item.b64_json,uri=item.url||\"\",raw;\n  if(!encoded && uri.startsWith(\"data:image/\")) {\n    const comma=uri.indexOf(\",\");if(comma<0 || !uri.slice(0,comma).includes(\";base64\")) throw new Error(\"Unsupported image data URI\");\n    encoded=uri.slice(comma+1);\n  }\n  if(encoded) {\n    if(encoded.length%4!==0 || !/^[A-Za-z0-9+/]*={0,2}$/.test(encoded)) throw new Error(\"Invalid Base64\");\n    raw=Buffer.from(encoded,\"base64\");\n  } else if(uri) {\n    const u=new URL(uri,\"https://api.ailoot.ai\");\n    if(u.protocol!==\"https:\" || u.username || u.password) throw new Error(\"Invalid returned URL\");\n    const owned=u.origin===\"https://api.ailoot.ai\" && u.pathname.startsWith(\"/v1/media/assets/\") && u.pathname.endsWith(\"/content\");\n    const response=await fetch(u,{headers:owned?{Authorization:\"Bearer \"+key}:{},redirect:\"manual\"});\n    if(!response.ok) throw new Error(\"Image content download failed: \"+response.status);\n    raw=Buffer.from(await response.arrayBuffer());\n  } else throw new Error(\"Image has neither bytes nor URL\");\n  if(!raw.length) throw new Error(\"Empty image result\");\n  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\";\n  writeFileSync(`image-${index}.${ext}`,raw);\n}\nconsole.log(\"Every returned image saved; sdk-result.json retains complete metadata\");\n",
            "label": "Node SDK · save all image outputs",
            "language": "js"
          }
        ],
        "family": "openai",
        "fast_multiplier": null,
        "flex_multiplier": null,
        "fmt": "images",
        "http": "POST",
        "img_in": null,
        "img_out": null,
        "in": null,
        "input": [
          "text"
        ],
        "label": "Ảnh",
        "max_out": null,
        "max_tool_calls": null,
        "out": null,
        "output": [
          "image"
        ],
        "path": "/v1/images/generations",
        "pricing_profiles": [
          {
            "dimensions": {},
            "label": "Core",
            "units": [
              {
                "amount": 0.075,
                "amount_unit": "usd_per_display_unit",
                "key": "image_output_1k",
                "label": "per 1K image",
                "side": "out"
              },
              {
                "amount": 0.075,
                "amount_unit": "usd_per_display_unit",
                "key": "image_output_2k",
                "label": "per 2K image",
                "side": "out"
              }
            ]
          }
        ],
        "request_model_id": "wan-image-latest",
        "route_label": "Core",
        "status_reads": [],
        "tiers": [],
        "tool_prices": null,
        "unit": "conditional",
        "units": [
          {
            "key": "image_output_1k",
            "label": "per 1K image",
            "side": "out",
            "usd": 0.075
          },
          {
            "key": "image_output_2k",
            "label": "per 2K image",
            "side": "out",
            "usd": 0.075
          }
        ]
      }
    ],
    "model_aliases": [
      {
        "canonical_model_id": "wan2.7-image-pro",
        "request_model_id": "wan2.7-image-pro",
        "route_label": "Core"
      },
      {
        "canonical_model_id": "wan2.7-image-pro",
        "request_model_id": "wan-image",
        "route_label": "Core"
      },
      {
        "canonical_model_id": "wan2.7-image-pro",
        "request_model_id": "wan-image-latest",
        "route_label": "Core"
      }
    ],
    "name": "wan2.7-image-pro",
    "price": {
      "in": null,
      "in_label": null,
      "out": 0.075,
      "out_label": "per 1K image",
      "sort_in": null,
      "sort_out": null,
      "varies": false
    },
    "short": "Mô hình tạo ảnh từ yêu cầu bằng văn bản. Nhà sản xuất cho phép điều khiển bảng màu và độ phân giải tối đa 4K khi tạo ảnh thông thường từ văn bản."
  },
  "renderer_schema": {
    "method_order": "Original DTO methods order; every exact route/format/path/caller survives.",
    "prices": "Original public DTO fields and original native display HTML; no flattened or normalized offers."
  },
  "representation": "exact-public-dto-and-native-renderer-html",
  "representationNotes": {
    "current_reference": {
      "about_json_pointer": "/aboutHtml",
      "methods": [
        {
          "contract_json_pointer": "/methods/0/rawMethod/contract",
          "html_json_pointer": "/methods/0/html",
          "method_ordinal": 0
        },
        {
          "contract_json_pointer": "/methods/1/rawMethod/contract",
          "html_json_pointer": "/methods/1/html",
          "method_ordinal": 1
        },
        {
          "contract_json_pointer": "/methods/2/rawMethod/contract",
          "html_json_pointer": "/methods/2/html",
          "method_ordinal": 2
        }
      ],
      "role": "current-semantic-reference"
    },
    "raw_input": {
      "examples_role": "historical-input-not-current-ready-examples",
      "json_pointers": [
        "/rawModel",
        "/methods/0/rawMethod",
        "/methods/1/rawMethod",
        "/methods/2/rawMethod"
      ],
      "role": "historical-owner-input"
    },
    "schema": "ailoot-native-model-representations-v1"
  },
  "schema": "ailoot-static-model-facts-v1",
  "schema_version": 1,
  "shortText": "Mô hình tạo ảnh từ yêu cầu bằng văn bản. Nhà sản xuất cho phép điều khiển bảng màu và độ phân giải tối đa 4K khi tạo ảnh thông thường từ văn bản.",
  "source": {
    "audit_sha256": "2e00086bcbfc28e64d0cebe97aa47c17d8d5618963027f8ffb9dc6123d7d25b1",
    "bridge_map_sha256": "1125275768b9636fc8461bc7da5061239a81ddfe508e2557843ca42c58ab0036",
    "raw_model_json_sha256": "75c94766afe4c1345587acd64d6b42126b06ab5786913611990956f6ca5d95f1",
    "renderer_sha256": "64a62299639eb843877e9ec5c95e32bf22bac3acfe230f6f502c5c3aa186f9c1"
  },
  "sourceRevision": "d90afcd65620dd651e780a9de820207a1755779e143a22455f87691167efdd02"
}
