Text to image
Generate an image from a text prompt.
Not writing code? See Generate images in your own tools.
Before you start
https://api.ofox.io/v1openai/gpt-image-2.5-flarepip install openaiCode
Every sample below was run verbatim. The result is saved as output.png in the current directory.
cURL
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.pngCommon tweaks
Change one parameter in the request above:
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.768x768fails;1024x768works. If omitted, the model decides; in our tests it was 1254×1254. See Size. - Quality
quality: get it working withlowfirst, then go higher. Omitting it is not the same asmedium; the model picks a tier itself.gpt-image-2has noxhighormax. 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.
openai/gpt-image-2.5-flareopenai/gpt-image-2.5-sunburstopenai/gpt-image-2Case-sensitive; a wrong case returns 404. Write out the full ID with the openai/ prefix.
Each image is billed separately. Above 10 returns 400.
All three measured working.
▶Advanced · 4output_compression · background · moderation · partial_imagesExpand
Only applies to jpeg and webp.
A transparent background needs png or webp; jpeg has no transparency.
How strict content moderation is.
Used with stream: true: how many intermediate images to send while generating.
Common errors
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.