The final time OpenAI’s ChatGPT launched a picture era mannequin, it shortly went viral throughout the web. Individuals have been captivated by the power to create Ghibli-style portraits of themselves, turning private recollections into animated paintings. Now, ChatGPT is taking issues a step additional with a brand new natively multimodal mannequin “gpt-image-1” which powers picture era immediately inside ChatGPT and is now out there by way of API. On this article we’ll discover the important thing options of OpenAI’s gpt-image-1 mannequin and the way to use it for picture era and enhancing.
What’s gpt-image-1?
gpt-image-1 is the most recent and most superior multimodal language mannequin from OpenAI. It stands out for its skill to generate high-quality photos whereas incorporating real-world data into the visible content material. Whereas gpt-image-1 is advisable for its strong efficiency, the picture API additionally helps different specialised fashions like DALL·E 2 and DALL·E 3.

Supply – Hyperlink
The Picture API provides three key endpoints, every designed for particular duties:
- Generations: Create photos from scratch utilizing a textual content immediate.
- Edits: Modify current photos utilizing a brand new immediate, both partially or totally.
- Variations: Generate variations of an current picture (out there with DALL·E 2 solely).

Supply – Hyperlink
Key Options of gpt-image-1
gpt-image-1 provides a number of key options:
- Excessive-fidelity photos: Produces detailed and correct visuals.
- Numerous visible kinds: Helps a variety of aesthetics, from photograph real looking to summary.
- Exact picture enhancing: Allows focused modifications to generated photos.
- Wealthy world data: Understands advanced prompts with contextual accuracy.
- Constant textual content rendering: Renders textual content inside photos reliably.
Availability
The OpenAI API permits customers to generate and edit photos from textual content prompts utilizing the GPT Picture or DALL·E fashions. At current, picture era is accessible solely by way of the Picture API, although help for the Responses API is actively being developed.
To learn extra about gpt-image-1 click on right here.
gpt-image-1 Pricing
Earlier than diving into the way to use and deploy the mannequin, it’s vital to know the pricing to make sure its efficient and budget-conscious utilization.
The gpt-image-1 mannequin is priced per token, with completely different charges for textual content and picture tokens:
- Textual content enter tokens (prompts): $5 per 1M tokens
- Picture enter tokens (uploaded photos): $10 per 1M tokens
- Picture output tokens (generated photos): $40 per 1M tokens
In sensible phrases, this roughly equates to:
- ~$0.02 for a low-quality sq. picture
- ~$0.07 for a medium-quality sq. picture
- ~$0.19 for a high-quality sq. picture
For extra detailed pricing by picture high quality and determination, discuss with the official pricing web page right here.

Be aware: This mannequin generates photos by first creating specialised picture tokens. Subsequently, each latency and general value rely upon the variety of tokens used. Bigger picture dimensions and better high quality settings require extra tokens, growing each time and value.
Entry gpt-image-1?
To entry the gpt-image-1 mannequin and use it, your group should first be verified. You might comply with this documentation supplied by Open AI. Particular person accounts should even be verified to realize entry to gpt-image-1.
To start, go to: https://platform.openai.com/settings/group/basic. Then, click on on “Confirm Group” to begin the verification course of.
gpt-image-1: Palms-on Utility
Lastly it’s time to see how we will generate photos utilizing the gpt-image-1 API.
We will probably be utilizing the picture era endpoint to create photos primarily based on textual content prompts. By default, the API returns a single picture, however we will set the n parameter to generate a number of photos directly in a single request.
Earlier than working our predominant code, we have to first run the code for set up and organising the atmosphere.
!pip set up openaiimport os
os.environ['OPENAI_API_KEY'] = "<your-openai-api-key"
Producing Pictures Utilizing gpt-image-1
Now, let’s strive producing a picture utilizing this new mannequin.
Enter Code:
from openai import OpenAI
import base64
shopper = OpenAI()
immediate = """
A serene, peaceable park scene the place people and pleasant robots are having fun with the
day collectively - some are strolling, others are taking part in video games or sitting on benches
beneath timber. The ambiance is heat and harmonious, with smooth daylight filtering
by way of the leaves.
"""
outcome = shopper.photos.generate(
mannequin="gpt-image-1",
immediate=immediate
)
image_base64 = outcome.information[0].b64_json
image_bytes = base64.b64decode(image_base64)
# Save the picture to a file
with open("utter_bliss.png", "wb") as f:
f.write(image_bytes)
Output:

Modifying Pictures Utilizing gpt-image-1
gpt-image-1 provides a lot of picture enhancing choices. The picture edits endpoint lets us:
- Edit current photos
- Generate new photos utilizing different photos as a reference
- Edit elements of a picture by importing a picture and masks indicating which areas needs to be changed (a course of often called inpainting)
Modifying an Picture Utilizing a Masks
Let’s strive enhancing a picture utilizing a masks. We’ll add a picture and supply a masks to specify which elements of it needs to be edited.

