Skip to main content
For the endpoint contract see Images API. This guide covers the practical side: picking a model, prompting, sizes, edits, persistence. client.images.generate(...) works against our base URL for the common case. Two things it doesn’t cover: image edits (see Image edits below), and a rare long-running generation answering a job to poll instead of an image (see the warning under Persistence). See the compatibility matrix for the full picture across every operation.

Pick a model

List the catalog with GET /v1/models and keep the entries whose _infery.modality is image. There is no modality query parameter — filter client-side. Each entry’s _infery.allowed_params.sizes tells you what to ask for.

Prompt patterns that work

Across all current image models, structured prompts beat freeform descriptions:
Tips that generalise:
  • Subject first. Models weight early tokens more.
  • Be concrete. “Cinematic lighting” is vague; “low-key chiaroscuro from a single window” isn’t.
  • Specify what to avoid with negative phrasing: “no text, no watermark, no humans”.
  • Anchor style with reference styles or photographers (“in the style of National Geographic”, “shot on Hasselblad H6D”).
  • Iterate small. Change one variable at a time — model, then prompt, then size.

Sizes and aspect ratios

Common, almost universally supported: Always check the model’s _infery.allowed_params.sizes in GET /v1/models before assuming — some models only support 1024x1024. Generating for a platform? Don’t look the numbers up — see Publishing formats for the 21 named formats (Instagram Story, YouTube thumbnail, LinkedIn profile cover and the rest) with the exact dimensions each platform wants, and what happens when the model you picked can’t produce one of them.

Persistence

Generated URLs are ephemeral — typically 1 hour. If you want to keep an image, do one of:
python
python
The second pattern keeps the bytes in your workspace storage and gives you a stable file_id. Some models skip this entirely: when a generation is served through our durable job path, each item in data already carries a file_id alongside its url, and that URL is signed over our own storage rather than the provider’s. Read file_id first and only fall back to downloading when it is absent.
A generation that runs longer than 5 minutes answers 504 rather than an image, with a job_id in the error body. The job keeps running and is still billed, so treat this as “collect later”, not as a failure: poll GET /v1/images/jobs/{job_id} until status is completed, then read data[].url. The same job endpoint serves image, speech and transcription jobs.

Image edits

Models with edit support (Nano Banana, Qwen Image, FLUX) take a source image plus a prompt.
client.images.edit(...) from the OpenAI SDK does not work here. The SDK posts multipart/form-data with an image file part; our /v1/images/edits takes JSON with a base64 image_base64 field. Call it over plain HTTP instead.
python
image_mime_type defaults to image/png — set it when your source is anything else. An optional mask_base64 (transparent = the region to repaint) enables in-painting on the models that support a mask. Not every image model can serve an edit: the request is routed to one source, and if that source takes no input image the call is refused with 400 edit_not_supported before anything is billed. Use cases: background swap, object removal, restyling, in-painting. Edit fidelity beats “regenerate from scratch” for any case where the subject needs to stay consistent.

Sample: generate vs. edit

Generated autumn Japanese garden scene

Generation — 'Vibrant Japanese garden in autumn, koi pond, golden hour'

Edited to winter scene, composition preserved

Edit — same source image, prompt: 'Transform into a snowy winter wonderland, keep layout intact'

Both images produced by Nano Banana (nano-banana). Notice how the edit preserves the composition — bridge, lantern, pond — while swapping season, lighting and palette.

Quality vs. cost

Generation cost varies by model and size — check pricing in GET /v1/models. Rules of thumb:
  • DALL·E 3 standard ≈ 4 credits, HD ≈ 8 credits
  • Imagen 4 ≈ 8 credits
  • Nano Banana ≈ 1.5 credits
  • FLUX (self-hosted) ≈ 1 credit
For experimentation in the Studio, pick the cheap models. For production hero images, pick by quality, not cost.

Safety

All providers (except FLUX self-hosted) run their own safety filters. Refusals come back as a 400 with the provider’s reason — they aren’t transient and fallback won’t help. If you hit refusals on legitimate content, try a different provider or rephrase. For the policy boundary, see AUP.