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.

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.
{ "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"}Authentication and endpoint
Section titled “Authentication and endpoint”Use a Modelflare API key with https://modelflare.dev/v1. The gateway entry point is POST /v1/images/generations.
Authorization: Bearer YOUR_MODELFLARE_API_KEYGenerate an image
Section titled “Generate an image”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 }'Request notes
Section titled “Request notes”OpenAI-compatible image models use prompt, n, size, and quality; use editing only when the official page documents it.
Request parameters
Section titled “Request parameters”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 |
Response and input limits
Section titled “Response and input limits”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.
Edit images
Section titled “Edit images”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.
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"Errors and failed tasks
Section titled “Errors and failed tasks”Invalid model parameters return a 4xx with a request ID; use the response fields and error message defined by the selected model contract.
Supported scope
Section titled “Supported scope”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.
Pricing and billing
Section titled “Pricing and billing”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
Official source: OpenAI
Contract parameters
| Intent field | Control | Options |
|---|---|---|
size | select | auto / 1024x1024 / 1536x1024 / 1024x1536 |
quality | select | auto / low / medium / high |
n | number | — |
Supported capability
allowed_values·size· auto, 1024x1024, 1536x1024, 1024x1536allowed_values·quality· auto, low, medium, highmax_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"
}