#how do I make an image
1 messages · Page 1 of 1 (latest)
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)
- Open ChatGPT (web or mobile).
- 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.
- Wait for the image to generate (can take up to ~2 minutes). [Creating images]
- 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)