The OpenAI Image Generation API in 2026: Models, Code, and Cost

Modellix cover: a glossy code terminal showing an OpenAI images API call, flow lines connecting to generated image thumbnails, headline OpenAI Image Generation API, The 2026 Developer Guide

Most guides to the OpenAI image generation API are quietly out of date. They walk you through DALL·E 3 — which OpenAI shut down on May 12, 2026 — or they build on gpt-image-1, which is scheduled to be turned off on October 23. If you’re integrating today, that matters: pick the wrong model and your code stops working within months.

Here’s the current picture, checked against OpenAI’s own image generation docs in July 2026. The image API is now the GPT Image family, and within it there’s really one model you should build on: gpt-image-2. This guide covers the live model lineup, what the API can do, the two ways to call it (with runnable code), what it costs per image, and the setup gotchas that trip people up — so you integrate against something that will still be there next quarter. (If you’re weighing OpenAI against the broader field, our text-to-image API guide covers the whole category.)

The current OpenAI image models

OpenAI has consolidated hard. As of July 2026, gpt-image-2 is the only image model that isn’t deprecated — it’s OpenAI’s recommended replacement for everything else. The rest are either gone or on a shutdown schedule:

Model Status Shutdown
gpt-image-2 Current — build on this
gpt-image-1.5 Deprecated Dec 1, 2026
gpt-image-1 Deprecated Oct 23, 2026
gpt-image-1-mini Deprecated Dec 1, 2026
DALL·E 3 / DALL·E 2 Retired May 12, 2026
OpenAI deprecations page showing gpt-image-1.5, gpt-image-1-mini and chatgpt-image-latest shutting down December 1, 2026 with gpt-image-2 as the replacement

OpenAI’s deprecations page, captured July 23, 2026 — the older GPT Image models are being retired, with gpt-image-2 named as the replacement.

So if you’re reading a tutorial that opens the dall-e-3 or gpt-image-1 model string, close it — those calls either already fail or will soon. The one exception worth knowing: gpt-image-1.5 is still live until December and is the model to reach for if you specifically need transparent backgrounds (more on that below). For everything else, gpt-image-2 is the answer.

What the OpenAI image API can do

Beyond plain text-to-image, the API covers the operations most products actually need:

  • Generation — a text prompt in, an image out, at 1024×1024, 1024×1536, or 1536×1024.
  • Editing and inpainting — pass a source image plus an optional mask to change part of an image while keeping the rest. An input_fidelity control governs how closely the output preserves the input; gpt-image-2 processes inputs at high fidelity automatically. (For a deeper look at edit workflows, see our image manipulation API guide.)
  • Multi-image input — combine several reference images into one result.
  • Moderation control — a moderation parameter set to auto (standard) or low (less restrictive).

One real limitation to plan around: gpt-image-2 does not support transparent backgrounds. If you need a cut-out PNG with alpha — product shots, logos, sprites — you’ll want gpt-image-1.5, which natively supports transparency (and can merge up to 16 images), for as long as it’s live. It’s the one place the newest model isn’t the automatic choice.

How to call the OpenAI image generation API: two paths

There are two distinct ways to generate an image, and picking the right one matters more than it sounds.

The Image API is the direct, single-purpose endpoint — POST /v1/images/generations and /v1/images/edits. (The old /variations endpoint only ever worked with DALL·E 2 and retired along with it, so there’s no current model behind it.) It returns the image as base64 in data[0].b64_json. This is what you want for a straightforward “prompt in, file out” job:

1
2
3
4
5
6
7
8
9
10
11
12
from openai import OpenAI
client = OpenAI()

result = client.images.generate(
model="gpt-image-2",
prompt="A children's book illustration of a veterinarian",
size="1024x1024",
quality="medium", # low | medium | high | auto
n=1, # number of images to return
output_format="png", # png (default) | jpeg | webp
)
image_b64 = result.data[0].b64_json # base64-encoded PNG

Editing works the same way — pass a source image and, optionally, a mask marking the region to regenerate:

1
2
3
4
5
6
7
edited = client.images.edit(
model="gpt-image-2",
image=open("room.png", "rb"),
mask=open("mask.png", "rb"), # transparent pixels in the mask get repainted
prompt="Replace the sofa with a green velvet one",
input_fidelity="high", # keep the rest of the room faithful
)

Reach for edits when you’re changing an existing image (product swaps, background replacement, retouching); use generations when you’re creating from scratch.

The Responses API invokes image generation as a tool inside a normal model call, which lets the model reason about the request, edit across turns, and stream partial images:

1
2
3
4
5
response = client.responses.create(
model="gpt-5.6",
input="Generate an image of a gray tabby cat hugging an otter",
tools=[{"type": "image_generation"}],
)

Rule of thumb: use the Image API for deterministic, high-volume generation where you just want the file; use the Responses API when the image is part of a conversation, needs multi-turn editing, or you want to stream previews (partial_images, 0–3). Both ultimately hand you base64 image data to decode and save — the Image API as data[0].b64_json, the Responses API inside the image-tool output.

What it costs to run

Pricing is per image, and it’s driven by the model and the quality tier you pick. From OpenAI’s own cost table, for a standard 1024×1024 output:

Model (1024²) Low Medium High
gpt-image-2 $0.006 $0.053 $0.211
gpt-image-1.5 $0.009 $0.034 $0.133
gpt-image-1-mini $0.005 $0.011 $0.036
OpenAI image pricing table showing gpt-image-2 at $0.006 low, $0.053 medium, $0.211 high per 1024px image, and gpt-image-1-mini from $0.005

OpenAI’s per-image pricing, captured July 23, 2026 — gpt-image-2 runs $0.006 (low) to $0.211 (high) at 1024×1024. Rates can change; confirm against the live page.

The spread is enormous — a high-quality gpt-image-2 render costs about 35× a low-quality one — so quality tier, not model choice, is the lever that moves your bill. Under the hood it’s token-metered (gpt-image-2 output tokens run $30 per million), but the per-image figures above are the numbers to budget with. Two things to note before you commit: there’s no free image tier on the API — every generation is billed (the free image generation inside the ChatGPT app is a separate consumer product, not API access) — and you’ll likely need to complete API Organization Verification in your developer console before GPT Image models will run at all. Build that verification step into your setup, not your launch day. (Wondering how OpenAI stacks up on price across providers? See our cheapest AI API breakdown.)

Getting started, and your access options

The straightforward path is direct: verify your organization, drop in your API key, and call client.images.generate with gpt-image-2. That’s the reference integration and, if OpenAI is the only provider you need, the right one.

If you’re evaluating OpenAI’s image models alongside others — Google’s Gemini image models, say, or Flux — you can also reach them through an aggregation layer on one key, which is handy while you’re still comparing. Modellix, for instance, carries four OpenAI image models — gpt-image-2 and gpt-image-1.5 plus their edit variants — metered per image ($0.0041–$0.3943 for gpt-image-2), with per-call cost and latency logging. Two honest limits: it carries only those four — not gpt-image-1, gpt-image-1-mini, DALL·E, or Sora — so for anything outside GPT Image you’d go direct; and it’s a distribution layer for OpenAI’s models, not a cheaper or exclusive source. What it buys you is one integration across providers while you decide, not a lower unit price.

FAQ

Is DALL·E still available through the API?
No. DALL·E 2 and DALL·E 3 were shut down on May 12, 2026. Any dall-e-3 API call now fails; gpt-image-2 is OpenAI’s replacement.

Which OpenAI image model should I use in 2026?
gpt-image-2 — it’s the only one not deprecated. The exception is transparent backgrounds, which need gpt-image-1.5 (live until December 1, 2026).

Is the OpenAI image generation API free?
No. There’s no free image tier; every generation is billed per image, from about $0.005 (mini, low quality) to $0.211 (gpt-image-2, high quality) at 1024×1024.

What happened to gpt-image-1 and gpt-image-1-mini?
Both are deprecated. gpt-image-1 shuts down October 23, 2026 and the -mini on December 1 — OpenAI points all of them to gpt-image-2.

Can I edit or inpaint images with the API?
Yes — the /v1/images/edits endpoint (or the Responses API’s image tool) takes a source image and optional mask, with an input_fidelity control for how much of the original to preserve.

Do I need anything special to use GPT Image models?
Usually API Organization Verification, completed in your developer console. Without it, calls to GPT Image models can be blocked.