Skip to Content
Cheapest Imagen
API reference

Edit image

Creates images from a prompt and one or more reference images, sent as files in a multipart form or as links.

POST
/images/edits

Creates images from a prompt and one or more reference images, sent as files in a multipart form or as links.

Authorization

apiKey
headerAuthorizationBearer <token>

Your API key, sent as Authorization: Bearer <key>.

Header Parameters

Idempotency-Key?string

A value of your choice, up to 255 characters. Sending the same value again does not create or charge a second request; it returns 409 instead.

Lengthlength <= 255

Request Body

multipart/form-data
  1. body
model*string

The model to use.

Value in"gpt-image-2""gpt-image-2-adobe""gpt-image-2.5""gpt-image-2.5-flare""gpt-image-2.5-sunburst""gpt-image-2.6""gpt-image-2.6-flare""gpt-image-2.6-sunburst""nano-banana-2""nano-banana-2.1""nano-banana-pro""nano-banana-2-1k""nano-banana-2-2k""nano-banana-2-4k""nano-banana-pro-1k""nano-banana-pro-2k""nano-banana-pro-4k"
prompt*string

What the image should show. Up to 32,000 characters.

Lengthlength <= 32000
n?integer

How many images to make. A request uses n times the model’s credits. At most 10 at 1K, 4 at 2K and 2 at 4K.

Range1 <= value <= 10
Default1
size?string

auto lets the model choose (on a model with one resolution, that resolution). The other values are 1K, 2K and 4K sizes; each model accepts the resolutions listed on its card at /models, at one price. See the sizes guide for the ratio of each. gpt-image-2-adobe and gpt-image-2.5-flare also take a width and height of your own: multiples of 16, up to 3840 px a side, no longer than 3:1, 655,360 to 8,294,400 pixels.

Default"auto"
Value in"auto""1024x1024""1536x1024""1024x1536""1443x1090""1090x1443""1672x941""941x1672""1408x1120""1120x1408""1920x832""832x1920""1792x896""896x1792""1152x864""864x1152""1280x720""720x1280""1120x896""896x1120""1456x624""624x1456""1536x768""768x1536""2048x2048""2048x1360""1360x2048""2304x1728""1728x2304""2048x1152""1152x2048""2240x1792""1792x2240""2912x1248""1248x2912""3072x1536""1536x3072""2048x688""688x2048""2880x2880""3504x2336""2336x3504""3264x2448""2448x3264""3840x2160""2160x3840""3200x2560""2560x3200""3840x1648""1648x3840""3840x1920""1920x3840""3840x1280""1280x3840""2048x512""512x2048""3072x384""384x3072""4096x1024""1024x4096""6144x768""768x6144""8192x2048""2048x8192""12288x1536""1536x12288"
quality?string

Rendering quality, honoured by gpt-image-2-adobe and the flare and sunburst variants; the other GPT models choose it themselves and Nano Banana ignores it. xhigh and max work on gpt-image-2.5-sunburst only. Every quality costs the same.

Default"auto"
Value in"auto""low""medium""high""xhigh""max"
background?string

No model makes a transparent background at the moment, so transparent returns a 400. auto and opaque work on every model.

Default"auto"
Value in"auto""opaque"
output_format?string

File format of the returned images. gif works on gpt-image-2.6 and its flare and sunburst variants, svg on gpt-image-2.6 only. png, jpeg and webp work on every model.

Default"png"
Value in"png""jpeg""webp""gif""svg"
output_compression?integer

Quality for jpeg and webp, from 0 to 100. Default 100.

Range0 <= value <= 100
moderation?string

How strictly the prompt and the result are checked. low is less restrictive.

Default"auto"
Value in"auto""low"
response_format?string

b64_json returns the image data in the response. url returns a link to the image, kept for 72 hours.

Default"b64_json"
Value in"b64_json""url"
async?boolean

Set to true to run the request in the background. The answer is 202 with a task right away; read the result later with GET /images/tasks/{id}. The images are returned as links, so response_format must be url or left out. The header Prefer: respond-async does the same.

Defaultfalse
webhook_url?string

With async: an https:// address that gets one POST of the finished task (the same JSON as GET /images/tasks/{id}). It is tried up to 3 times. Send webhook_secret to have the call signed; without it, confirm what you receive by fetching the task with your key.

Formaturi
webhook_secret?string

With webhook_url: a secret of your own, 16 to 128 characters. The call to your address then carries x-webhook-signature: t=<unix seconds>,v1=<hex>, where the hex is HMAC-SHA256 of <t>.<body> made with this secret.

Length16 <= length <= 128
image[]*array<>

Reference images: PNG, JPEG or WebP, 1 to 16 files, each up to 20 MB, 50 MB in total.

Items1 <= items <= 16
input_fidelity?string

How closely the result keeps the details of the reference images. Not accepted by gpt-image-2.

Value in"low""high"

Response Body

The images.

application/json
  1. response
created*integer

When the images were made, as a Unix timestamp in seconds.

data*array<>
Example Request
curl -X POST 'https://api.cheapestimagen.com/v1/images/edits' \  -F 'model=gpt-image-2' \  -F 'prompt=string' \  -F 'image[]=[  "string"]'
Example Response
{  "created": 0,  "data": [    {      "b64_json": "string",      "url": "http://example.com"    }  ]}