Skip to main content

Can GPT-Image-2 Return Multiple Images? Use the Image API n Parameter

5 min readAI Image Generation

Use the official Image API's n parameter to request several independent GPT-Image-2 candidates, save each final result, and keep streaming previews separate from usable outputs.

GPT-Image-2 batch request turning one prompt and an n value into four separate final image files

Yes—when you use the official OpenAI Image API, set the n parameter to the number of final GPT-Image-2 candidates you want. The default is one image. A request with n: 4 is meant to return four separate final image payloads in result.data, not one four-panel collage.

That answer applies to the Image API. It does not automatically describe the ChatGPT UI, a Responses API image-generation tool call, or a gateway that happens to use a similar model name. Those routes may offer a different control—or no direct count control at all.

The direct API answer

What you needUse this
Several independent final candidatesCall openai.images.generate() with model: "gpt-image-2" and n greater than 1.
One final candidateOmit n or use n: 1.
Intermediate images while one final image is renderingUse streaming and partial_images; these are previews, not extra candidates.
Several pictures inside a single fileDescribe a collage or storyboard in the prompt. That is one output, not an API batch.

OpenAI's Image Generation guide documents n for generating multiple images in one Image API request. Treat the resulting array as a set of candidates: save them separately, check how many actually arrived, and select before spending on more runs.

One prompt can produce multiple final candidates, while streaming previews and a collage mean different things

Generate and save four final images

This Node example requests four 1024px square WebP candidates and writes each returned payload to a distinct file. It deliberately does not assume a particular response count before checking the array.

javascript
import OpenAI from "openai"; import { writeFile } from "fs/promises"; const openai = new OpenAI(); const result = await openai.images.generate({ model: "gpt-image-2", prompt: "A studio product photo of a matte black desk lamp on a pale gray background, centered with soft side light. No text, logos, or people.", n: 4, size: "1024x1024", quality: "low", output_format: "webp", }); if (!result.data?.length) { throw new Error("The request completed without final image data."); } await Promise.all( result.data.map((item, index) => { if (!item.b64_json) { throw new Error(`Image ${index + 1} has no base64 payload.`); } return writeFile(`lamp-candidate-${index + 1}.webp`, Buffer.from(item.b64_json, "base64")); }) ); console.log(`Saved ${result.data.length} final candidate(s).`);

The API's default output is base64 image data; output_format: "webp" makes the saved extension match the requested format. If your SDK or wrapper uses a different parameter name or returns URLs, consult that route's own documentation instead of copying this example unchanged.

What n does—and does not—promise

It doesIt does not do
Requests multiple separate final image outputs from the official Image API.Guarantee that the candidates are equally good, unique, or ready to ship.
Puts final image payloads in the response data array when the request succeeds.Turn one file into several images; a collage is still one final image.
Lets you evaluate candidates under the same prompt and requested settings.Make ChatGPT, a Responses tool call, or a provider expose the same numeric control.

Use a batch when the candidates will be evaluated under the same acceptance rule—for example, four product-shot compositions with the same subject, aspect ratio, and brand restrictions. Do not batch unrelated jobs just because they can share an API call; separate prompts make failures, cost attribution, and review harder to understand.

Do not confuse final candidates with streaming previews

Streaming has a different purpose. The official guide lets you ask for partial_images while an image is still rendering. It may send zero to three intermediate preview events before the final result, and a fast render can send fewer previews than requested. Those events help make a UI feel responsive. They are not the same thing as requesting n: 3 final images.

The practical distinction is simple:

  • Want three images you can compare or persist? Use n: 3 in the Image API generation call. Want to show progress while one image renders? Use stream: true with partial-images.
  • Want three scenes inside one poster? Ask for a three-panel layout in the prompt, then expect one final file.

Pick the correct surface first

SurfaceCan this page's n example be assumed to apply?Next action
OpenAI Image APIYes, for the generations call documented by OpenAI.Use openai.images.generate() and loop over result.data.
Responses API image toolNo direct assumption.Follow the current Responses tool contract; it is designed for conversational image workflows.
ChatGPT web or app UINo.Use the controls available in that product; a prompt request is not an API parameter.
Third-party provider or gatewayNo.Check its model mapping, parameter schema, response format, limits, and billing terms.

This matters when debugging a result that has only one image. First record the endpoint, SDK method, model field, and raw response shape. If the code never calls the Image API generations endpoint with n set, changing the English prompt will not add a batch parameter. If a provider accepts n but returns one item, treat that as a provider-contract issue until it reproduces against the official route.

Save every final candidate, select the winner against one rule, then refine only that branch

Batch safely: save, select, then refine

Multiple outputs are useful only if you have a selection rule. Before submitting a batch, define the few observable checks that matter: correct subject, readable text, no prohibited logo, correct crop, or a required layout. Save the prompt version and requested settings alongside each filename. Then choose the strongest candidate before raising quality, making a targeted edit, or sending another batch.

Each requested final image can consume generation capacity and create cost. Start with a small, reviewable candidate set and lower quality for draft composition checks. Once one direction passes, make the next request narrower: preserve the winning composition, change one detail, or request the final quality. Do not blindly rerun a large batch because one candidate missed the mark; that obscures what improved and increases review work.

For production automation, also handle partial success. Count the returned items, store the request identifier or your own correlation ID, and mark the job incomplete if the count does not meet your downstream requirement. A response with valid image data is not proof that every candidate satisfies your content, brand, or safety acceptance rule.

FAQ

Can GPT-Image-2 return four separate images in one API request?

Yes. With the official Image API, use model: "gpt-image-2" and n: 4, then save each item in the returned image data array. The default is one image when n is not supplied.

Are partial_images the same as multiple final images?

No. partial_images are intermediate stream previews for one rendering operation. Use n when you need several final candidates to compare or store.

Why did I get a collage instead of several files?

The prompt may have requested a multi-panel composition, or your route may have produced one image by design. A collage is one final output. Check that you are calling the official Image API generations endpoint and that n is an actual request parameter rather than plain prompt text.

#GPT Image 2#GPT-Image-2#gpt-image-2#OpenAI Image API#Image Generation API#Multiple Images
Share: