#how do I make an image

1 messages · Page 1 of 1 (latest)

heady drum
#

uhh

leaden pantherBOT
#

Hi @heady drum. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

You can create images with OpenAI in two main ways: directly in ChatGPT, or via the API.

1. In ChatGPT (no code)

  1. Open ChatGPT (web or mobile).
  2. Either:
    • Just type what you want, e.g. “Create an image of a cat wearing sunglasses on a beach”, or
    • Click View all tools (next to the microphone) and choose Create image.
  3. Wait for the image to generate (can take up to ~2 minutes). [Creating images]
  4. To edit it later, click the image and use the Select tool, then describe the changes you want. [Creating images]

2. With the API (simple example, Python)

This creates an image from a text prompt using the Image API:

from openai import OpenAI
import base64

client = OpenAI()

prompt = """
A children's book drawing of a veterinarian using a stethoscope to 
listen to the heartbeat of a baby otter.
"""

result = client.images.generate(
    model="gpt-image-1",
    prompt=prompt
)

image_base64 = result.data[0].b64_json
image_bytes = base64.b64decode(image_base64)

with open("otter.png", "wb") as f:
    f.write(image_bytes)

[Generate images]

If you tell me whether you’re using ChatGPT or the API (and what language, if coding), I can give you a more tailored, step‑by‑step version.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: