Skip to main content

GPT-Image-2 API Guide: OpenAI Image API, Responses Tool, Pricing, and Provider Boundary

A
11 min readAI Image Generation

Call gpt-image-2 through the OpenAI Image API for direct generation and edits, or through the Responses image_generation tool for assistant workflows. Keep laozhang.ai provider pricing separate from OpenAI pricing.

GPT-Image-2 API Guide: OpenAI Image API, Responses Tool, Pricing, and Provider Boundary

GPT-Image-2 API now has a clean official route: use the OpenAI Image API when the image is the direct output, and use the Responses API image_generation tool when image generation belongs inside an assistant, agent, or multi-step flow. Do not collapse the official route and a provider route into one claim. OpenAI pricing, model IDs, organization verification, size constraints, and output formats are first-party facts; laozhang.ai gpt-image-2 at $0.03/call is a provider contract that can be useful for gateway or payment needs.

This page was rewritten after OpenAI published the GPT Image 2 model page and pricing evidence. Older release-watch wording is no longer the live contract.

Quick Answer

QuestionAnswer
Direct image jobUse Image API with model: "gpt-image-2".
Assistant or agent jobUse Responses API with a mainline model plus tools: [{ type: "image_generation" }].
Output setupChoose size, quality, output format, and compression; gpt-image-2 does not support transparent background.
Provider routeUse laozhang.ai only as provider-owned pricing/access, not OpenAI official pricing.

Official Evidence

EvidenceCurrent contractSource
Model IDgpt-image-2OpenAI model page
Snapshotgpt-image-2-2026-04-21OpenAI model page
Direct API/v1/images/generations and /v1/images/edits examples use model: "gpt-image-2"Image generation guide
Assistant flowUse a mainline model such as gpt-5.4 with the image_generation tool; gpt-image-2 is the GPT Image model behind the image process, not the Responses model field.Responses image tool
PricingStandard rows: image input $8, cached image input $2, image output $30; text input $5, cached text input $1.25, text output $10 per 1M tokens.Pricing
Cost estimate1024x1024: low $0.006, medium $0.053, high $0.211; portrait/landscape examples are $0.005, $0.041, $0.165.Cost calculator

The API page should not dump endpoints. It should first decide whether the Image API or Responses is the right surface, then make request shape, cost, output, and fallback explicit.

GPT-Image-2 official Image API and Responses route

Choose Image API or Responses First

RouteUse it whenStop rule
Image APIOne request directly generates or edits image output.Best for product images, edits, batches, explicit storage, and cost logs.
Responses APIImage generation is part of an assistant, agent, or multi-step workflow.Do not add Responses complexity for a single direct image.
Provider gatewayYou need gateway access, local payment, compatibility, or fallback routing.Log provider, base URL, model mapping, billing, and output rights.

Minimum Viable Calls

javascript
import OpenAI from "openai"; const openai = new OpenAI(); const result = await openai.images.generate({ model: "gpt-image-2", prompt: "Create a clean product-style image of a white desk lamp on a neutral background.", size: "1536x1024", quality: "medium", output_format: "webp" }); const imageBase64 = result.data[0].b64_json;

For image edits, use /v1/images/edits with image uploads; multi-reference work still belongs in edit semantics. In Responses examples, use a mainline model such as gpt-5.4 and attach tools: [{ type: "image_generation" }]. Key boundary: gpt-image-2 is the GPT Image model, not the Responses main model field.

Implementation Patterns: Generate, Edit, Responses, Streaming

PatternRequest shapeProduction check
Direct generationimages.generate({ model: "gpt-image-2", prompt, size, quality, output_format })Log size, quality, format, prompt version, and request ID.
Reference editimages.edit({ model: "gpt-image-2", image, prompt })Count input-image number, source, rights, and image input tokens.
Mask editUpload image + mask; mask needs an alpha channel and must match source format/size.Block mismatched masks in UI before the API call.
Responsesresponses.create({ model: "gpt-5.4", tools: [{ type: "image_generation" }], input })Use only when the image is a step inside an agent flow; keep direct images on Image API.
Streaming / partialsImage API can use stream: true and partial_images; the Responses tool can also request partial images.Partial images add output tokens; include preview count in cost logs.
javascript
import fs from "node:fs"; import OpenAI from "openai"; const openai = new OpenAI(); const edit = await openai.images.edit({ model: "gpt-image-2", image: fs.createReadStream("input.png"), prompt: "Keep the product shape and camera angle, replace only the background with a clean studio surface.", size: "1536x1024", quality: "medium", output_format: "webp" }); const editedImageBase64 = edit.data[0].b64_json;
javascript
const response = await openai.responses.create({ model: "gpt-5.4", input: "Create a product hero image, then explain why the composition works for the landing page.", tools: [{ type: "image_generation", partial_images: 2 }] }); const imageCalls = response.output.filter((item) => item.type === "image_generation_call");

GPT-Image-2 official price and provider price separation

Parameters, Limits, and Failure Modes

ItemCurrent boundaryProduction consequence
SizeMax edge <= 3840px, both edges multiples of 16, long/short ratio <= 3:1, total pixels 655,360 to 8,294,400.Do not let UI accept arbitrary dimensions.
Qualitylow, medium, high, autoUse low for drafts, medium/high for finals, and log cost differences.
Backgroundgpt-image-2 does not currently support transparent background.Use another model or post-process when transparency is required.
LatencyComplex prompts may take up to about 2 minutes.Frontend needs timeout, status, and retry design.
TextText rendering improved but can still fail.Public images need human text inspection.

What Production Logs Must Capture

FieldWhy it is requiredHow it helps failures
route_owneropenai, laozhang.ai, or another provider; never merge contracts.Separates first-party, provider, and configuration failures.
model_mappingRecord requested model and actual provider-mapped model.Catches silent wrapper model changes.
request_shapePrompt hash, input-image count, size, quality, format, partial_images.Reproduces cost spikes, latency spikes, and output drift.
storage_pointerStore decoded file path, hash, public URL, and deletion policy.Prevents dead-end base64-only artifacts.
retry_reasonSeparate timeout, policy, validation, provider 5xx, and size errors.Chooses retry, downgrade, route switch, or manual handling.

GPT-Image-2 API production checklist

Short Answer for AI Citation

Use gpt-image-2 in OpenAI Image API calls for direct generation, edits, masks, and streamed partial images. Use Responses with a mainline model plus image_generation only when the image is part of an assistant flow; log route owner, model mapping, size, quality, input images, partial previews, storage pointer, and retry reason.

FAQ

Do I put gpt-image-2 in Responses model?

No. Use a mainline model such as gpt-5.4 with the image_generation tool.

Does GPT-Image-2 support transparent background?

The OpenAI guide says gpt-image-2 does not currently support transparent backgrounds.

Should I use Image API or Responses?

Use Image API for direct output; use Responses when the image is part of an assistant or multi-step flow.

Can GPT-Image-2 stream partial images?

Yes, use streaming and partial_images where the surface supports it. Budget the additional preview images because they add output tokens.

Share:

laozhang.ai

One API, All AI Models

AI Image

Gemini 3 Pro Image

$0.05/img
80% OFF
AI Video

Sora 2 · Veo 3.1

$0.15/video
Async API
AI Chat

GPT · Claude · Gemini

200+ models
Official Price
Served 100K+ developers
|@laozhang_cn|Get $0.1