curl --request POST \
--url https://api.apimart.ai/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "gpt-image-2.6-ext",
"version": "flare",
"prompt": "An orange cat resting on a sunny windowsill, a city after the rain, warm cinematic lighting",
"size": "16:9",
"resolution": "1k",
"quality": "high",
"n": 1
}'
import time
import requests
base_url = "https://api.apimart.ai"
headers = {"Authorization": "Bearer <token>"}
payload = {
"model": "gpt-image-2.6-ext",
"version": "flare",
"prompt": "An orange cat resting on a sunny windowsill, a city after the rain, warm cinematic lighting",
"size": "16:9",
"resolution": "1k",
"quality": "high",
"n": 1
}
response = requests.post(
f"{base_url}/v1/images/generations",
headers=headers, json=payload, timeout=30,
)
response.raise_for_status()
task_id = response.json()["data"][0]["task_id"]
print(task_id)
deadline = time.monotonic() + 300
while time.monotonic() < deadline:
response = requests.get(
f"{base_url}/v1/tasks/{task_id}", headers=headers, timeout=30,
)
response.raise_for_status()
body = response.json()
task = body.get("data", body)
if task["status"] == "completed":
print(task["result"]["images"][0]["url"])
break
if task["status"] == "failed":
raise RuntimeError(task["error"]["message"])
time.sleep(4)
else:
raise TimeoutError(f"Continue polling task {task_id}")
const baseUrl = "https://api.apimart.ai";
const headers = {
Authorization: "Bearer <token>",
"Content-Type": "application/json",
};
const response = await fetch(`${baseUrl}/v1/images/generations`, {
method: "POST",
headers,
body: JSON.stringify({
"model": "gpt-image-2.6-ext",
"version": "flare",
"prompt": "An orange cat resting on a sunny windowsill, a city after the rain, warm cinematic lighting",
"size": "16:9",
"resolution": "1k",
"quality": "high",
"n": 1
}),
});
if (!response.ok) throw new Error(await response.text());
const taskId = (await response.json()).data[0].task_id;
console.log(taskId);
async function waitForTask(taskId) {
const deadline = Date.now() + 300_000;
while (Date.now() < deadline) {
const response = await fetch(`${baseUrl}/v1/tasks/${taskId}`, { headers });
if (!response.ok) throw new Error(await response.text());
const body = await response.json();
const task = body.data ?? body;
if (task.status === "completed") return task.result.images[0].url;
if (task.status === "failed") throw new Error(task.error.message);
await new Promise(resolve => setTimeout(resolve, 4000));
}
throw new Error(`Continue polling task ${taskId}`);
}
console.log(await waitForTask(taskId));
{
"code": 200,
"data": [
{
"status": "submitted",
"task_id": "task_01EXAMPLE"
}
]
}
{
"error": {
"message": "quality \"ultra\" is not supported (supported: auto / low / medium / high / xhigh / max)",
"type": "invalid_request_error",
"param": "",
"code": "invalid_request_error"
}
}
GPT-Image-2.6 Ext
GPT-Image-2.6 Ext 画像生成
gpt-image-2.6-ext で画像単位の固定料金による生成。version で Flare / Sunburst を選択し、参照画像、SVG、GIF を利用できます。
POST
/
v1
/
images
/
generations
curl --request POST \
--url https://api.apimart.ai/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "gpt-image-2.6-ext",
"version": "flare",
"prompt": "An orange cat resting on a sunny windowsill, a city after the rain, warm cinematic lighting",
"size": "16:9",
"resolution": "1k",
"quality": "high",
"n": 1
}'
import time
import requests
base_url = "https://api.apimart.ai"
headers = {"Authorization": "Bearer <token>"}
payload = {
"model": "gpt-image-2.6-ext",
"version": "flare",
"prompt": "An orange cat resting on a sunny windowsill, a city after the rain, warm cinematic lighting",
"size": "16:9",
"resolution": "1k",
"quality": "high",
"n": 1
}
response = requests.post(
f"{base_url}/v1/images/generations",
headers=headers, json=payload, timeout=30,
)
response.raise_for_status()
task_id = response.json()["data"][0]["task_id"]
print(task_id)
deadline = time.monotonic() + 300
while time.monotonic() < deadline:
response = requests.get(
f"{base_url}/v1/tasks/{task_id}", headers=headers, timeout=30,
)
response.raise_for_status()
body = response.json()
task = body.get("data", body)
if task["status"] == "completed":
print(task["result"]["images"][0]["url"])
break
if task["status"] == "failed":
raise RuntimeError(task["error"]["message"])
time.sleep(4)
else:
raise TimeoutError(f"Continue polling task {task_id}")
const baseUrl = "https://api.apimart.ai";
const headers = {
Authorization: "Bearer <token>",
"Content-Type": "application/json",
};
const response = await fetch(`${baseUrl}/v1/images/generations`, {
method: "POST",
headers,
body: JSON.stringify({
"model": "gpt-image-2.6-ext",
"version": "flare",
"prompt": "An orange cat resting on a sunny windowsill, a city after the rain, warm cinematic lighting",
"size": "16:9",
"resolution": "1k",
"quality": "high",
"n": 1
}),
});
if (!response.ok) throw new Error(await response.text());
const taskId = (await response.json()).data[0].task_id;
console.log(taskId);
async function waitForTask(taskId) {
const deadline = Date.now() + 300_000;
while (Date.now() < deadline) {
const response = await fetch(`${baseUrl}/v1/tasks/${taskId}`, { headers });
if (!response.ok) throw new Error(await response.text());
const body = await response.json();
const task = body.data ?? body;
if (task.status === "completed") return task.result.images[0].url;
if (task.status === "failed") throw new Error(task.error.message);
await new Promise(resolve => setTimeout(resolve, 4000));
}
throw new Error(`Continue polling task ${taskId}`);
}
console.log(await waitForTask(taskId));
{
"code": 200,
"data": [
{
"status": "submitted",
"task_id": "task_01EXAMPLE"
}
]
}
{
"error": {
"message": "quality \"ultra\" is not supported (supported: auto / low / medium / high / xhigh / max)",
"type": "invalid_request_error",
"param": "",
"code": "invalid_request_error"
}
}
モデルは
gpt-image-2.6-ext、version は flare / sunburst。画像単位で課金します。resolution は 1k / 2k / 4k に対応し、現在は n: 1 を使用します。すべての品質レベルと PNG / JPEG / WebP / SVG / GIF に対応しています。curl --request POST \
--url https://api.apimart.ai/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "gpt-image-2.6-ext",
"version": "flare",
"prompt": "An orange cat resting on a sunny windowsill, a city after the rain, warm cinematic lighting",
"size": "16:9",
"resolution": "1k",
"quality": "high",
"n": 1
}'
import time
import requests
base_url = "https://api.apimart.ai"
headers = {"Authorization": "Bearer <token>"}
payload = {
"model": "gpt-image-2.6-ext",
"version": "flare",
"prompt": "An orange cat resting on a sunny windowsill, a city after the rain, warm cinematic lighting",
"size": "16:9",
"resolution": "1k",
"quality": "high",
"n": 1
}
response = requests.post(
f"{base_url}/v1/images/generations",
headers=headers, json=payload, timeout=30,
)
response.raise_for_status()
task_id = response.json()["data"][0]["task_id"]
print(task_id)
deadline = time.monotonic() + 300
while time.monotonic() < deadline:
response = requests.get(
f"{base_url}/v1/tasks/{task_id}", headers=headers, timeout=30,
)
response.raise_for_status()
body = response.json()
task = body.get("data", body)
if task["status"] == "completed":
print(task["result"]["images"][0]["url"])
break
if task["status"] == "failed":
raise RuntimeError(task["error"]["message"])
time.sleep(4)
else:
raise TimeoutError(f"Continue polling task {task_id}")
const baseUrl = "https://api.apimart.ai";
const headers = {
Authorization: "Bearer <token>",
"Content-Type": "application/json",
};
const response = await fetch(`${baseUrl}/v1/images/generations`, {
method: "POST",
headers,
body: JSON.stringify({
"model": "gpt-image-2.6-ext",
"version": "flare",
"prompt": "An orange cat resting on a sunny windowsill, a city after the rain, warm cinematic lighting",
"size": "16:9",
"resolution": "1k",
"quality": "high",
"n": 1
}),
});
if (!response.ok) throw new Error(await response.text());
const taskId = (await response.json()).data[0].task_id;
console.log(taskId);
async function waitForTask(taskId) {
const deadline = Date.now() + 300_000;
while (Date.now() < deadline) {
const response = await fetch(`${baseUrl}/v1/tasks/${taskId}`, { headers });
if (!response.ok) throw new Error(await response.text());
const body = await response.json();
const task = body.data ?? body;
if (task.status === "completed") return task.result.images[0].url;
if (task.status === "failed") throw new Error(task.error.message);
await new Promise(resolve => setTimeout(resolve, 4000));
}
throw new Error(`Continue polling task ${taskId}`);
}
console.log(await waitForTask(taskId));
{
"code": 200,
"data": [
{
"status": "submitted",
"task_id": "task_01EXAMPLE"
}
]
}
{
"error": {
"message": "quality \"ultra\" is not supported (supported: auto / low / medium / high / xhigh / max)",
"type": "invalid_request_error",
"param": "",
"code": "invalid_request_error"
}
}
認証
string
必須
プラットフォームの API キーで Bearer Token 認証を行います。API キー管理で取得してください。送信には
Content-Type: application/json を使用します。バージョン選択
| バージョン | 用途 |
|---|---|
flare | 既定。速度重視で、日常的な生成、バッチ処理、素早い試行向け。 |
sunburst | 構図と編集精度重視。完成素材、画像内の文字、細かな編集向け。 |
リクエストパラメータ
列挙値は大文字・小文字を区別せず、前後の空白は除去されます。例では小文字を使用します。string
必須
固定値
gpt-image-2.6-ext。string
必須
生成・編集の指示。必須で空文字は不可。複数画像では「1 枚目」「2 枚目」と指定し、変更・維持する内容を記述します。
string
デフォルト:"flare"
flare / sunburst。省略時は flare。その他は HTTP 400。バージョン間で価格が異なる場合があります。string
デフォルト:"1k"
1k / 2k / 4k(大文字 1K / 2K / 4K も可)。size の比率と組み合わせて出力ピクセルが決まります(下の「比率と寸法」表を参照)。1 枚あたりの価格は解像度ごとに異なります。hd / 8k などは HTTP 400。string
デフォルト:"auto"
auto または下表の 10 比率のみ。1024x1024 などのピクセル指定は不可。auto のテキスト生成は 1:1、編集は寸法を読み取れる最初の参照画像に最も近い対応比率を選びます。GIF では省略または auto を使用します。string
size の別名。どちらか一方を使用します。両方指定する場合は一致が必要で、不一致は HTTP 400。GIF では省略または auto のみ。integer
デフォルト:"1"
現在は整数
1 を使用してください。string
auto / low / medium / high / xhigh / max。省略時は上流に転送せず自動選択に任せます。auto は low 固定ではありません。画像単価は変わりませんが、高品質ほど通常時間がかかります。その他は HTTP 400。string
デフォルト:"png"
png / jpeg / webp / svg / gif。jpg は jpeg の別名。SVG・GIF はテキスト生成のみ。その他は HTTP 400。SVG 出力は現在未対応です。
string
low / medium / high。省略時は上流が決定します。画面の複雑さを制御し、low は簡潔なアイコンやフラットイラスト、high は豊かな細部向け。単価は変わりません。string[]
最大 16 枚、各 20 MB 以下。PNG / JPEG / WebP / GIF / BMP。公開 HTTP(S) URL または
data:image/png;base64,... などの画像 Data URL に対応。指定すると編集モード。SVG・GIF では参照画像不可。resolution が 2k / 4k の場合、参照画像に GIF / BMP は使用できません。image_url、image、images、input_image、input_images にも対応しますが、image_urls を推奨します。URL はログイン不要で公開アクセスできる必要があります。
比率と寸法
| 比率 | 1k | 2k | 4k |
|---|---|---|---|
1:1 | 1024×1024 | 2048×2048 | 2880×2880 |
3:2 | 1536×1024 | 2048×1360 | 3520×2336 |
2:3 | 1024×1536 | 1360×2048 | 2336×3520 |
4:3 | 1024×768 | 2048×1536 | 3312×2480 |
3:4 | 768×1024 | 1536×2048 | 2480×3312 |
5:4 | 1280×1024 | 2560×2048 | 3216×2576 |
4:5 | 1024×1280 | 2048×2560 | 2576×3216 |
16:9 | 1536×864 | 2048×1152 | 3840×2160 |
9:16 | 864×1536 | 1152×2048 | 2160×3840 |
21:9 | 2016×864 | 2688×1152 | 3840×1648 |
auto のテキスト生成は 1:1(1k 1024×1024、2k 2048×2048、4k 2880×2880)。編集では上表の最も近い比率を選ぶため、元画像と同じピクセル寸法は保証されません。
参照画像の編集例
編集もPOST /v1/images/generations を使用します。例の URL は実際にアクセス可能な画像に置き換えてください。
{
"model": "gpt-image-2.6-ext",
"version": "sunburst",
"prompt": "Place the product from the first image into the scene in the second image. Preserve the logo and packaging text, and match the lighting.",
"image_urls": [
"https://example.com/product.png",
"https://example.com/scene.jpg"
],
"size": "auto",
"quality": "high",
"n": 1
}
SVG 出力
output_format: "svg" を指定。テキスト生成のみ、n=1 が必須です。size は比率指定に対応し、complexity: "low" は簡潔なベクター画像に適しています。
object
{
"model": "gpt-image-2.6-ext",
"prompt": "A minimalist rocket icon in a single line color, flat vector style, no text",
"size": "1:1",
"output_format": "svg",
"complexity": "low",
"svg": {
"model": "gpt-4.1-mini"
},
"n": 1
}
GIF アニメーション
output_format: "gif" を指定。テキスト生成のみ。size / aspect_ratio は省略または auto。比率名やピクセル値は HTTP 400。動きとループを指示してください。
{
"model": "gpt-image-2.6-ext",
"prompt": "A cartoon puppy raises one paw to wave, then returns to the starting pose. White background, fixed camera, seamless loop.",
"output_format": "gif",
"quality": "medium",
"n": 1
}
非対応・無効なパラメータ
| パラメータ | 動作 |
|---|---|
width / height / markup / markup_url | 送信時に HTTP 400。寸法は比率名を使用し、マークアップ編集は非対応です。 |
background / moderation / output_compression / seed / negative_prompt / style | エラーにはなりませんが、効果はありません。 |
response_format | 出力方式は変わりません。結果はファイル URL で、Base64 画像ではありません。 |
送信とタスク結果
送信成功は HTTP 200。data[0].task_id を取得し、タスク照会 APIを 3–5 秒間隔で completed / failed まで呼び出します。クライアントがタイムアウトしても生成を再送せず、既存タスクを照会してください。
curl --request GET \
--url https://api.apimart.ai/v1/tasks/task_01EXAMPLE \
--header 'Authorization: Bearer <token>'
{code, data} 形式なら先に data を取得します。Python / JavaScript 例は両形式を処理します。
{
"id": "task_01EXAMPLE",
"status": "completed",
"progress": 100,
"result": {
"images": [
{
"url": [
"https://upload.apimart.ai/images/example.png"
],
"expires_at": 1793923252
}
]
}
}
result.images[0].url は配列で、最初のリンクは result.images[0].url[0]。expires_at より前に保存してください。推奨有効期間は完了後 24 時間です。cost / credits_cost は最終料金です。
| 状態 | 対応 |
|---|---|
pending / processing | 照会を続けます。 |
completed | ファイルのリンクを取得して保存します。 |
failed | error.message を確認。全額返金され、cost は 0 です。原因を修正して再送してください。 |
POST /v1/tasks/batch、本文は {"task_ids":["task_xxx","task_yyy"]}。
課金
単価はversion × resolution のみで決定します。品質、形式(SVG / GIF を含む)、複雑さ、比率、参照数、svg.model は価格に影響しません。現在は n=1 を使用し、失敗は全額返金されます。最新料金は APIMart 料金ページまたは /api/pricing を参照してください。
エラー処理
| 段階 / 状態 | 原因と対応 |
|---|---|
| HTTP 400 | 無効なパラメータ。タスク作成前に拒否され、課金されません。列挙値、比率、参照制限、SVG / GIF 専用フィールドを確認してください。 |
| HTTP 401 | API キーが未指定または無効。Authorization を確認。 |
| HTTP 403 | model_price_not_configured:この version × resolution の価格が未設定です。サポートに連絡するか別の解像度を使用。 |
| HTTP 429 | リクエスト過多。同時実行数を減らして再試行。 |
status: "failed" | 静止画・GIF の n=2–4、参照画像の取得失敗、安全ポリシーなどによる実行失敗。error.message を確認して修正。料金は全額返金されます。 |