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.6-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.6-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
More accurate complex compositionscomplexity2.6 only — see complexity
Vector imageoutput_format: "svg" + svg2.6 only — see SVG vector output
Animationoutput_format: "gif" + frame_count2.6 only — see Animated GIF

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.

Planning complexity (complexity)

Key point2.6 only. Defaults to high when omitted; lower it for faster images.

complexity controls how much compute the model spends planning the image before generating it. It is independent of quality, which controls rendering detail, and the two can be set separately.

ValueBest for
lowSimple compositions where speed matters, such as icons or a single object
mediumGeneral scenes
high (default)Multiple subjects, text layout, complex spatial relationships

Changing complexity costs nothing extra. Higher values are slower and may introduce unwanted changes; for simple compositions low is enough. The edit endpoint supports this parameter too.

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.6-flare", "prompt": "A red apple on a white table, soft natural light", "size": "1024x1024", "quality": "low", "complexity": "low" }' \ -o response.json jq -r '.data[0].b64_json' response.json | base64 --decode > output.png

SVG vector output

Key point2.6 only, text-to-image endpoint only. svg.model is required and n must be 1.

Good for icons and illustrations whose paths, shapes and colors you want to edit afterwards. Generation takes two steps: the image model named in the outer model first generates a reference image, then the text model named in svg.model writes SVG code from it. quality and complexity affect only the reference image; reasoning effort while writing the SVG is controlled separately by svg.reasoning.effort.

ItemDetails
Requiredoutput_format: "svg"; svg.model: the text model that writes the SVG, your choice
What to put in svg.modelAny OpenAI text model on OfoxAI — from gpt-5 and gpt-5-nano to gpt-6-astra and gpt-6.1-sol, all wrote valid SVG in our tests. No openai/ prefix, unlike the outer model. Other vendors’ models are not supported. Pick gpt-6-luna to save money; for a cost comparison see SVG cost
Optionalsvg.reasoning.effort: reasoning effort while writing the SVG — none, minimal, low, medium, high, xhigh or max. Which levels are available depends on the model; for example, gpt-5.4-pro supports only medium, high and xhigh. If omitted, the model’s default is used
Limitsn must be 1; stream, partial_images, prompt_rewriter and output_compression are not supported; the edit endpoint does not support SVG, and an SVG cannot be used as an input image for editing
Responsedata[0].b64_json decodes to UTF-8 SVG text containing only static vector content — no scripts, external resources or bitmaps
BillingBilled in two parts: the reference image at the image model’s price, recorded in usage; the SVG-writing tokens separately at the price of the svg.model text model, recorded in svg_usage. Both appear in the request details in the console
LatencyMuch slower than ordinary image generation; set the client timeout to 600 seconds
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.6-flare", "prompt": "A flat-style icon of an orange fox, white background", "size": "1024x1024", "quality": "low", "n": 1, "output_format": "svg", "svg": { "model": "gpt-6-luna" } }' \ -o response.json jq -r '.data[0].b64_json' response.json | base64 --decode > output.svg

Animated GIF

Key point2.6 only; supported on both the text-to-image and edit endpoints. Describe the subject, the motion and whether it loops in the prompt.
ParameterValuesDefault
output_formatgif—
frame_count2–16 frames9
frame_duration_msMilliseconds each frame is shown; minimum 20, rounded to 10 ms200
sizeSize of each frame: auto, or width and height both multiples of 16auto

The frame count and per-frame size together must meet a minimum pixel requirement; frames that are too small return No supported sheet fits … GIF frames. For example, with 9 frames 256x256 is not enough but 512x512 works. Frame count, size and number of images together also cannot exceed an upper limit; if they do, lower frame_count, shrink the size or reduce n.

stream, partial_images and output_compression are not supported, and when editing it cannot be combined with mask. frame_count and frame_duration_ms only take effect for GIF output.

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.6-flare", "prompt": "An orange fox wagging its tail side to side, flat illustration style, seamless loop", "size": "512x512", "quality": "low", "output_format": "gif", "frame_count": 8, "frame_duration_ms": 120 }' \ -o response.json jq -r '.data[0].b64_json' response.json | base64 --decode > output.gif

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.6-flareopenai/gpt-image-2.6-sunburstopenai/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· valuespngjpegwebpgifsvg

png, jpeg and webp all measured working. gif and svg are 2.6 only — see Animated GIF and SVG vector output.

complexitystring· default high· valueslowmediumhigh

2.6 only. How much planning happens before generation; independent of quality, at no extra cost. See complexity.

▶Advanced · 7svg · frame_count · frame_duration_ms · output_compression · background · moderation · partial_imagesExpand
svgobject

2.6 only; required when output_format is svg. svg.model (required) is the OpenAI text model that writes the SVG, without the openai/ prefix; svg.reasoning.effort (optional) is the reasoning effort while writing the SVG. See SVG vector output.

frame_countinteger· default 9· values2–16

2.6 only. Number of GIF frames; only takes effect when output_format is gif.

frame_duration_msinteger· default 200· values≥ 20

2.6 only. Milliseconds each GIF frame is shown, rounded to 10 ms; only takes effect when output_format is gif.

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.6
Invalid value: 'standard'quality set to standard or hdUse low through max
No supported sheet fits … GIF framesGIF frames are too small: frame count and size together fall below the minimum pixel requirementUse a larger size — see Animated GIF
SVG output requires an svg object with a modelsvg.model was not passed when generating SVGAdd svg.model — see SVG vector output
SVG author model '…' is not supported for svg.modelsvg.model has the openai/ prefix, names another vendor’s model, or has a typo in the model IDDrop the prefix and use an OpenAI text model ID such as gpt-6-luna
Unsupported value: '…' is not supported with the '…' modelsvg.reasoning.effort set to a level the model doesn’t supportUse one of the levels listed in the error, or omit it to use the model’s default
SVG output supports only n=1n greater than 1 when generating SVGRemove n or set it to 1
Invalid 'frame_count' for GIF outputframe_count outside 2–16Use an integer from 2 to 16
Complexity '…' is not supported for this image modelcomplexity sent to 2.5 or gpt-image-2Remove the parameter, or switch to 2.6
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