apimaxDocs
DocsPricingConsole
API ReferenceIntegration GuideUser GuideChangelog

Music Series

Image Series

POSTNative OpenAI image format (synchronous)

Video series

Task Management

Error Code ReferenceQuery Task StatusGET

Account Management

Query Quota UsageGET

Docs / Image Series / GPT Image / Sync

SyncPOSTgpt-image-2gpt-image-2.5-flaregpt-image-2.5-sunburstgpt-image-2.6-flare

Native OpenAI image format (synchronous)

Synchronous OpenAI image endpoints: text-to-image uses POST /v1/images/generations (JSON); image-to-image and image editing use POST /v1/images/edits (multipart/form-data). Supports the quality parameter; the 2.6 series supports animated GIF output with configurable frame count and per-frame duration.

POSThttps://api.apimax.ai/v1/images/generations
Try it

Real-time success rate (--:--:--)

Bearer API KeyJSONServer-side call

The GPT Image 2 (gpt-image-2) image editing API is compatible with the OpenAI Images Edits format. It edits or extends the original image via multipart/form-data file uploads. This API is synchronous: the response carries the generated result directly, so no task polling is needed.

- Compared with image generation: image editing is a synchronous API that passes images as file uploads, while image generation is an async API that passes images as image URLs. - The generated image is returned directly as base64 (b64_json) or a temporary URL; save it promptly.

Text-to-image / image-to-image endpoint selection#

ScenarioEndpointRequest formatDescription
Text-to-imagePOST /v1/images/generationsapplication/jsonSubmit a text prompt only and generate images directly
Image-to-image / image editingPOST /v1/images/editsmultipart/form-dataUpload one or more reference images, combined with a prompt for editing
Use `/v1/images/generations` to generate images from text only; use `/v1/images/edits` when you need to upload reference images.

/v1/images/generations: synchronous image generation#

The synchronous text-to-image endpoint follows the OpenAI Images API format: submit JSON and the generated result is returned directly. Image editing still uses the /v1/images/edits multipart endpoint below.

POST /v1/images/generations

Request parameters#

ParameterTypeRequiredDefaultDescription
modelstringYesgpt-image-2Model name; supports gpt-image-2, gpt-image-2.5-flare, gpt-image-2.5-sunburst, gpt-image-2.6-flare, gpt-image-2.6-sunburst, gpt-image-web
promptstringYes—Describes the image to generate
nintegerNo1Number of images to generate; actual returned count follows data, billed by successfully generated images
sizestringNoautoImage size, e.g. 1024x1024, 1536x1024, 1024x1536, or auto; custom sizes are also supported (see the size constraints below)
qualitystringNoautolow, medium, high; xhigh and max are supported only by the 2.5 series (gpt-image-2.5-flare, gpt-image-2.5-sunburst) and the 2.6 series (gpt-image-2.6-flare, gpt-image-2.6-sunburst)
output_formatstringNopngOutput image format: png, jpeg, webp, gif; gif is supported only by the 2.6 series models
frame_countintegerNo9Total number of GIF frames, 2–16; only valid with output_format=gif, see Animated GIF output below
frame_duration_msintegerNo200Playback duration of each GIF frame in milliseconds, 20–2000, rounded to the nearest 10 ms; only valid with output_format=gif
response_formatstringNob64_jsonResponse format compatibility parameter: b64_json (default) or url; see the response_format section below

output_format (image format, with GIF)#

output_format selects the output image format: png (default), jpeg, webp, and gif. gif is supported only by the two 2.6 models gpt-image-2.6-flare and gpt-image-2.6-sunburst, producing animated GIFs for stickers, looping animations, and similar use cases. See Animated GIF output below for details.

Animated GIF output#

When generating animated GIFs, both /v1/images/generations and /v1/images/edits accept the following fields:

FieldValuesDefaultDescription
frame_count2–16 frames9Total number of frames in the animation
frame_duration_ms20–2000, rounded to the nearest 10 ms200Playback duration of each frame, in milliseconds
sizeauto or WIDTHxHEIGHTautoPer-frame canvas size (see below)

`size` means the per-frame size, but total pixels accumulate over frames: for GIF output, size describes the width and height of each finished frame — the dimensions the animation plays back at — and all frames share the same canvas. However, the total pixel budget is calculated as frame count × per-frame pixels (× `n`), with the same cap as still images (8,294,400 pixels). For example, frame_count=9 + size=1024x1024 totals 9 × 1,048,576 ≈ 9.4MP, which exceeds the budget and returns a 400 error; with 9 frames the largest per-frame size is 960x960 (9 × 921,600 = 8,294,400 exactly). Prefer smaller frame sizes for GIF output, such as 512x512 (GIF frames are not subject to the 0.65MP minimum area that applies to still images). If the request exceeds the limits, reduce frame_count, shrink the frame dimensions, or lower n — or use size=auto to let the API choose a frame size within the model's limits.

