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

# OpenAI: GPT Image 2

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

## [OpenAI: GPT Image 2](https://ailoot.ai/models/en/gpt-image-2/)

GPT Image 2 generates and edits images from text and visual references. It supports flexible frame dimensions and automatically processes image inputs at high fidelity, with separate quality, format and background controls for the finished asset.

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

About the model

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

GPT Image 2 is OpenAI’s model for image generation and editing from text and visual inputs. It creates a new image from a written brief and can use source images for edits or reference-led work. Practical tasks include illustrations, product concepts, visual compositions and changes to an existing asset. It is a separate edition from the GPT Image 2.5 Sunburst and Flare models, with its own quality range and input-fidelity behaviour.

For generation, describe the subject, scene, composition, light and intended style. For an edit, name what should change and what should keep its appearance. A product brief can request a ceramic lamp on a pale surface with a centred silhouette and room for a caption; a follow-up edit can change the background while retaining the lamp’s shape and viewing angle. The documented direct generation and edit workflows accept prompts up to 32,000 characters and can return one to ten images.

Reference editing accepts up to sixteen input images. Specify the purpose of each reference so a subject, background and visual treatment are not confused. GPT Image 2 processes every image input at high fidelity automatically; input\_fidelity should be omitted because it is not adjustable for this edition. This differs from the high-or-low choice on GPT Image 1 and the low-only input-fidelity mode of GPT Image 1 Mini. High-fidelity input processing supports source detail without guaranteeing that every detail is reproduced unchanged.

A mask can identify the region to edit. The source image and mask must have the same format and dimensions and be below 50 MB in the guide’s preparation requirements; the mask also needs an alpha channel. If several input images are provided, masking applies to the first. The model treats the mask as prompt-based guidance rather than a strict geometric boundary. Describe the local change and preservation requirements, then examine the surrounding area for unintended differences.

GPT Image 2 supports low, medium, high and auto quality, with auto as the default. The 2.5 family’s xhigh and max settings are not part of this edition’s quality range. Size can be square, landscape, portrait, automatic or a valid custom width and height. The producer examples include 1024 × 1024, 1536 × 1024, 1024 × 1536, 2048 × 2048, 2048 × 1152, 3840 × 2160 and 2160 × 3840 pixels. Choose the orientation and detail level for the actual layout rather than treating quality and dimensions as the same control.

Custom dimensions must be multiples of sixteen pixels, with a maximum edge of 3840 pixels, a long-to-short-edge ratio no greater than 3:1 and an area from 655,360 to 8,294,400 pixels. These conditions hold simultaneously. Resolutions above 2560 × 1440 are marked experimental. A frame that satisfies one rule can still fail another, so select a supported pair of dimensions and describe the crop-sensitive elements in the brief.

Output is PNG by default, with JPEG or WebP also available. Compression from 0 to 100 is supported for JPEG and WebP. The background can be opaque or automatic; the exact current reference describes transparency for GPT Image 2 as a preview capability. When requesting transparency, use PNG or WebP so an alpha channel can be retained. The documented streaming workflow permits up to three partial images before the finished image; save the final asset rather than a progress preview. The manufacturer interface also supports batch processing.

Evaluate text clarity, the position of objects and preservation of source details in the actual result. GPT Image can struggle with precise lettering, layout-sensitive compositions and recurring visual identity across separate generations. For a sequence of edits, use the chosen result as the next source and give a concrete change tied to a visible issue. GPT Image 2’s useful output is an image connected to a clear generation or edit brief, with its high-fidelity inputs, dimensions and quality chosen for that specific task.

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

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

OpenAI /`gpt-image-2`

### Overview

GPT Image 2 generates and edits images from text and visual references. It supports flexible frame dimensions and automatically processes image inputs at high fidelity, with separate quality, format and background controls for the finished asset.

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 gpt-image-2 | 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

Text input

$0.0025 */ 1K*

