AI / Core OpenAI Codex Application Fundamentals Interview Questions
What are OpenAI's image generation models and how do you use them in applications?
OpenAI offers image generation models accessible via the Images API. As of mid-2026 the recommended models are gpt-image-2 and gpt-image-1, following the deprecation of DALL-E 2 and DALL-E 3 in May 2026.
| Model | Key capability | API endpoint |
|---|---|---|
| gpt-image-2 | Most advanced; highest quality generation and editing | v1/images/generate, v1/images/edits |
| gpt-image-1 | Strong generation; also available via Responses API image tool | v1/images/generate, Responses API |
| gpt-image-1-mini | Faster, lighter image generation | v1/images/generate |
| chatgpt-image-latest | Always points to the latest image model | v1/images/generate |
from openai import OpenAI import base64 client = OpenAI() # Generate an image (gpt-image-2) response = client.images.generate( model="gpt-image-2", prompt="A Python snake debugging code on a computer, photorealistic", size="1024x1024", quality="high", n=1, response_format="b64_json", # or "url" ) image_data = base64.b64decode(response.data[0].b64_json) # Image editing (inpainting) response = client.images.edit( model="gpt-image-2", image=open("original.png", "rb"), mask=open("mask.png", "rb"), # transparent area = area to edit prompt="Replace the background with a futuristic city skyline", ) # Via Responses API (gpt-image-1 as a tool): response = client.responses.create( model="gpt-5.5", input="Create a diagram of a microservices architecture.", tools=[{"type": "image_generation"}], )
Note on DALL-E deprecation: DALL-E 2 and DALL-E 3 model snapshots were deprecated and removed from the API on May 12, 2026. Applications referencing dall-e-2 or dall-e-3 will now receive errors and must migrate to gpt-image-2, gpt-image-1, or gpt-image-1-mini.
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