In the prompt, describe the subject, the motion, and how the animation should loop (for example, "the motion loops and returns to the starting pose") to get a natural loop. The defaults (frame_count=9, frame_duration_ms=200) correspond to a loop of roughly 1.8 seconds.

GIF output limitations: streaming (stream), partial images (partial_images), and output_compression are not supported. frame_count and frame_duration_ms are only valid with output_format=gif; sending them with another output format returns a 400 error.

bash
curl --request POST \
  --url https://api.apimax.ai/v1/images/generations \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "gpt-image-2.6-sunburst",
    "prompt": "A cat waving hello, with the motion looping back to the starting pose",
    "size": "512x512",
    "output_format": "gif",
    "frame_count": 9,
    "frame_duration_ms": 200
  }'

Request example#

bash
curl --request POST \
  --url https://api.apimax.ai/v1/images/generations \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "gpt-image-2",
    "prompt": "A minimalist white cat icon",
    "size": "1024x1024",
    "quality": "medium"
  }'

response_format (compatibility parameter)#

GPT Image natively returns base64 image data only. For compatibility with the DALL·E ecosystem, the platform additionally supports the response_format parameter on both /v1/images/generations and /v1/images/edits:

ValueBehavior
b64_jsonDefault. Returns the image data as base64 in data[].b64_json
urlThe platform uploads the generated image to hosted storage and returns data[].url; b64_json is no longer included
  • When omitted or empty, the parameter is treated as b64_json; any other value (e.g. binary) returns a 400 error
  • The url points to a platform-hosted image address; download and save it promptly before the link expires

Authentication#

All endpoints require Bearer token authentication. Create your key on the API Key management page and add it to the request header:

text
Authorization: Bearer YOUR_API_KEY

/v1/images/edits: image-to-image and editing#

POST /v1/images/edits

The request body is multipart/form-data (not JSON). Core fields: upload one or more source images as image, together with a prompt describing how to edit them.

ModeDescription
Whole-image editing / style rewriteSend only image + prompt; the model edits the image as a whole based on the original
Multi-image compositionSend multiple image[] files; the model blends multiple reference images

Request parameters (form fields)#

FieldTypeRequiredDefaultDescription
modelstringYes—Model name; supports gpt-image-2, gpt-image-2.5-flare, gpt-image-2.5-sunburst, gpt-image-2.6-flare, gpt-image-2.6-sunburst, gpt-image-web
imagefileYes—Source image file to edit. For multiple images, repeat the image[] field
promptstringYes—Describes the desired edit
nintegerNo1Number of images to generate; actual returned count follows data, billed by successfully generated images
sizestringNoautoOutput size, e.g. 1024x1024, 1536x1024, auto
qualitystringNoautoRender quality: low/medium/high/auto; xhigh and max are supported only by the 2.5 and 2.6 series models
output_formatstringNopngOutput image format: png, jpeg, webp, gif; gif is supported only by the 2.6 series models
frame_countintegerNo9Total number of GIF frames, 2–16; only valid with output_format=gif
frame_duration_msintegerNo200Playback duration of each GIF frame in milliseconds, 20–2000, rounded to the nearest 10 ms; only valid with output_format=gif
response_formatstringNob64_jsonResponse format compatibility parameter: b64_json (default) or url; behaves the same as on /v1/images/generations

image (source image)#

  • Supported formats: .png, .jpg, .jpeg, .webp
  • Use the image field for single-image editing; for multi-image composition, upload multiple files by repeating the image[] field
  • Files are uploaded as multipart binary data, not as URLs

size#

ValueDescription
autoDecided by the model (default)
1024x1024Square
1536x1024Landscape
1024x1536Portrait

Common aspect ratios and high-resolution examples (all sizes below satisfy the official constraints and can be used directly):

RatioLandscapePortraitTypical use cases
1:11024x1024, 2048x2048same as landscapeAvatars, icons, e-commerce hero images
4:3 / 3:41024x768, 2048x1536768x1024, 1536x2048Article covers, illustrations
3:2 / 2:31536x1024, 3072x20481024x1536, 2048x3072Photographic-style visuals, posters
16:9 / 9:161280x720, 2048x1152, 3840x2160720x1280, 1152x2048, 2160x3840Banners, desktop wallpapers, video covers, full-screen mobile assets
21:9 / 9:212688x1152, 3360x14401152x2688, 1440x3360Ultrawide banners and wallpapers
2:1 / 1:22048x10241024x2048Long-form graphics, infographics
3:1 / 1:33072x10241024x3072, 1280x3840Extreme panoramic or tall images (aspect-ratio cap)
  • 3840x2160 / 2160x3840 (4K) hits the total-pixel cap of 8,294,400 exactly and is the largest available 16:9 size
  • Higher resolutions consume more output tokens, take longer to generate, and cost more — choose only as large as you need

