Skip to Content
Cheapest Imagen
Guides

Text to image

Generate images from a text prompt with the Cheapest Imagen API, and choose the model, size, quality, number of images and output file format.

Send a prompt to POST /v1/images/generations. Only model and prompt are required.

curl https://api.cheapestimagen.com/v1/images/generations \
  -H "Authorization: Bearer $YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-image-2",
    "prompt": "a lighthouse at dusk, oil painting",
    "n": 2,
    "size": "1536x1024",
    "quality": "high"
  }'

Options

FieldWhat it doesValues
nNumber of images1 to 10, default 1
sizeWidth and heightauto or a 1K, 2K or 4K size, see Ratios and sizes
qualityRendering quality, same price for allauto, low, medium, high; xhigh, max on gpt-image-2.5-sunburst
backgroundTransparent or solid backgroundauto, opaque, transparent
output_formatFile formatpng (default), jpeg, webp on every model; gif on gpt-image-2.6 and its flare and sunburst variants; svg on gpt-image-2.6
output_compressionQuality for jpeg and webp0 to 100, default 100
moderationHow strict content checks areauto, low
response_formatImage data or a linkb64_json (default), url

No model makes a transparent background at the moment: OpenAI withdrew its transparency preview for the GPT Image models, and they now return a solid background. A request with background: transparent returns a 400 with code unsupported_parameter. To get a cut-out, ask for a plain single-colour background in the prompt and remove it afterwards.

Output formats

PNG, JPEG and WebP work on every model, as on OpenAI’s API. Most models make a PNG, and we convert it to the JPEG or WebP you asked for inside Cloudflare’s network (about 0.1 to 0.4 seconds; a 2 MB PNG becomes a JPEG or WebP of about 250 KB). gpt-image-2.6-flare and gpt-image-2.6-sunburst make JPEG and WebP themselves.

ModelPNGJPEGWebPGIFSVG
gpt-image-2, gpt-image-2.5, gpt-image-2-adobeYesYesYes––
gpt-image-2.6YesYesYesYesYes
gpt-image-2.5-flare, gpt-image-2.5-sunburstYesYesYes––
gpt-image-2.6-flare, gpt-image-2.6-sunburstYesYesYesYes–
Nano Banana (all versions)YesYesYes––

“–” returns a 400. output_compression sets the JPEG or WebP quality on every model (default 100). A GIF can take three to five minutes. The file’s real type is in the link’s extension and its Content-Type.

How many credits a request uses

A request uses n times the model’s credits: 8 per image for GPT Image 2, 2.5 and 2.6, 12 for Nano Banana 2 and 2.1, 20 for Nano Banana Pro, gpt-image-2-adobe and the flare variants, 25 for the sunburst variants, 60 to 180 for the Nano Banana stable channels. If fewer images come back than you asked for, you pay only for the images you received.

Sending the same request twice

Add an Idempotency-Key header with a value of your choice. If the same key arrives again while the first request is running or after it succeeded, the API answers 409 and does not generate or charge again. After a failed request you can reuse the key.

On this page