Skip to Content
ModelsGPT ImageText to image

Text to image

Generate an image from a text prompt.

Not writing code? See Generate images in your own tools.

POST/v1/images/generationsShared parameters Try it

Before you start

You needDetails
API keyCreate one in the OfoxAI console  and replace YOUR_OFOX_API_KEY in the code
EnvironmentcURL needs jq to decode the image; Python needs pip install openai; Node.js 18 or later, no dependencies
TimeoutSet your client timeout to 600 seconds. High quality, large sizes or editing can take several minutes
Values used in the code
API URLhttps://api.ofox.io/v1
Model IDopenai/gpt-image-2.5-flare
API keyReplace YOUR_OFOX_API_KEY in the code with your key
Python depspip install openai

Code

Every sample below was run verbatim. The result is saved as output.png in the current directory.

Terminal
curl -s https://api.ofox.io/v1/images/generations \ -H "Authorization: Bearer YOUR_OFOX_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "openai/gpt-image-2.5-flare", "prompt": "A red apple on a white table, soft natural light", "size": "1024x1024", "quality": "low" }' \ -o response.json # The image comes back as base64 — decode and save it (needs jq; on error, read response.json) jq -r '.data[0].b64_json' response.json | base64 --decode > output.png

Common tweaks

Change one parameter in the request above:

To getChangeNotes
A different sizesizeCustom sizes must meet the four rules
Better qualityqualityHigher tiers cost more and take longer — see Quality
Smaller filesoutput_format, output_compressionSwitch to jpeg or webp, then set the compression
Several imagesn1–10, each billed separately

Size (size) and quality (quality)

  • Size size: width and height both multiples of 16, longest edge ≤ 3840, aspect ratio between 1:3 and 3:1, total pixels ≥ 655,360. 768x768 fails; 1024x768 works. If omitted, the model decides; in our tests it was 1254×1254. See Size.
  • Quality quality: get it working with low first, then go higher. Omitting it is not the same as medium; the model picks a tier itself. gpt-image-2 has no xhigh or max. Usage per tier is in Quality.

Parameter values

Accepted values and measured defaults for this family. For size and quality, see Size and Quality on the overview page.

Required
modelrequiredstring· valuesopenai/gpt-image-2.5-flareopenai/gpt-image-2.5-sunburstopenai/gpt-image-2

Case-sensitive; a wrong case returns 404. Write out the full ID with the openai/ prefix.

Common
ninteger· default 1· values1–10

Each image is billed separately. Above 10 returns 400.

output_formatstring· default png· valuespngjpegwebp

All three measured working.

▶Advanced · 4output_compression · background · moderation · partial_imagesExpand
output_compressioninteger· values0–100

Only applies to jpeg and webp.

backgroundstring· default opaque· valuesopaquetransparentauto

A transparent background needs png or webp; jpeg has no transparency.

moderationstring· valuesautolow

How strict content moderation is.

partial_imagesinteger· values0–3

Used with stream: true: how many intermediate images to send while generating.

Common errors

ErrorCauseFix
moderation_blockedThe prompt was blocked by the upstream safety systemChange the prompt and try again; retrying unchanged gives the same result
Transparent background is not supported for JPEG output formatTransparent background requested with jpegUse png or webp
404 model_not_foundModel ID misspelled or wrong caseCopy the model ID from this page
Invalid sizeSize breaks one of the four rules aboveAdjust it as described in Size and quality
does not support quality 'xhigh'xhigh or max sent to gpt-image-2Use high, or switch to 2.5
Invalid value: 'standard'quality set to standard or hdUse low through max
429 rate_limit_exceededOver 100 requests per minute (per team)Retry later

For other errors, see the full error table.

Official docs

OpenAI’s docs describe behavior when you call OpenAI directly. When you call through OfoxAI, the measured results in these pages take precedence. For example, you don’t need to pin a provider for editing.

Last updated on