The clear areas of the masks will probably be changed primarily based on the immediate, whereas the colored areas will stay unchanged.
Now, let me ask the mannequin so as to add Elon Musk to my uploaded picture.
Enter Code:
from openai import OpenAI
shopper = OpenAI()
outcome = shopper.photos.edit(
mannequin="gpt-image-1",
picture=open("/content material/analytics_vidhya_1024.png", "rb"),
masks=open("/content material/mask_alpha_1024.png", "rb"),
immediate="Elon Musk standing in entrance of Firm Emblem"
)
image_base64 = outcome.information[0].b64_json
image_bytes = base64.b64decode(image_base64)
# Save the picture to a file
with open("Elon_AV.png", "wb") as f:
f.write(image_bytes)
Output:

Factors to notice whereas enhancing a picture utilizing gpt-image-1:
- The picture you wish to edit and the corresponding masks should be in the identical format and dimensions, and every needs to be lower than 25MB in dimension.
- The immediate you give can be utilized to explain your entire new picture, not simply the portion being edited.
- For those who provide a number of enter photos, the masks will probably be utilized solely to the primary picture.
- The masks picture should embody an alpha channel. For those who’re utilizing a picture enhancing software to create the masks, make sure that it’s saved with an alpha channel enabled.
- If in case you have a black-and-white picture, you should use a program so as to add an alpha channel and convert it into a legitimate masks as supplied beneath:
from PIL import Picture
from io import BytesIO
# 1. Load your black & white masks as a grayscale picture
masks = Picture.open("/content material/analytics_vidhya_masked.jpeg").convert("L")
# 2. Convert it to RGBA so it has house for an alpha channel
mask_rgba = masks.convert("RGBA")
# 3. Then use the masks itself to fill that alpha channel
mask_rgba.putalpha(masks)
# 4. Convert the masks into bytes
buf = BytesIO()
mask_rgba.save(buf, format="PNG")
mask_bytes = buf.getvalue()
# 5. Save the ensuing file
img_path_mask_alpha = "mask_alpha.png"
with open(img_path_mask_alpha, "wb") as f:
f.write(mask_bytes)
Greatest Practices for Utilizing gpt-image-1
Listed here are some suggestions and greatest practices to comply with whereas utilizing gpt-image-1 for producing or enhancing photos.
- You’ll be able to customise how your picture appears to be like by setting choices like dimension, high quality, file format, compression degree, and whether or not the background is clear or not. These settings assist you management the ultimate output to match your particular wants.
- For sooner outcomes, go together with sq. photos (1024×1024) and commonplace high quality. You can too select portrait (1536×1024) or panorama (1024×1536) codecs. High quality may be set to low, medium, or excessive, and each dimension and high quality default to auto if not specified.
- Be aware that the Picture API returns the base64-encoded picture information. The default format is png, however we will additionally request it in jpeg or webp.
- In case you are utilizing jpeg or webp, then you may as well specify the output_compression parameter to regulate the compression degree (0-100%). For instance, output_compression=50 will compress the picture by 50%.
Functions of gpt-image-1
From inventive designing and e-commerce to schooling, enterprise software program, and gaming, gpt-image-1 has a variety of functions.
- Gaming: content material creation, sprite masks, dynamic backgrounds, character era, idea artwork
- Artistic Instruments: paintings era, fashion switch, design prototyping, visible storytelling
- Schooling: visible aids, historic recreations, interactive studying content material, idea visualization
- Enterprise Software program: slide visuals, report illustrations, data-to-image era, branding property
- Promoting & Advertising and marketing: marketing campaign visuals, social media graphics, localized content material creation
- Healthcare: medical illustration, affected person scan visuals, artificial picture information for mannequin coaching
- Structure & Actual Property: inside mockups, exterior renderings, structure previews, renovation concepts
- Leisure & Media: scene ideas, promotional materials, digital doubles
Limitations of gpt-image-1
The GPT-4o Picture mannequin is a robust and versatile software for picture era, however there are nonetheless a couple of limitations to bear in mind:
- Latency: Extra advanced prompts can take as much as 2 minutes to course of.
- Textual content Rendering: Whereas considerably higher than the DALL·E fashions, the mannequin should face challenges with exact textual content alignment and readability.
- Consistency: Though it may well generate visually constant photos, the mannequin could often wrestle to keep up uniformity for recurring characters or model components throughout a number of photos.
- Composition Management: Even with improved instruction-following capabilities, the mannequin could not all the time place components precisely in structured or layout-sensitive designs.
Conclusion
OpenAI’s gpt-image-1 showcases highly effective picture era capabilities with help for creation, enhancing, and variations all coming from easy textual prompts. Whereas the era of photos could take a while, the standard and management it provides make it extremely sensible and rewarding general.
Picture era fashions like this facilitate sooner content material creation, personalization, and sooner prototyping. With built-in customization choices for dimension, high quality, format, and many others. and even inpainting capabilities, gpt-image-1 provides builders full and clear management over the specified output.
Whereas some may fear that this know-how may substitute human creativity, it’s vital to notice that such instruments goal to reinforce human creativity and be useful instruments for artists. Whereas we should always undoubtedly respect originality, we should additionally embrace the comfort that this know-how brings. We should discover the best steadiness the place such instruments assist us innovate with out taking away the worth of genuine, human-made work.
Login to proceed studying and luxuriate in expert-curated content material.