Image input

$0.004 */ 1K tokens*

Image output

$0.015 */ 1K tokens*

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": "gpt-image-2", "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': 'gpt-image-2', '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": "gpt-image-2", "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

<strong>Ailoot</strong> [`gpt-image-2`](https://ailoot.ai/models/en/#m=openai%2Fgpt-image-2&route=Core&caller=gpt-image-2&fmt=images)
**Ailoot Ultra** [`gpt-image-2`](https://ailoot.ai/models/en/#m=openai%2Fgpt-image-2&route=Ultra&caller=gpt-image-2&fmt=images), [`openai/gpt-image-2`](https://ailoot.ai/models/en/#m=openai%2Fgpt-image-2&route=Ultra&caller=openai%2Fgpt-image-2&fmt=images)

#### Method path aliases

`/v1/images`

#### Related caller IDs

[`openai/gpt-image-2`](https://ailoot.ai/models/en/#m=openai%2Fgpt-image-2&route=Ultra&caller=openai%2Fgpt-image-2&fmt=images), [`gpt-image-2`](https://ailoot.ai/models/en/#m=openai%2Fgpt-image-2&route=Core&caller=gpt-image-2&fmt=images), [`gpt-image-2`](https://ailoot.ai/models/en/#m=openai%2Fgpt-image-2&route=Ultra&caller=gpt-image-2&fmt=images)

**Ailoot Ultra · Images** `POST /v1/images/generations` `gpt-image-2`

[`gpt-image-2`](https://ailoot.ai/models/en/#m=openai%2Fgpt-image-2&route=Ultra&caller=gpt-image-2&fmt=images)

OpenAI /`gpt-image-2`

Model ID

- `gpt-image-2`
- `openai/gpt-image-2`

### Overview

GPT Image 2 generates and edits images from text and visual references. It supports flexible frame dimensions and automatically processes image inputs at high fidelity, with separate quality, format and background controls for the finished asset.

Accepted inputs

Text

Results

Images

### Available in Ailoot · inputs & methods

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

Input types

`text`

Output types

`image`

| Field | Type | Requirement | Values & limits | Default |
| --- | --- | --- | --- | --- |
| Field`model` | Type`string` | RequirementRequired | Values & limits gpt-image-2 | Default— |
| Field`prompt` | Type`string` | RequirementRequired | Values & limits Maximum length: 32,000 | Default— |
| Field`size` | Type`string` | RequirementOptional | Values & limits Conditions: Use auto or WIDTHxHEIGHT with both dimensions divisible by 16. The longest side is at most 3,840 pixels and total size at most 8,300,000 pixels. | Defaultauto |
| Field`background` | Type`string` | RequirementOptional | Values & limits transparent, opaque, auto | Defaultauto |
| Field`moderation` | Type`string` | RequirementOptional | Values & limits low, auto Conditions: Use auto for standard content moderation. | Default— |
| Field`n` | Type`integer` | RequirementOptional | Values & limits Minimum: 1 Maximum: 10 | Default1 |
| Field`quality` | Type`string` | RequirementOptional | Values & limits auto, high, medium, low | Defaultauto |
| Field`output_compression` | Type`integer` | RequirementOptional | Values & limits Minimum: 0 Maximum: 100 Conditions: Applies to JPEG and WebP output; send the documented integer value. | Default100 |
| Field`output_format` | Type`string` | RequirementOptional | Values & limits webp, png, jpeg | Defaultpng |
| Field`stream` | Type`boolean` | RequirementOptional | Values & limits false Conditions: This route returns one completed JSON response. | Defaultfalse |

Method parameters and lifecycle

| Parameter | Contract |
| --- | --- |
| Parameter`content_type` | Contractapplication/json |
| Parameter`required` | Contractprompt, model |
| Parameter`material_types` | Contracttext |
| Parameter`optional` | Contractsize, background, moderation, n, quality, output\_compression, output\_format, stream |
| Parameter`conditions` | ContractA transparent background requires PNG or WebP., Output compression applies to JPEG or WebP., The selected method generates from text. Editing and streaming controls described for the manufacturer are separate capabilities. |

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}`

### Pricing

##### How the final charge is calculated

The displayed rates estimate the cost before generation. The final charge is calculated from the cost recorded for the original generation. Measured output duration and forecast quantities are not the final billable quantity.

Tariff references do not add request options. Supported parameters are listed for the selected method.

Fast mode

Not specified When fast mode is selected

Flex mode

Not specified When flex mode is selected

Maximum reasoning effort

Not specified When maximum reasoning effort uses the default adjustment

#### Estimated rates for comparison

#### Prices by configuration

Match each charge to the conditions shown. Use one rate for each set of alternative configurations.

| Configuration | Rate schedule | Forecast quantity | Charge |
| --- | --- | --- | --- |
| ConfigurationBase token rates | Rate scheduleBase rate | Forecast quantity— | Charge Input · Input tokens · Estimate for comparison only **—** / 1K tokens Output · Output tokens · Estimate for comparison only **—** / 1K tokens Input · Cache read · Estimate for comparison only **—** / 1K tokens Input · Cache write · Estimate for comparison only **—** / 1K tokens Input · Cache write, 1 hour · Estimate for comparison only **—** / 1K tokens |
| ConfigurationEstimated generation cost | Rate schedule— | Forecast quantityone generation estimate | Charge Output · Estimated generation cost · Estimate for comparison only **$0.24576** estimate before generation This estimate is not an additional charge or a fixed rate for the completed generation. |

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 Ultra · Images

curl

```bash
set -eu
: "${AILOOT_API_KEY:?Set your Ailoot API key}"
export AILOOT_API_KEY
python3 - <<'PY_REQUEST'
import json,os
from pathlib import Path
p={'prompt': 'A cute baby sea otter', 'model': 'gpt-image-2', 'size': '1024x1024', 'n': 1, 'background': 'auto', 'moderation': 'auto', 'output_format': 'png'}

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
```

### Receive and save results

#### Ailoot Ultra · 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}`

Other content reads

Read existing owned assets

```bash
set -eu
: "${AILOOT_API_KEY:?Set your Ailoot API key}"
curl --fail-with-body --silent --show-error https://api.ailoot.ai/v1/media/assets \
  -H "Authorization: Bearer $AILOOT_API_KEY" -o owned-assets.json
# Preserve every returned asset and follow its exact signed content URL. Do not construct a signed token.
```

##### Keep all completed results

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

Retain the complete response and headers, every actual output, original returned identifiers and all usage fields. Recover the original operation without submitting creation again.

##### If the original response needs checking

Keep the returned X-Client-Request-ID for reconciliation. Read only actual returned task\_id/asset\_id values or the owned media library; never build a task URL from the operation ID and never resubmit creation.

Response fields

| Field | Type |
| --- | --- |
| Field`created` | Type |
| Field`data[].url` | Type |
| Field`data[].b64_json` | Type |
| Field`usage` | Type |

### Aliases

#### Model aliases

<strong>Ailoot</strong> [`gpt-image-2`](https://ailoot.ai/models/en/#m=openai%2Fgpt-image-2&route=Core&caller=gpt-image-2&fmt=images)
**Ailoot Ultra** [`gpt-image-2`](https://ailoot.ai/models/en/#m=openai%2Fgpt-image-2&route=Ultra&caller=gpt-image-2&fmt=images), [`openai/gpt-image-2`](https://ailoot.ai/models/en/#m=openai%2Fgpt-image-2&route=Ultra&caller=openai%2Fgpt-image-2&fmt=images)

#### Method path aliases

`/v1/images`

#### Related caller IDs

[`openai/gpt-image-2`](https://ailoot.ai/models/en/#m=openai%2Fgpt-image-2&route=Ultra&caller=openai%2Fgpt-image-2&fmt=images), [`gpt-image-2`](https://ailoot.ai/models/en/#m=openai%2Fgpt-image-2&route=Core&caller=gpt-image-2&fmt=images), [`gpt-image-2`](https://ailoot.ai/models/en/#m=openai%2Fgpt-image-2&route=Ultra&caller=gpt-image-2&fmt=images)

**Ailoot Ultra · Images** `POST /v1/images/generations` `openai/gpt-image-2`

[`openai/gpt-image-2`](https://ailoot.ai/models/en/#m=openai%2Fgpt-image-2&route=Ultra&caller=openai%2Fgpt-image-2&fmt=images)

OpenAI /`openai/gpt-image-2`

Model ID

- `gpt-image-2`
- `openai/gpt-image-2`

### Overview

GPT Image 2 generates and edits images from text and visual references. It supports flexible frame dimensions and automatically processes image inputs at high fidelity, with separate quality, format and background controls for the finished asset.

Accepted inputs

Text · Images

Results

Images

### Available in Ailoot · inputs & methods

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

Input types

`text`, `image`

Output types

`image`

| Field | Type | Requirement | Values & limits | Default |
| --- | --- | --- | --- | --- |
| Field`model` | Type`string` | RequirementRequired | Values & limits openai/gpt-image-2 | Default— |
| Field`prompt` | Type`string` | RequirementRequired | Values & limits Minimum length: 1 | Default— |
| Field`aspect_ratio` | Type`string` | RequirementOptional | Values & limits 1:1, 3:2, 2:3, 4:3, 3:4, 16:9, 9:16, 21:9, auto | Default— |
| Field`quality` | Type`string` | RequirementOptional | Values & limits auto, low, medium, high | Default— |
| Field`background` | Type`string` | RequirementOptional | Values & limits auto, opaque | Default— |
| Field`n` | Type`integer` | RequirementOptional | Values & limits Minimum: 1 Maximum: 10 | Default— |
| Field`input_references` | Type`array` | RequirementOptional | Values & limits Minimum items: 0 Maximum items: 16 | Default— |
| Field`output_compression` | Type`integer` | RequirementOptional | Values & limits Minimum: 0 Maximum: 100 | Default— |
| Field`provider` | Type`object` | RequirementOptional | Values & limits | Default— |

Method parameters and lifecycle

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

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}`

### Pricing

##### How the final charge is calculated

The displayed rates estimate the cost before generation. The final charge is calculated from the cost recorded for the original generation. Measured output duration and forecast quantities are not the final billable quantity.

Tariff references do not add request options. Supported parameters are listed for the selected method.

Fast mode

Not specified When fast mode is selected

Flex mode

Not specified When flex mode is selected

Maximum reasoning effort

Not specified When maximum reasoning effort uses the default adjustment

#### Estimated rates for comparison

#### Prices by configuration

Match each charge to the conditions shown. Use one rate for each set of alternative configurations.

| Configuration | Rate schedule | Forecast quantity | Charge |
| --- | --- | --- | --- |
| ConfigurationBase token rates | Rate scheduleBase rate | Forecast quantity— | Charge Input · Input tokens · Estimate for comparison only **—** / 1K tokens Output · Output tokens · Estimate for comparison only **—** / 1K tokens Input · Cache read · Estimate for comparison only **—** / 1K tokens Input · Cache write · Estimate for comparison only **—** / 1K tokens Input · Cache write, 1 hour · Estimate for comparison only **—** / 1K tokens |
| ConfigurationEstimated generation cost | Rate schedule— | Forecast quantityone generation estimate | Charge Output · Estimated generation cost · Estimate for comparison only **$0.24576** estimate before generation This estimate is not an additional charge or a fixed rate for the completed generation. |

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 Ultra · Images

curl

```bash
set -eu
: "${AILOOT_API_KEY:?Set your Ailoot API key}"
export AILOOT_API_KEY
python3 - <<'PY_REQUEST'
import json,os
from pathlib import Path
p={'model': 'openai/gpt-image-2', 'prompt': 'a red panda astronaut floating in space, studio lighting'}

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
```

### Receive and save results

#### Ailoot Ultra · 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}`

Other content reads

Read existing owned assets

```bash
set -eu
: "${AILOOT_API_KEY:?Set your Ailoot API key}"
curl --fail-with-body --silent --show-error https://api.ailoot.ai/v1/media/assets \
  -H "Authorization: Bearer $AILOOT_API_KEY" -o owned-assets.json
# Preserve every returned asset and follow its exact signed content URL. Do not construct a signed token.
```

##### Keep all completed results

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

Retain the complete response and headers, every actual output, original returned identifiers and all usage fields. Recover the original operation without submitting creation again.

##### If the original response needs checking

Keep the returned X-Client-Request-ID for reconciliation. Read only actual returned task\_id/asset\_id values or the owned media library; never build a task URL from the operation ID and never resubmit creation.

Response fields

| Field | Type |
| --- | --- |
| Field`created` | Type |
| Field`data[].url` | Type |
| Field`data[].b64_json` | Type |
| Field`usage` | Type |

### Aliases

#### Model aliases

<strong>Ailoot</strong> [`gpt-image-2`](https://ailoot.ai/models/en/#m=openai%2Fgpt-image-2&route=Core&caller=gpt-image-2&fmt=images)
**Ailoot Ultra** [`gpt-image-2`](https://ailoot.ai/models/en/#m=openai%2Fgpt-image-2&route=Ultra&caller=gpt-image-2&fmt=images), [`openai/gpt-image-2`](https://ailoot.ai/models/en/#m=openai%2Fgpt-image-2&route=Ultra&caller=openai%2Fgpt-image-2&fmt=images)

#### Method path aliases

`/v1/images`

#### Related caller IDs

[`openai/gpt-image-2`](https://ailoot.ai/models/en/#m=openai%2Fgpt-image-2&route=Ultra&caller=openai%2Fgpt-image-2&fmt=images), [`gpt-image-2`](https://ailoot.ai/models/en/#m=openai%2Fgpt-image-2&route=Core&caller=gpt-image-2&fmt=images), [`gpt-image-2`](https://ailoot.ai/models/en/#m=openai%2Fgpt-image-2&route=Ultra&caller=gpt-image-2&fmt=images)

FAQ · OpenAI: GPT Image 2

What inputs and results are available?

`POST /v1/images/generations` · `gpt-image-2`: `text` → `image` `POST /v1/images/generations` · `gpt-image-2`: `text` → `image` `POST /v1/images/generations` · `openai/gpt-image-2`: `text`, `image` → `image`

Which fields does the request use?

`POST /v1/images/generations` · `gpt-image-2`: `model`, `prompt`, `n`, `response_format`, `stream` `POST /v1/images/generations` · `gpt-image-2`: `model`, `prompt`, `size`, `background`, `moderation`, `n`, `quality`, `output_compression`, `output_format`, `stream` `POST /v1/images/generations` · `openai/gpt-image-2`: `model`, `prompt`, `aspect_ratio`, `quality`, `background`, `n`, `input_references`, `output_compression`, `provider`

What limits apply?

`POST /v1/images/generations` · `gpt-image-2`: `n.minimum`: `1` `POST /v1/images/generations` · `gpt-image-2`: `prompt.maximum_length`: `32000`; `n.minimum`: `1`; `n.maximum`: `10`; `output_compression.minimum`: `0`; `output_compression.maximum`: `100` `POST /v1/images/generations` · `openai/gpt-image-2`: `n.minimum`: `1`; `n.maximum`: `10`; `output_compression.minimum`: `0`; `output_compression.maximum`: `100`

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.
