Skip to content
Open CastalyConsole

Image

gpt-image-2 API

Call gpt-image-2 through Modelflare with the exact model ID shown on this page.

Use the exact model ID gpt-image-2. The model field must match this page exactly.

Coloured glass marbles pouring upward out of a laundromat washer into a bright arc.

Sample outputgpt-image-2POST /v1/images/generations

Parameters: size=1536x1024n=1

Prompt: A 24-hour laundromat at three in the morning, a whole wall of front-loaders turning. A young man in a silver metallic bomber jacket has just tipped a jar of coloured glass marbles into the nearest drum. The marbles are pouring upward out of the open door instead of sinking, already arcing across the room in a bright teal and amber bridge that rings against the ceiling lights. Cold cyan tubes overhead, a hard warm amber glow thrown out of the drum itself. Straight-on symmetrical camera, wide, hyper-real detail in the glass, film grain, no text.

Request that produced this sample
{
"model": "gpt-image-2",
"prompt": "A 24-hour laundromat at three in the morning, a whole wall of front-loaders turning. A young man in a silver metallic bomber jacket has just tipped a jar of coloured glass marbles into the nearest drum. The marbles are pouring upward out of the open door instead of sinking, already arcing across the room in a bright teal and amber bridge that rings against the ceiling lights. Cold cyan tubes overhead, a hard warm amber glow thrown out of the drum itself. Straight-on symmetrical camera, wide, hyper-real detail in the glass, film grain, no text.",
"n": 1,
"size": "1536x1024"
}

Use a Modelflare API key with https://modelflare.dev/v1. The gateway entry point is POST /v1/images/generations.

HTTP
Authorization: Bearer YOUR_MODELFLARE_API_KEY
Terminal windowbash
curl https://modelflare.dev/v1/images/generations \
-H "Authorization: Bearer YOUR_MODELFLARE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-2",
"prompt": "A white cat runs through a neon-lit street in the rain",
"size": "1024x1024", "n": 1
}'

OpenAI-compatible image models use prompt, n, size, and quality; use editing only when the official page documents it.

GPT Image uses the OpenAI-compatible Images API. Generation uses JSON; editing and mask-guided editing use multipart. GPT Image 2 returns Base64 image data in data[].b64_json.

Field Required Notes
model Yes gpt-image-2
prompt Yes Generation or editing instruction
size No auto or custom WIDTHxHEIGHT within the documented size rules
quality No low / medium / high / auto; default auto
background No auto / opaque / transparent; transparent backgrounds require PNG or WebP output
output_format No png / jpeg / webp
output_compression No 0–100 for JPEG/WebP, default 100; ignored for PNG
moderation No auto / low; default auto
n No 1–10 outputs; default 1

Custom sizes require both edges to be multiples of 16, a 1:3 to 3:1 aspect ratio, a maximum edge of 3,840 pixels, and 655,360–8,294,400 total pixels. Editing accepts up to 16 source images, each source and mask under 50 MB; do not send DALL·E-only response_format.

GPT Image 2 edits use /v1/images/edits with multipart image/image[]; up to 16 input images are accepted, and the mask must match the first image’s format and dimensions.

Terminal windowbash
curl https://modelflare.dev/v1/images/edits \
-H "Authorization: Bearer YOUR_MODELFLARE_API_KEY" \
-F "model=gpt-image-2" \
-F "image[]=@/path/to/product.png" \
-F "mask=@/path/to/mask.png" \
-F "prompt=保持主体不变,将背景替换为暖色摄影棚渐变" \
-F "size=1536x1024" \
-F "quality=high" \
-F "output_format=png" \
-F "n=1"

Invalid model parameters return a 4xx with a request ID; use the response fields and error message defined by the selected model contract.

This page covers Modelflare model generation and editing calls. Search or map enrichment, voice management, and element-library management are resource APIs outside this public model-call surface and are not required request fields.

This model uses token-based billing. See the model pricing page for the current customer price, reference list price, and complete specification.

Media contract · v1

Contract ID: media.gpt-image-2.v1Adapter: image.openai.edit.v1@v1Fingerprint: 28b44e2700854f28e2c7b40f6117990dbe3673ec06855b4fc90f34a785b761fa

Official source: OpenAI

Contract parameters

Intent fieldControlOptions
sizeselectauto / 1024x1024 / 1536x1024 / 1024x1536
qualityselectauto / low / medium / high
nnumber—

Supported capability

  • allowed_values · size · auto, 1024x1024, 1536x1024, 1024x1536
  • allowed_values · quality · auto, low, medium, high
  • max_assets · reference_asset_ids · 16

Structured request example

text

Intent

{
  "n": 1,
  "prompt": "A red paper kite over a quiet harbour at dusk.",
  "quality": "auto",
  "size": "auto"
}

Provider request

{
  "model": "gpt-image-2",
  "n": 1,
  "prompt": "A red paper kite over a quiet harbour at dusk.",
  "quality": "auto",
  "size": "auto"
}

reference

Intent

{
  "n": 1,
  "prompt": "A red paper kite over a quiet harbour at dusk.",
  "quality": "auto",
  "size": "auto"
}

Provider request

{
  "images": [
    "https://example.com/reference.png"
  ],
  "model": "gpt-image-2",
  "n": 1,
  "prompt": "A red paper kite over a quiet harbour at dusk.",
  "quality": "auto",
  "size": "auto"
}