Beyond the sizes above, custom pixel sizes (WIDTHxHEIGHT, lowercase x) are also supported, subject to the official constraints:

  • Width and height must both be multiples of 16
  • Each side must be within 16–3840 pixels
  • The aspect ratio must not exceed 1:3 (either orientation, e.g. 1024x3072 is fine but 1024x4096 is not)
  • The total pixel count (width × height) must be within 655,360–8,294,400 (about 0.65MP–8.29MP; the cap is roughly 3840×2160)

Sizes violating these constraints are rejected with a 400 error.

Request examples#

Whole-image editing (single image):

bash
curl --request POST \
  --url https://api.apimax.ai/v1/images/edits \
  --header 'Authorization: Bearer <token>' \
  --form 'model=gpt-image-2' \
  --form 'image=@/path/to/input.png' \
  --form 'prompt=Change the background to a spring park with cherry blossoms in full bloom' \
  --form 'size=1024x1024' \
  --form 'quality=high'

Multi-image composition:

bash
curl --request POST \
  --url https://api.apimax.ai/v1/images/edits \
  --header 'Authorization: Bearer <token>' \
  --form 'model=gpt-image-2' \
  --form 'image[]=@/path/to/a.png' \
  --form 'image[]=@/path/to/b.png' \
  --form 'prompt=Blend these two images into a single movie poster'

Python (requests):

python
import requests

url = "https://api.apimax.ai/v1/images/edits"
headers = {"Authorization": "Bearer <token>"}
files = {
    "image": open("input.png", "rb"),
}
data = {
    "model": "gpt-image-2",
    "prompt": "Replace the sky with a starry night sky",
    "size": "1024x1024",
}
resp = requests.post(url, headers=headers, files=files, data=data)
print(resp.json())

Response example#

Returns the standard OpenAI Images format synchronously; data[].b64_json is the base64 encoding of the generated image:

json
{
  "created": 1757156493,
  "data": [
    {
      "b64_json": "iVBORw0KGgoAAAANSUhEUgAA..."
    }
  ],
  "usage": {
    "input_tokens": 312,
    "output_tokens": 4160,
    "total_tokens": 4472,
    "input_tokens_details": {
      "text_tokens": 12,
      "image_tokens": 300
    }
  }
}

Decode b64_json to get the image binary. Image-to-image incurs additional image input token usage from reference images (see usage.input_tokens_details.image_tokens).

The generated result is determined by what data actually returns: individual images may fail to generate, in which case only the successful images are returned and billed (e.g. with n=4 and 2 images succeeded, 2 images are returned and billed).

If the request specifies response_format=url, each item returns a url field (a platform-hosted image link) and no longer contains b64_json:

json
{
  "created": 1757156493,
  "data": [
    {
      "url": "https://<storage-host>/img/image_xxxxxxxx.png"
    }
  ]
}

Error codes#

Status codeMeaning
400Invalid request parameters (missing image/prompt, unsupported format, etc.)
401Authentication failed; check your API key
403Insufficient account balance; top up and try again
403The token does not have access to this model
429Too many requests; try again later
500Internal server error; try again later

Next steps

All docs
Relink Audio URLsSynchronously fetch ready-to-use audio URLs by Suno clip_id.Upsample Style TagsPolish and expand style tags and lyrics into a fuller style description.Get Style Inspiration SuggestionsGet random style or inspiration suggestions from the Suno upstream.Method 1: Create a Voice from an Existing SongCreate a vocal voice directly from a song clip already generated in this pool.Upload AudioImport user audio as a Suno-owned clip; returns an async upload task ID. With copyright=true the request switches to the copyright pipeline.Query Quota UsageUse an API key to query the remaining credits, used credits, and unlimited-quota status of the current key and its owning user.
On this page
OverviewText-to-image / image-to-image endpoint selection/v1/images/generations: synchronous image generationRequest parametersoutputformat (image format, with GIF)Animated GIF outputRequest exampleresponseformat (compatibility parameter)Authentication/v1/images/edits: image-to-image and editingRequest parameters (form fields)image (source image)sizeRequest examplesResponse exampleError codesNext steps
API

POST /v1/images/generations