Source: https://ailoot.ai/models/en/image-01/
Canonical: https://ailoot.ai/models/en/image-01/
Language: en

# image-01

[Markdown](https://ailoot.ai/models/en/image-01/index.md) · [JSON](https://ailoot.ai/models/en/image-01/facts.json)

## [image-01](https://ailoot.ai/models/en/image-01/)

MiniMax image-01 creates images from detailed text descriptions and supports square, portrait and wide compositions.

- [**Ailoot · Images** `POST /v1/images/generations` `image-01`](https://ailoot.ai/models/en/image-01/#method-0)
- [**Ailoot · Images** `POST /v1/images/generations` `minimax-image`](https://ailoot.ai/models/en/image-01/#method-1)
- [**Ailoot · Images** `POST /v1/images/generations` `minimax-image-latest`](https://ailoot.ai/models/en/image-01/#method-2)
- [**Ailoot · Images** `POST /v1/images/generations` `minimax/image-01`](https://ailoot.ai/models/en/image-01/#method-3)

About the model

This description covers the model’s capabilities. Available in Ailoot inputs, outputs and options are listed for the selected method below.

#### An image from a description

MiniMax image-01 creates a new image from a text description. A character or object, surroundings and image style can be specified. This Ailoot card accepts text and returns an image; the description defines the future scene's content and composition.

#### Working with a character's appearance

The manufacturer's model capabilities also include generation using a visual character reference. One source image with a clearly distinguishable main subject helps transfer its characteristic features into a new scene alongside a text description. The manufacturer recommends a single front-facing portrait; one reference per request is supported.

JPG, JPEG and PNG images under **10 MB** are declared for this source image. The generation method available in this card is text-based; reference capability belongs to image-01 and does not automatically expand the request's input.

#### Proportions and sizes

Eight aspect ratios are provided for image-01: **1:1, 16:9, 4:3, 3:2, 2:3, 3:4, 9:16 and 21:9**. They cover square, landscape, portrait and wide compositions. Their standard sizes are respectively 1024×1024, 1280×720, 1152×864, 1248×832, 832×1248, 864×1152, 720×1280 and 1344×576 pixels.

The manufacturer also allows width and height to be specified together: **512 to 2048 pixels** each, in multiples of 8. When both an aspect ratio and separate dimensions are supplied, the aspect ratio takes precedence.

#### Number of variations and generation parameters

The model's capabilities include **1 to 9 images** per request; one is created by default. The text description is limited to **1500 characters**. Automatic prompt optimization is provided and initially disabled, along with a random seed: the same seed and parameters are used for result repeatability.

A generation result is an image or a set of images. The manufacturer provides for transfer of the data itself and obtaining a file; if some variations are not generated, the number of successful results is counted separately. The listed sizes and settings describe model capabilities; the parameters available to a specific request are determined by the Ailoot card.

**Ailoot · Images** `POST /v1/images/generations` `image-01`

[`image-01`](https://ailoot.ai/models/en/#m=image-01&route=Core&caller=image-01&fmt=images)

MiniMax /`image-01`

Model ID

- `image-01`
- `minimax-image`
- `minimax-image-latest`
- `minimax/image-01`

### Overview

MiniMax image-01 creates images from detailed text descriptions and supports square, portrait and wide compositions.

Accepted inputs

Text

Results

Images

### Available in Ailoot · inputs & methods

**Ailoot · Images** `POST /v1/images/generations`

Input types

`text`

Output types

`image`

Output format

Image file

| Field | Type | Requirement | Values & limits | Default |
| --- | --- | --- | --- | --- |
| Field`model` | Type`string` | RequirementRequired | Values & limits image-01 | Default— |
| Field`prompt` | Type`string` | RequirementRequired | Values & limits Minimum length: 1 | Default— |
| Field`n` | Type`integer` | RequirementOptional | Values & limits Minimum: 1 | Default1 |
| Field`response_format` | Type`string` | RequirementOptional | Values & limits url, b64\_json | Default— |
| Field`stream` | Type`boolean` | RequirementOptional | Values & limits | Defaultfalse |
| Field`size` | Type`string` | RequirementOptional | Values & limits Model-specific | Default— |
| Field`quality` | Type`string` | RequirementOptional | Values & limits Model-specific | Default— |
| Field`background` | Type`string` | RequirementOptional | Values & limits Model-specific | Default— |
| Field`output_format` | Type`string` | RequirementOptional | Values & limits Model-specific | Default— |
| Field`output_compression` | Type`integer` | RequirementOptional | Values & limits Model-specific | Default— |
| Field`moderation` | Type`string` | RequirementOptional | Values & limits Model-specific | Default— |
| Field`input_fidelity` | Type`string` | RequirementOptional | Values & limits Model-specific | Default— |
| Field`style` | Type`string` | RequirementOptional | Values & limits Model-specific | Default— |
| Field`partial_images` | Type`integer` | RequirementOptional | Values & limits Model-specific | Default— |

Input material combinations

**Text to image** · Required: prompt

Method parameters and lifecycle

| Parameter | Contract |
| --- | --- |
| Parameter`material_types` | Contracttext |
| Parameter`required` | Contractmodel, prompt |
| Parameter`optional_controls` | Contractnull |
| Parameter`content_type` | Contractapplication/json |

Lifecycle: `synchronous_result_then_owned_library`

`GET /v1/media/tasks/{task_id}` · actual returned task\_id or media library record

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

`GET /v1/media/assets`

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

Method shapes and IDs are exact; supplier capability is separate from admission.

### Pricing

#### Ailoot method rates

Output

$0.0035 *per 1K image*

Output

$0.0035 *per 2K image*

Ailoot reserves an estimated amount before a request. After the result, it settles the final charge from measured usage. Streaming settlement uses the final usage record. [How reservation and settlement work →](https://ailoot.ai/docs/en/billing/reserve/)

### Example requests

#### Ailoot · Images

curlPython SDKNode.js SDK

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

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

```python
from openai import OpenAI
import base64, json, os, subprocess
from pathlib import Path
from urllib.parse import urlsplit, urljoin

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

f=Path(os.environ["AILOOT_PROMPT_FILE"])
if not f.is_file():raise SystemExit("Set your actual UTF-8 image brief file")
request={'model': 'image-01', 'prompt': ''}
request["prompt"]=f.read_text(encoding="utf-8")
client=OpenAI(base_url="https://api.ailoot.ai/v1",api_key=os.environ["AILOOT_API_KEY"],max_retries=0)
result=client.images.generate(**request)
Path("sdk-result.txt").write_text(str(result),encoding="utf-8")
save_images([{"b64_json":getattr(item,"b64_json",None),"url":getattr(item,"url",None)} for item in result.data])
```

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

### Receive and save results

#### Ailoot · Images

Download each returned image or save its Base64 contents

- `GET /v1/media/tasks/{task_id}`
- `GET /v1/media/assets/{asset_id}/content`
- `GET /v1/media/assets`
- `GET /v1/media/assets/{asset_id}`

##### Keep all completed results

Save every completed image; retrieve each returned URL or decode its Base64 contents.

Save every data item. Decode each b64\_json or fetch every returned signed URL. Select a filename extension from the actual MIME/bytes.

##### If the original response needs checking

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.

Response fields

| Field | Type |
| --- | --- |
| Field`created` | Typeinteger |
| Field`data[].url` | Typestring |
| Field`data[].b64_json` | Typebase64 string |
| Field`usage` | Typeobject |

Errors and next steps

| Response | Condition | Next step |
| --- | --- | --- |
| Response400 · `invalid_request_error` | ConditionInvalid required fields, material representation or parameter value | Next stepCorrect the indicated fields before a new creation request. |
| Response`server_error` | ConditionThe returned response says the operation or result requires a check | Next stepKeep the original returned operation/task ID, request headers and response; continue supported reads of that original operation. Do not resubmit the creation request. |

### Aliases

#### Model aliases

**Ailoot** [`image-01`](https://ailoot.ai/models/en/#m=image-01&route=Core&caller=image-01&fmt=images), [`minimax-image`](https://ailoot.ai/models/en/#m=image-01&route=Core&caller=minimax-image&fmt=images), [`minimax-image-latest`](https://ailoot.ai/models/en/#m=image-01&route=Core&caller=minimax-image-latest&fmt=images), [`minimax/image-01`](https://ailoot.ai/models/en/#m=image-01&route=Core&caller=minimax%2Fimage-01&fmt=images)

#### Method path aliases

Use the method paths shown above.

#### Related caller IDs

[`image-01`](https://ailoot.ai/models/en/#m=image-01&route=Core&caller=image-01&fmt=images), [`minimax-image`](https://ailoot.ai/models/en/#m=image-01&route=Core&caller=minimax-image&fmt=images), [`minimax-image-latest`](https://ailoot.ai/models/en/#m=image-01&route=Core&caller=minimax-image-latest&fmt=images), [`minimax/image-01`](https://ailoot.ai/models/en/#m=image-01&route=Core&caller=minimax%2Fimage-01&fmt=images)

**Ailoot · Images** `POST /v1/images/generations` `minimax-image`

[`minimax-image`](https://ailoot.ai/models/en/#m=image-01&route=Core&caller=minimax-image&fmt=images)

MiniMax /`minimax-image`

Model ID

- `image-01`
- `minimax-image`
- `minimax-image-latest`
- `minimax/image-01`

### Overview

MiniMax image-01 creates images from detailed text descriptions and supports square, portrait and wide compositions.

Accepted inputs

Text

Results

Images

### Available in Ailoot · inputs & methods

**Ailoot · Images** `POST /v1/images/generations`

Input types

`text`

Output types

`image`

Output format

Image file

| Field | Type | Requirement | Values & limits | Default |
| --- | --- | --- | --- | --- |
| Field`model` | Type`string` | RequirementRequired | Values & limits minimax-image | Default— |
| Field`prompt` | Type`string` | RequirementRequired | Values & limits Minimum length: 1 | Default— |
| Field`n` | Type`integer` | RequirementOptional | Values & limits Minimum: 1 | Default1 |
| Field`response_format` | Type`string` | RequirementOptional | Values & limits url, b64\_json | Default— |
| Field`stream` | Type`boolean` | RequirementOptional | Values & limits | Defaultfalse |
| Field`size` | Type`string` | RequirementOptional | Values & limits Model-specific | Default— |
| Field`quality` | Type`string` | RequirementOptional | Values & limits Model-specific | Default— |
| Field`background` | Type`string` | RequirementOptional | Values & limits Model-specific | Default— |
| Field`output_format` | Type`string` | RequirementOptional | Values & limits Model-specific | Default— |
| Field`output_compression` | Type`integer` | RequirementOptional | Values & limits Model-specific | Default— |
| Field`moderation` | Type`string` | RequirementOptional | Values & limits Model-specific | Default— |
| Field`input_fidelity` | Type`string` | RequirementOptional | Values & limits Model-specific | Default— |
| Field`style` | Type`string` | RequirementOptional | Values & limits Model-specific | Default— |
| Field`partial_images` | Type`integer` | RequirementOptional | Values & limits Model-specific | Default— |

Input material combinations

**Text to image** · Required: prompt

Method parameters and lifecycle

| Parameter | Contract |
| --- | --- |
| Parameter`material_types` | Contracttext |
| Parameter`required` | Contractmodel, prompt |
| Parameter`optional_controls` | Contractnull |
| Parameter`content_type` | Contractapplication/json |

Lifecycle: `synchronous_result_then_owned_library`

`GET /v1/media/tasks/{task_id}` · actual returned task\_id or media library record

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

`GET /v1/media/assets`

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

Method shapes and IDs are exact; supplier capability is separate from admission.

### Pricing

#### Ailoot method rates

Output

$0.0035 *per 1K image*

Output

$0.0035 *per 2K image*

Ailoot reserves an estimated amount before a request. After the result, it settles the final charge from measured usage. Streaming settlement uses the final usage record. [How reservation and settlement work →](https://ailoot.ai/docs/en/billing/reserve/)

### Example requests

#### Ailoot · Images

curlPython SDKNode.js SDK

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

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

```python
from openai import OpenAI
import base64, json, os, subprocess
from pathlib import Path
from urllib.parse import urlsplit, urljoin

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

f=Path(os.environ["AILOOT_PROMPT_FILE"])
if not f.is_file():raise SystemExit("Set your actual UTF-8 image brief file")
request={'model': 'minimax-image', 'prompt': ''}
request["prompt"]=f.read_text(encoding="utf-8")
client=OpenAI(base_url="https://api.ailoot.ai/v1",api_key=os.environ["AILOOT_API_KEY"],max_retries=0)
result=client.images.generate(**request)
Path("sdk-result.txt").write_text(str(result),encoding="utf-8")
save_images([{"b64_json":getattr(item,"b64_json",None),"url":getattr(item,"url",None)} for item in result.data])
```

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

### Receive and save results

#### Ailoot · Images

Download each returned image or save its Base64 contents

- `GET /v1/media/tasks/{task_id}`
- `GET /v1/media/assets/{asset_id}/content`
- `GET /v1/media/assets`
- `GET /v1/media/assets/{asset_id}`

##### Keep all completed results

Save every completed image; retrieve each returned URL or decode its Base64 contents.

Save every data item. Decode each b64\_json or fetch every returned signed URL. Select a filename extension from the actual MIME/bytes.

##### If the original response needs checking

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.

Response fields

| Field | Type |
| --- | --- |
| Field`created` | Typeinteger |
| Field`data[].url` | Typestring |
| Field`data[].b64_json` | Typebase64 string |
| Field`usage` | Typeobject |

Errors and next steps

| Response | Condition | Next step |
| --- | --- | --- |
| Response400 · `invalid_request_error` | ConditionInvalid required fields, material representation or parameter value | Next stepCorrect the indicated fields before a new creation request. |
| Response`server_error` | ConditionThe returned response says the operation or result requires a check | Next stepKeep the original returned operation/task ID, request headers and response; continue supported reads of that original operation. Do not resubmit the creation request. |

### Aliases

#### Model aliases

**Ailoot** [`image-01`](https://ailoot.ai/models/en/#m=image-01&route=Core&caller=image-01&fmt=images), [`minimax-image`](https://ailoot.ai/models/en/#m=image-01&route=Core&caller=minimax-image&fmt=images), [`minimax-image-latest`](https://ailoot.ai/models/en/#m=image-01&route=Core&caller=minimax-image-latest&fmt=images), [`minimax/image-01`](https://ailoot.ai/models/en/#m=image-01&route=Core&caller=minimax%2Fimage-01&fmt=images)

#### Method path aliases

Use the method paths shown above.

#### Related caller IDs

[`image-01`](https://ailoot.ai/models/en/#m=image-01&route=Core&caller=image-01&fmt=images), [`minimax-image`](https://ailoot.ai/models/en/#m=image-01&route=Core&caller=minimax-image&fmt=images), [`minimax-image-latest`](https://ailoot.ai/models/en/#m=image-01&route=Core&caller=minimax-image-latest&fmt=images), [`minimax/image-01`](https://ailoot.ai/models/en/#m=image-01&route=Core&caller=minimax%2Fimage-01&fmt=images)

**Ailoot · Images** `POST /v1/images/generations` `minimax-image-latest`

[`minimax-image-latest`](https://ailoot.ai/models/en/#m=image-01&route=Core&caller=minimax-image-latest&fmt=images)

MiniMax /`minimax-image-latest`

Model ID

- `image-01`
- `minimax-image`
- `minimax-image-latest`
- `minimax/image-01`

### Overview

MiniMax image-01 creates images from detailed text descriptions and supports square, portrait and wide compositions.

Accepted inputs

Text

Results

Images

### Available in Ailoot · inputs & methods

**Ailoot · Images** `POST /v1/images/generations`

Input types

`text`

Output types

`image`

Output format

Image file

| Field | Type | Requirement | Values & limits | Default |
| --- | --- | --- | --- | --- |
| Field`model` | Type`string` | RequirementRequired | Values & limits minimax-image-latest | Default— |
| Field`prompt` | Type`string` | RequirementRequired | Values & limits Minimum length: 1 | Default— |
| Field`n` | Type`integer` | RequirementOptional | Values & limits Minimum: 1 | Default1 |
| Field`response_format` | Type`string` | RequirementOptional | Values & limits url, b64\_json | Default— |
| Field`stream` | Type`boolean` | RequirementOptional | Values & limits | Defaultfalse |
| Field`size` | Type`string` | RequirementOptional | Values & limits Model-specific | Default— |
| Field`quality` | Type`string` | RequirementOptional | Values & limits Model-specific | Default— |
| Field`background` | Type`string` | RequirementOptional | Values & limits Model-specific | Default— |
| Field`output_format` | Type`string` | RequirementOptional | Values & limits Model-specific | Default— |
| Field`output_compression` | Type`integer` | RequirementOptional | Values & limits Model-specific | Default— |
| Field`moderation` | Type`string` | RequirementOptional | Values & limits Model-specific | Default— |
| Field`input_fidelity` | Type`string` | RequirementOptional | Values & limits Model-specific | Default— |
| Field`style` | Type`string` | RequirementOptional | Values & limits Model-specific | Default— |
| Field`partial_images` | Type`integer` | RequirementOptional | Values & limits Model-specific | Default— |

Input material combinations

**Text to image** · Required: prompt

Method parameters and lifecycle

| Parameter | Contract |
| --- | --- |
| Parameter`material_types` | Contracttext |
| Parameter`required` | Contractmodel, prompt |
| Parameter`optional_controls` | Contractnull |
| Parameter`content_type` | Contractapplication/json |

Lifecycle: `synchronous_result_then_owned_library`

`GET /v1/media/tasks/{task_id}` · actual returned task\_id or media library record

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

`GET /v1/media/assets`

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

Method shapes and IDs are exact; supplier capability is separate from admission.

### Pricing

#### Ailoot method rates

Output

$0.0035 *per 1K image*

Output

$0.0035 *per 2K image*

Ailoot reserves an estimated amount before a request. After the result, it settles the final charge from measured usage. Streaming settlement uses the final usage record. [How reservation and settlement work →](https://ailoot.ai/docs/en/billing/reserve/)

### Example requests

#### Ailoot · Images

curlPython SDKNode.js SDK

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

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

```python
from openai import OpenAI
import base64, json, os, subprocess
from pathlib import Path
from urllib.parse import urlsplit, urljoin

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

f=Path(os.environ["AILOOT_PROMPT_FILE"])
if not f.is_file():raise SystemExit("Set your actual UTF-8 image brief file")
request={'model': 'minimax-image-latest', 'prompt': ''}
request["prompt"]=f.read_text(encoding="utf-8")
client=OpenAI(base_url="https://api.ailoot.ai/v1",api_key=os.environ["AILOOT_API_KEY"],max_retries=0)
result=client.images.generate(**request)
Path("sdk-result.txt").write_text(str(result),encoding="utf-8")
save_images([{"b64_json":getattr(item,"b64_json",None),"url":getattr(item,"url",None)} for item in result.data])
```

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

### Receive and save results

#### Ailoot · Images

Download each returned image or save its Base64 contents

- `GET /v1/media/tasks/{task_id}`
- `GET /v1/media/assets/{asset_id}/content`
- `GET /v1/media/assets`
- `GET /v1/media/assets/{asset_id}`

##### Keep all completed results

Save every completed image; retrieve each returned URL or decode its Base64 contents.

Save every data item. Decode each b64\_json or fetch every returned signed URL. Select a filename extension from the actual MIME/bytes.

##### If the original response needs checking

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.

Response fields

| Field | Type |
| --- | --- |
| Field`created` | Typeinteger |
| Field`data[].url` | Typestring |
| Field`data[].b64_json` | Typebase64 string |
| Field`usage` | Typeobject |

Errors and next steps

| Response | Condition | Next step |
| --- | --- | --- |
| Response400 · `invalid_request_error` | ConditionInvalid required fields, material representation or parameter value | Next stepCorrect the indicated fields before a new creation request. |
| Response`server_error` | ConditionThe returned response says the operation or result requires a check | Next stepKeep the original returned operation/task ID, request headers and response; continue supported reads of that original operation. Do not resubmit the creation request. |

### Aliases

#### Model aliases

**Ailoot** [`image-01`](https://ailoot.ai/models/en/#m=image-01&route=Core&caller=image-01&fmt=images), [`minimax-image`](https://ailoot.ai/models/en/#m=image-01&route=Core&caller=minimax-image&fmt=images), [`minimax-image-latest`](https://ailoot.ai/models/en/#m=image-01&route=Core&caller=minimax-image-latest&fmt=images), [`minimax/image-01`](https://ailoot.ai/models/en/#m=image-01&route=Core&caller=minimax%2Fimage-01&fmt=images)

#### Method path aliases

Use the method paths shown above.

#### Related caller IDs

[`image-01`](https://ailoot.ai/models/en/#m=image-01&route=Core&caller=image-01&fmt=images), [`minimax-image`](https://ailoot.ai/models/en/#m=image-01&route=Core&caller=minimax-image&fmt=images), [`minimax-image-latest`](https://ailoot.ai/models/en/#m=image-01&route=Core&caller=minimax-image-latest&fmt=images), [`minimax/image-01`](https://ailoot.ai/models/en/#m=image-01&route=Core&caller=minimax%2Fimage-01&fmt=images)

**Ailoot · Images** `POST /v1/images/generations` `minimax/image-01`

[`minimax/image-01`](https://ailoot.ai/models/en/#m=image-01&route=Core&caller=minimax%2Fimage-01&fmt=images)

MiniMax /`minimax/image-01`

Model ID

- `image-01`
- `minimax-image`
- `minimax-image-latest`
- `minimax/image-01`

### Overview

MiniMax image-01 creates images from detailed text descriptions and supports square, portrait and wide compositions.

Accepted inputs

Text

Results

Images

### Available in Ailoot · inputs & methods

**Ailoot · Images** `POST /v1/images/generations`

Input types

`text`

Output types

`image`

Output format

Image file

| Field | Type | Requirement | Values & limits | Default |
| --- | --- | --- | --- | --- |
| Field`model` | Type`string` | RequirementRequired | Values & limits minimax/image-01 | Default— |
| Field`prompt` | Type`string` | RequirementRequired | Values & limits Minimum length: 1 | Default— |
| Field`n` | Type`integer` | RequirementOptional | Values & limits Minimum: 1 | Default1 |
| Field`response_format` | Type`string` | RequirementOptional | Values & limits url, b64\_json | Default— |
| Field`stream` | Type`boolean` | RequirementOptional | Values & limits | Defaultfalse |
| Field`size` | Type`string` | RequirementOptional | Values & limits Model-specific | Default— |
| Field`quality` | Type`string` | RequirementOptional | Values & limits Model-specific | Default— |
| Field`background` | Type`string` | RequirementOptional | Values & limits Model-specific | Default— |
| Field`output_format` | Type`string` | RequirementOptional | Values & limits Model-specific | Default— |
| Field`output_compression` | Type`integer` | RequirementOptional | Values & limits Model-specific | Default— |
| Field`moderation` | Type`string` | RequirementOptional | Values & limits Model-specific | Default— |
| Field`input_fidelity` | Type`string` | RequirementOptional | Values & limits Model-specific | Default— |
| Field`style` | Type`string` | RequirementOptional | Values & limits Model-specific | Default— |
| Field`partial_images` | Type`integer` | RequirementOptional | Values & limits Model-specific | Default— |

Input material combinations

**Text to image** · Required: prompt

Method parameters and lifecycle

| Parameter | Contract |
| --- | --- |
| Parameter`material_types` | Contracttext |
| Parameter`required` | Contractmodel, prompt |
| Parameter`optional_controls` | Contractnull |
| Parameter`content_type` | Contractapplication/json |

Lifecycle: `synchronous_result_then_owned_library`

`GET /v1/media/tasks/{task_id}` · actual returned task\_id or media library record

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

`GET /v1/media/assets`

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

Method shapes and IDs are exact; supplier capability is separate from admission.

### Pricing

#### Ailoot method rates

Output

$0.0035 *per 1K image*

Output

$0.0035 *per 2K image*

Ailoot reserves an estimated amount before a request. After the result, it settles the final charge from measured usage. Streaming settlement uses the final usage record. [How reservation and settlement work →](https://ailoot.ai/docs/en/billing/reserve/)

### Example requests

#### Ailoot · Images

curlPython SDKNode.js SDK

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

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

```python
from openai import OpenAI
import base64, json, os, subprocess
from pathlib import Path
from urllib.parse import urlsplit, urljoin

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

f=Path(os.environ["AILOOT_PROMPT_FILE"])
if not f.is_file():raise SystemExit("Set your actual UTF-8 image brief file")
request={'model': 'minimax/image-01', 'prompt': ''}
request["prompt"]=f.read_text(encoding="utf-8")
client=OpenAI(base_url="https://api.ailoot.ai/v1",api_key=os.environ["AILOOT_API_KEY"],max_retries=0)
result=client.images.generate(**request)
Path("sdk-result.txt").write_text(str(result),encoding="utf-8")
save_images([{"b64_json":getattr(item,"b64_json",None),"url":getattr(item,"url",None)} for item in result.data])
```

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

### Receive and save results

#### Ailoot · Images

Download each returned image or save its Base64 contents

- `GET /v1/media/tasks/{task_id}`
- `GET /v1/media/assets/{asset_id}/content`
- `GET /v1/media/assets`
- `GET /v1/media/assets/{asset_id}`

##### Keep all completed results

Save every completed image; retrieve each returned URL or decode its Base64 contents.

Save every data item. Decode each b64\_json or fetch every returned signed URL. Select a filename extension from the actual MIME/bytes.

##### If the original response needs checking

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.

Response fields

| Field | Type |
| --- | --- |
| Field`created` | Typeinteger |
| Field`data[].url` | Typestring |
| Field`data[].b64_json` | Typebase64 string |
| Field`usage` | Typeobject |

Errors and next steps

| Response | Condition | Next step |
| --- | --- | --- |
| Response400 · `invalid_request_error` | ConditionInvalid required fields, material representation or parameter value | Next stepCorrect the indicated fields before a new creation request. |
| Response`server_error` | ConditionThe returned response says the operation or result requires a check | Next stepKeep the original returned operation/task ID, request headers and response; continue supported reads of that original operation. Do not resubmit the creation request. |

### Aliases

#### Model aliases

**Ailoot** [`image-01`](https://ailoot.ai/models/en/#m=image-01&route=Core&caller=image-01&fmt=images), [`minimax-image`](https://ailoot.ai/models/en/#m=image-01&route=Core&caller=minimax-image&fmt=images), [`minimax-image-latest`](https://ailoot.ai/models/en/#m=image-01&route=Core&caller=minimax-image-latest&fmt=images), [`minimax/image-01`](https://ailoot.ai/models/en/#m=image-01&route=Core&caller=minimax%2Fimage-01&fmt=images)

#### Method path aliases

Use the method paths shown above.

#### Related caller IDs

[`image-01`](https://ailoot.ai/models/en/#m=image-01&route=Core&caller=image-01&fmt=images), [`minimax-image`](https://ailoot.ai/models/en/#m=image-01&route=Core&caller=minimax-image&fmt=images), [`minimax-image-latest`](https://ailoot.ai/models/en/#m=image-01&route=Core&caller=minimax-image-latest&fmt=images), [`minimax/image-01`](https://ailoot.ai/models/en/#m=image-01&route=Core&caller=minimax%2Fimage-01&fmt=images)

FAQ · image-01

What inputs and results are available?

`POST /v1/images/generations` · `image-01`: `text` → `image` `POST /v1/images/generations` · `minimax-image`: `text` → `image` `POST /v1/images/generations` · `minimax-image-latest`: `text` → `image` `POST /v1/images/generations` · `minimax/image-01`: `text` → `image`

Which fields does the request use?

`POST /v1/images/generations` · `image-01`: `model`, `prompt`, `n`, `response_format`, `stream` `POST /v1/images/generations` · `minimax-image`: `model`, `prompt`, `n`, `response_format`, `stream` `POST /v1/images/generations` · `minimax-image-latest`: `model`, `prompt`, `n`, `response_format`, `stream` `POST /v1/images/generations` · `minimax/image-01`: `model`, `prompt`, `n`, `response_format`, `stream`

What limits apply?

`POST /v1/images/generations` · `image-01`: `n.minimum`: `1` `POST /v1/images/generations` · `minimax-image`: `n.minimum`: `1` `POST /v1/images/generations` · `minimax-image-latest`: `n.minimum`: `1` `POST /v1/images/generations` · `minimax/image-01`: `n.minimum`: `1`

Connect Ailoot to Claude Code, OpenCode, Hermes or your own app.

## The company and its project portfolio

The company and its project portfolio: millions of customers; monthly sales in the billions.

## Buy tokens at a discount.

Subscription discounts for regular use. Promo codes offer up to 50% off token purchases.

Subscription

Choose a discounted plan for your regular requests.

Promo code: up to 50% off

Enter your code at checkout. The price updates to reflect the current promotion.

Spending in your history

The model, tokens and amount are recorded for each request.

[Choose a subscription](https://ailoot.ai/docs/en/billing/subscriptions/) · [View model prices](https://ailoot.ai/models/en/)

## Connect the API to a product you sell.

Use Ailoot in SaaS, apps and bots under its official service offer and licence agreement. Request a reseller licence for resale.

Commercial application

Add text, image, video and audio generation to paid features in your service.

Reseller licence

Send a description of your project and how you provide access. Request written terms for use and resale.

Documents on the website

The service offer, licence agreement and data processing policy are available before you connect.

[Request a reseller licence](mailto:support@ailoot.ai) · [Service offer and licence agreement](https://ailoot.ai/legal/offer?lang=en)

## Ailoot · The company and its project portfolio





Ailoot combines established operating experience, a large client base, stable service and ongoing KPI control.





The company and its project portfolio: millions of customers; monthly sales in the billions.





Ailoot brings that operating experience to API access for AI features in customer products, agents, applications and automations.
