OpenAI: GPT Image 2
GPT Image 2は、テキストと視覚参照から画像を生成・編集します。柔軟なフレーム寸法に対応し、すべての画像入力を自動で高忠実度処理します。完成素材の品質、形式、背景は個別に制御できます。
- Ailoot · 画像
POST /v1/images/generationsgpt-image-2 - Ailoot Ultra · 画像
POST /v1/images/generationsgpt-image-2 - Ailoot Ultra · 画像
POST /v1/images/generationsopenai/gpt-image-2
モデルについて
この説明はモデルの機能を紹介するものです。Ailootで利用できる入力、出力、オプションは、選択したメソッドごとに以下に記載されています。
GPT Image 2は、テキストと視覚入力から画像を生成・編集するOpenAIのモデルです。文章の制作指示から新しい画像を作り、編集や参照中心の制作には原画像を使えます。イラスト、商品コンセプト、視覚的な構図、既存素材の変更などが実用例です。GPT Image 2.5 SunburstやFlareとは別のエディションで、固有の品質範囲と入力忠実度の動作を持ちます。
生成では、被写体、シーン、構図、光、意図したスタイルを記述します。編集では変えるものと外観を維持するものを指定します。商品制作なら、淡い面に置いた陶器のランプ、中央の輪郭、キャプション用の余白を依頼し、追加編集でランプの形と視点を保ちながら背景を変えられます。記載された直接の生成・編集ワークフローは最大32,000文字のプロンプトを受け付け、1~10枚の画像を返せます。
参照を使う編集は最大16枚の入力画像に対応します。被写体、背景、視覚表現が混同されないよう、各参照の目的を指定します。GPT Image 2はすべての画像入力を自動で高忠実度処理します。このエディションでは調整できないため、input_fidelityは省略します。これはGPT Image 1のhighまたはlowの選択や、GPT Image 1 Miniのlow限定の入力忠実度とは異なります。高忠実度の入力処理は原素材の細部を支えますが、すべての細部が変わらず再現される保証ではありません。
マスクで編集領域を示せます。ガイドの準備要件では、原画像とマスクは同じ形式と寸法で、50 MB未満である必要があります。マスクにはアルファチャンネルも必要です。複数の入力画像がある場合、マスクは最初の画像に適用されます。モデルはマスクを厳密な幾何学的境界ではなく、プロンプトに基づく誘導として扱います。局所的な変更と維持要件を記述し、周囲に意図しない差異がないかを確認します。
GPT Image 2はlow、medium、high、autoの品質に対応し、標準はautoです。2.5ファミリーのxhighとmaxは、このエディションの品質範囲に含まれません。サイズは正方形、横長、縦長、自動、または有効な独自の幅と高さを選べます。開発元の例は1024 × 1024、1536 × 1024、1024 × 1536、2048 × 2048、2048 × 1152、3840 × 2160、2160 × 3840ピクセルです。品質と寸法を同じ制御として扱わず、実際のレイアウトに合う向きと細部の水準を選びます。
独自寸法は16ピクセルの倍数、最大辺3840ピクセル、長辺対短辺の比率3:1以下、面積655,360~8,294,400ピクセルが条件です。これらは同時に適用されます。2560 × 1440を超える解像度は実験的とされています。一つの条件を満たすフレームでも別の条件に違反し得るため、有効な縦横寸法の組み合わせを選び、切り取りで失いたくない要素を制作指示に記述します。
出力の標準はPNGで、JPEGとWebPも利用できます。JPEGとWebPは0~100の圧縮値に対応します。背景は不透明または自動を選べます。現在の個別仕様は、GPT Image 2の透明背景をプレビュー機能として説明しています。透明背景を依頼する場合は、アルファチャンネルを保持できるPNGまたはWebPを使います。記載されたストリーミングは、完成画像の前に最大3枚の部分画像を送れます。進捗プレビューではなく最終素材を保存してください。開発元のインターフェースはバッチ処理にも対応します。
実際の結果で、文字の明瞭さ、物体の位置、原素材の細部の維持を評価します。GPT Imageは、正確な文字、レイアウトに敏感な構図、別々の生成で視覚的特徴を繰り返し保つことが難しい場合があります。編集を続ける場合は採用した結果を次の原画像に使い、目に見える問題に結びつく具体的な変更を指定します。GPT Image 2の有用な出力は、明確な生成・編集指示に結びついた画像です。その作業に合わせて高忠実度入力、寸法、品質を選びます。
Ailoot · 画像 POST /v1/images/generations gpt-image-2
gpt-image-2はじめに
GPT Image 2は、テキストと視覚参照から画像を生成・編集します。柔軟なフレーム寸法に対応し、すべての画像入力を自動で高忠実度処理します。完成素材の品質、形式、背景は個別に制御できます。
- 対応する入力
- テキスト
- 結果
- 画像
Ailootで利用可能 · 入力とメソッド
Ailoot · 画像 POST /v1/images/generations
- 入力の種類
text- 出力の種類
image- 出力形式
- 画像ファイル
| フィールド | 種類 | 要件 | 値と制限 | デフォルト |
|---|---|---|---|---|
フィールドmodel | 種類string | 要件必須 | 値と制限 gpt-image-2 | デフォルト— |
フィールドprompt | 種類string | 要件必須 | 値と制限 最小の長さ: 1 | デフォルト— |
フィールドn | 種類integer | 要件任意 | 値と制限 最小値: 1 | デフォルト1 |
フィールドresponse_format | 種類string | 要件任意 | 値と制限 url, b64_json | デフォルト— |
フィールドstream | 種類boolean | 要件任意 | 値と制限 | デフォルトfalse |
フィールドsize | 種類string | 要件任意 | 値と制限 モデルによる | デフォルト— |
フィールドquality | 種類string | 要件任意 | 値と制限 モデルによる | デフォルト— |
フィールドbackground | 種類string | 要件任意 | 値と制限 モデルによる | デフォルト— |
フィールドoutput_format | 種類string | 要件任意 | 値と制限 モデルによる | デフォルト— |
フィールドoutput_compression | 種類integer | 要件任意 | 値と制限 モデルによる | デフォルト— |
フィールドmoderation | 種類string | 要件任意 | 値と制限 モデルによる | デフォルト— |
フィールドinput_fidelity | 種類string | 要件任意 | 値と制限 モデルによる | デフォルト— |
フィールドstyle | 種類string | 要件任意 | 値と制限 モデルによる | デフォルト— |
フィールドpartial_images | 種類integer | 要件任意 | 値と制限 モデルによる | デフォルト— |
入力素材の組み合わせ
テキストから画像へ · 必須: prompt
メソッドのパラメータとライフサイクル
| パラメータ | 仕様 |
|---|---|
パラメータmaterial_types | 仕様text |
パラメータrequired | 仕様model, prompt |
パラメータoptional_controls | 仕様null |
パラメータcontent_type | 仕様application/json |
ライフサイクル: synchronous_result_then_owned_library
GET /v1/media/tasks/{task_id} · 実際に返された task_id またはメディアライブラリのレコード
GET /v1/media/assets/{asset_id}/content
GET /v1/media/assets
GET /v1/media/assets/{asset_id}
メソッドの形式とIDは正確に記載しています。供給元の対応能力とリクエストの受け入れは別です。
料金
Ailootのメソッド料金
POST /v1/images/generations- テキスト入力
- $0.0025 / 1K
- 入力、画像
- $0.004 / 1K tokens
- 出力、画像
- $0.015 / 1K tokens
Ailootはリクエスト前に見積額を確保します。結果の取得後、実測使用量に基づいて最終料金を精算します。ストリーミング時の精算には最終の使用量記録を使用します。金額の確保と精算の仕組み →
リクエスト例
Ailoot · 画像
set -eu
: "${AILOOT_API_KEY:?Set your Ailoot API key}"
export AILOOT_API_KEY
export AILOOT_API_KEY
: "${AILOOT_PROMPT_FILE:?Set your actual UTF-8 image brief}"
export AILOOT_PROMPT_FILE
python3 - <<'PY_REQUEST'
import json,os
from pathlib import Path
p=json.loads('{"model": "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
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])
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");
結果を受け取って保存
Ailoot · 画像
返された画像をすべてダウンロードするか、Base64の内容を保存
GET /v1/media/tasks/{task_id}GET /v1/media/assets/{asset_id}/contentGET /v1/media/assetsGET /v1/media/assets/{asset_id}
完了した結果をすべて保存
完了した画像をすべて保存してください。返された各URLから取得するか、Base64の内容をデコードしてください。
すべてのデータ項目を保存してください。各 b64_json をデコードするか、返された署名付き URL すべてから取得してください。実際の MIME タイプ/バイト列に応じてファイル名の拡張子を選んでください。
元のレスポンスを確認する場合
画像の生成または編集の結果に確認が必要な場合は、元の operation_id/X-Client-Request-ID と、返された結果情報を保存してください。実際の task_id または asset_id の値を使い、メディアライブラリから自分が所有する既存の結果を取得してください。生成/編集リクエストを再送したり、operation_id からポーリング URL を組み立てたりしないでください。
レスポンスのフィールド
| フィールド | 種類 |
|---|---|
フィールドcreated | 種類integer |
フィールドdata[].url | 種類string |
フィールドdata[].b64_json | 種類base64 string |
フィールドusage | 種類object |
エラーと次の手順
| レスポンス | 条件 | 次の手順 |
|---|---|---|
レスポンス400 · invalid_request_error | 条件必須フィールド、素材の表現形式、またはパラメーター値が不正です | 次の手順新しい生成リクエストを送る前に、指定されたフィールドを修正してください。 |
レスポンスserver_error | 条件返されたレスポンスは、操作または結果の確認が必要であることを示しています | 次の手順最初に返された操作/タスク ID、リクエストヘッダー、レスポンスを保存し、その元の操作に対してサポートされている読み取りを継続してください。作成リクエストを再送しないでください。 |
エイリアス
モデルのエイリアス
Ailoot gpt-image-2
Ailoot Ultra gpt-image-2, openai/gpt-image-2
メソッドパスのエイリアス
/v1/images
関連する呼び出し用ID
Ailoot Ultra · 画像 POST /v1/images/generations gpt-image-2
gpt-image-2gpt-image-2openai/gpt-image-2
はじめに
GPT Image 2は、テキストと視覚参照から画像を生成・編集します。柔軟なフレーム寸法に対応し、すべての画像入力を自動で高忠実度処理します。完成素材の品質、形式、背景は個別に制御できます。
- 対応する入力
- テキスト
- 結果
- 画像
Ailootで利用可能 · 入力とメソッド
Ailoot Ultra · 画像 POST /v1/images/generations
- 入力の種類
text- 出力の種類
image
| フィールド | 種類 | 要件 | 値と制限 | デフォルト |
|---|---|---|---|---|
フィールドmodel | 種類string | 要件必須 | 値と制限 gpt-image-2 | デフォルト— |
フィールドprompt | 種類string | 要件必須 | 値と制限 最大の長さ: 32,000 | デフォルト— |
フィールドsize | 種類string | 要件任意 | 値と制限 条件: autoまたはWIDTHxHEIGHTを使用し、幅と高さの両方を16で割り切れる値にしてください。長辺は最大3,840ピクセル、総画素数は最大8,300,000ピクセルです。 | デフォルトauto |
フィールドbackground | 種類string | 要件任意 | 値と制限 transparent, opaque, auto | デフォルトauto |
フィールドmoderation | 種類string | 要件任意 | 値と制限 low, auto 条件: 標準のコンテンツモデレーションにはautoを使用してください。 | デフォルト— |
フィールドn | 種類integer | 要件任意 | 値と制限 最小値: 1 最大値: 10 | デフォルト1 |
フィールドquality | 種類string | 要件任意 | 値と制限 auto, high, medium, low | デフォルトauto |
フィールドoutput_compression | 種類integer | 要件任意 | 値と制限 最小値: 0 最大値: 100 条件: JPEGとWebPの出力に適用されます。文書に記載された整数値を送信してください。 | デフォルト100 |
フィールドoutput_format | 種類string | 要件任意 | 値と制限 webp, png, jpeg | デフォルトpng |
フィールドstream | 種類boolean | 要件任意 | 値と制限 false 条件: このルートは、完了したJSONレスポンスを一件返します。 | デフォルトfalse |
メソッドのパラメータとライフサイクル
| パラメータ | 仕様 |
|---|---|
パラメータcontent_type | 仕様application/json |
パラメータrequired | 仕様prompt, model |
パラメータmaterial_types | 仕様text |
パラメータoptional | 仕様size, background, moderation, n, quality, output_compression, output_format, stream |
パラメータconditions | 仕様透過背景にはPNGまたはWebPが必要です。, 出力圧縮はJPEGまたはWebPに適用されます。, 選択したメソッドはテキストから生成します。メーカーの説明に記載されている編集およびストリーミングの制御は、別の機能です。 |
ライフサイクル: synchronous_result_then_owned_library
GET /v1/media/tasks/{task_id} · 実際に返された task_id またはメディアライブラリのレコード
GET /v1/media/assets/{asset_id}/content
GET /v1/media/assets
GET /v1/media/assets/{asset_id}
料金
最終料金の計算方法
表示料金は生成前の費用の見積もりです。最終請求額は、元の生成処理に記録された費用から計算されます。実測された出力時間や予測数量が、そのまま最終的な課金数量になるわけではありません。
料金情報はリクエストの機能を追加しません。対応するパラメーターは選択したメソッドに記載されています。
- 高速モード
- 未指定 高速モードが選択されている場合
- Flex モード
- 未指定 flex モードが選択されている場合
- 最大推論量
- 未指定 推論量が最大で、調整に既定値(default)を使用する場合
比較用の推定料金
設定別の価格
各料金を表示された条件と照合してください。選択肢となる設定の各組には、いずれか1つの料金を適用します。
| 設定 | 料金表 | 予測数量 | 料金 |
|---|---|---|---|
| 設定基本トークン料金 | 料金表基本料金 | 予測数量— | 料金 入力 · 入力トークン · 比較専用の見積もり — / 1K トークン 出力 · 出力トークン · 比較専用の見積もり — / 1K トークン 入力 · キャッシュ読み取り · 比較専用の見積もり — / 1K トークン 入力 · キャッシュ書き込み · 比較専用の見積もり — / 1K トークン 入力 · キャッシュ書き込み、1時間 · 比較専用の見積もり — / 1K トークン |
| 設定生成費用の見積もり | 料金表— | 予測数量生成1回分の概算 | 料金 出力 · 推定生成コスト · 比較専用の見積もり $0.24576 生成前の見積もり この見積もりは追加料金ではなく、完了した生成処理に対する固定料金でもありません。 |
Ailootはリクエスト前に見積額を確保します。結果の取得後、実測使用量に基づいて最終料金を精算します。ストリーミング時の精算には最終の使用量記録を使用します。金額の確保と精算の仕組み →
リクエスト例
Ailoot Ultra · 画像
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
結果を受け取って保存
Ailoot Ultra · 画像
返された画像をすべてダウンロードするか、Base64の内容を保存
GET /v1/media/tasks/{task_id}GET /v1/media/assets/{asset_id}/contentGET /v1/media/assetsGET /v1/media/assets/{asset_id}
その他のコンテンツ取得
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.
完了した結果をすべて保存
完了した画像をすべて保存してください。返された各URLから取得するか、Base64の内容をデコードしてください。
レスポンスとヘッダーの全体、実際の出力すべて、最初に返された識別子、使用量フィールドすべてを保存してください。作成リクエストを再送せずに、元の操作を復旧してください。
元のレスポンスを確認する場合
照合のため、返された X-Client-Request-ID を保存してください。実際に返された task_id/asset_id の値、または自分が所有するメディアライブラリだけを使って読み取ってください。操作 ID からタスクの URL を組み立てたり、作成リクエストを再送したりしないでください。
レスポンスのフィールド
| フィールド | 種類 |
|---|---|
フィールドcreated | 種類 |
フィールドdata[].url | 種類 |
フィールドdata[].b64_json | 種類 |
フィールドusage | 種類 |
エイリアス
モデルのエイリアス
Ailoot gpt-image-2
Ailoot Ultra gpt-image-2, openai/gpt-image-2
メソッドパスのエイリアス
/v1/images
関連する呼び出し用ID
Ailoot Ultra · 画像 POST /v1/images/generations openai/gpt-image-2
openai/gpt-image-2gpt-image-2openai/gpt-image-2
はじめに
GPT Image 2は、テキストと視覚参照から画像を生成・編集します。柔軟なフレーム寸法に対応し、すべての画像入力を自動で高忠実度処理します。完成素材の品質、形式、背景は個別に制御できます。
- 対応する入力
- テキスト · 画像
- 結果
- 画像
Ailootで利用可能 · 入力とメソッド
Ailoot Ultra · 画像 POST /v1/images/generations
- 入力の種類
text,image- 出力の種類
image
| フィールド | 種類 | 要件 | 値と制限 | デフォルト |
|---|---|---|---|---|
フィールドmodel | 種類string | 要件必須 | 値と制限 openai/gpt-image-2 | デフォルト— |
フィールドprompt | 種類string | 要件必須 | 値と制限 最小の長さ: 1 | デフォルト— |
フィールドaspect_ratio | 種類string | 要件任意 | 値と制限 1:1, 3:2, 2:3, 4:3, 3:4, 16:9, 9:16, 21:9, auto | デフォルト— |
フィールドquality | 種類string | 要件任意 | 値と制限 auto, low, medium, high | デフォルト— |
フィールドbackground | 種類string | 要件任意 | 値と制限 auto, opaque | デフォルト— |
フィールドn | 種類integer | 要件任意 | 値と制限 最小値: 1 最大値: 10 | デフォルト— |
フィールドinput_references | 種類array | 要件任意 | 値と制限 最小項目数: 0 最大項目数: 16 | デフォルト— |
フィールドoutput_compression | 種類integer | 要件任意 | 値と制限 最小値: 0 最大値: 100 | デフォルト— |
フィールドprovider | 種類object | 要件任意 | 値と制限 | デフォルト— |
メソッドのパラメータとライフサイクル
| パラメータ | 仕様 |
|---|---|
パラメータcontent_type | 仕様application/json |
パラメータrequired | 仕様model, prompt |
パラメータmaterial_types | 仕様text, image |
ライフサイクル: synchronous_result_then_owned_library
GET /v1/media/tasks/{task_id} · 実際に返された task_id またはメディアライブラリのレコード
GET /v1/media/assets/{asset_id}/content
GET /v1/media/assets
GET /v1/media/assets/{asset_id}
料金
最終料金の計算方法
表示料金は生成前の費用の見積もりです。最終請求額は、元の生成処理に記録された費用から計算されます。実測された出力時間や予測数量が、そのまま最終的な課金数量になるわけではありません。
料金情報はリクエストの機能を追加しません。対応するパラメーターは選択したメソッドに記載されています。
- 高速モード
- 未指定 高速モードが選択されている場合
- Flex モード
- 未指定 flex モードが選択されている場合
- 最大推論量
- 未指定 推論量が最大で、調整に既定値(default)を使用する場合
比較用の推定料金
設定別の価格
各料金を表示された条件と照合してください。選択肢となる設定の各組には、いずれか1つの料金を適用します。
| 設定 | 料金表 | 予測数量 | 料金 |
|---|---|---|---|
| 設定基本トークン料金 | 料金表基本料金 | 予測数量— | 料金 入力 · 入力トークン · 比較専用の見積もり — / 1K トークン 出力 · 出力トークン · 比較専用の見積もり — / 1K トークン 入力 · キャッシュ読み取り · 比較専用の見積もり — / 1K トークン 入力 · キャッシュ書き込み · 比較専用の見積もり — / 1K トークン 入力 · キャッシュ書き込み、1時間 · 比較専用の見積もり — / 1K トークン |
| 設定生成費用の見積もり | 料金表— | 予測数量生成1回分の概算 | 料金 出力 · 推定生成コスト · 比較専用の見積もり $0.24576 生成前の見積もり この見積もりは追加料金ではなく、完了した生成処理に対する固定料金でもありません。 |
Ailootはリクエスト前に見積額を確保します。結果の取得後、実測使用量に基づいて最終料金を精算します。ストリーミング時の精算には最終の使用量記録を使用します。金額の確保と精算の仕組み →
リクエスト例
Ailoot Ultra · 画像
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
結果を受け取って保存
Ailoot Ultra · 画像
返された画像をすべてダウンロードするか、Base64の内容を保存
GET /v1/media/tasks/{task_id}GET /v1/media/assets/{asset_id}/contentGET /v1/media/assetsGET /v1/media/assets/{asset_id}
その他のコンテンツ取得
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.
完了した結果をすべて保存
完了した画像をすべて保存してください。返された各URLから取得するか、Base64の内容をデコードしてください。
レスポンスとヘッダーの全体、実際の出力すべて、最初に返された識別子、使用量フィールドすべてを保存してください。作成リクエストを再送せずに、元の操作を復旧してください。
元のレスポンスを確認する場合
照合のため、返された X-Client-Request-ID を保存してください。実際に返された task_id/asset_id の値、または自分が所有するメディアライブラリだけを使って読み取ってください。操作 ID からタスクの URL を組み立てたり、作成リクエストを再送したりしないでください。
レスポンスのフィールド
| フィールド | 種類 |
|---|---|
フィールドcreated | 種類 |
フィールドdata[].url | 種類 |
フィールドdata[].b64_json | 種類 |
フィールドusage | 種類 |
エイリアス
モデルのエイリアス
Ailoot gpt-image-2
Ailoot Ultra gpt-image-2, openai/gpt-image-2
メソッドパスのエイリアス
/v1/images
関連する呼び出し用ID
FAQ · OpenAI: GPT Image 2
- 利用できる入力と結果は何ですか?
POST /v1/images/generations·gpt-image-2:text→imagePOST /v1/images/generations·gpt-image-2:text→imagePOST /v1/images/generations·openai/gpt-image-2:text,image→image- リクエストはどの項目を使用しますか?
POST /v1/images/generations·gpt-image-2:model,prompt,n,response_format,streamPOST /v1/images/generations·gpt-image-2:model,prompt,size,background,moderation,n,quality,output_compression,output_format,streamPOST /v1/images/generations·openai/gpt-image-2:model,prompt,aspect_ratio,quality,background,n,input_references,output_compression,provider- どの制限が適用されますか?
POST /v1/images/generations·gpt-image-2:n.minimum:1POST /v1/images/generations·gpt-image-2:prompt.maximum_length:32000;n.minimum:1;n.maximum:10;output_compression.minimum:0;output_compression.maximum:100POST /v1/images/generations·openai/gpt-image-2:n.minimum:1;n.maximum:10;output_compression.minimum:0;output_compression.maximum:100