---
title: "Creates an image given a prompt. [Learn more](/docs/guides/images)."
method: POST
path: "/images/generations"
tags: ["Images"]
---

# Creates an image given a prompt. \[Learn more\](/docs/guides/images).

`POST /images/generations`

## Request body

- CreateImageRequest
  - `prompt` string, required — A text description of the desired image(s). The maximum length is 32000 characters for `gpt-image-1`, 1000 characters for `dall-e-2` and 4000 characters for `dall-e-3`.
  - `model` union — The model to use for image generation. One of `dall-e-2`, `dall-e-3`, or `gpt-image-1`. Defaults to `dall-e-2` unless a parameter specific to `gpt-image-1` is used.
    - string
    - 'dall-e-2' | 'dall-e-3' | 'gpt-image-1'
  - `n` integer, nullable — The number of images to generate. Must be between 1 and 10. For `dall-e-3`, only `n=1` is supported.
  - `quality` 'standard' | 'hd' | 'low' | 'medium' | 'high' | 'auto', nullable — The quality of the image that will be generated. - `auto` (default value) will automatically select the best quality for the given model. - `high`, `medium` and `low` are supported for `gpt-image-1`. - `hd` and `standard` are supported for `dall-e-3`. - `standard` is the only option for `dall-e-2`.
  - `response_format` 'url' | 'b64_json', nullable — The format in which generated images with `dall-e-2` and `dall-e-3` are returned. Must be one of `url` or `b64_json`. URLs are only valid for 60 minutes after the image has been generated. This parameter isn't supported for `gpt-image-1` which will always return base64-encoded images.
  - `output_format` 'png' | 'jpeg' | 'webp', nullable — The format in which the generated images are returned. This parameter is only supported for `gpt-image-1`. Must be one of `png`, `jpeg`, or `webp`.
  - `output_compression` integer, nullable — The compression level (0-100%) for the generated images. This parameter is only supported for `gpt-image-1` with the `webp` or `jpeg` output formats, and defaults to 100.
  - `size` 'auto' | '1024x1024' | '1536x1024' | '1024x1536' | '256x256' | '512x512' | '1792x1024' | '1024x1792', nullable — The size of the generated images. Must be one of `1024x1024`, `1536x1024` (landscape), `1024x1536` (portrait), or `auto` (default value) for `gpt-image-1`, one of `256x256`, `512x512`, or `1024x1024` for `dall-e-2`, and one of `1024x1024`, `1792x1024`, or `1024x1792` for `dall-e-3`.
  - `moderation` 'low' | 'auto', nullable — Control the content-moderation level for images generated by `gpt-image-1`. Must be either `low` for less restrictive filtering or `auto` (default value).
  - `background` 'transparent' | 'opaque' | 'auto', nullable — Allows to set transparency for the background of the generated image(s). This parameter is only supported for `gpt-image-1`. Must be one of `transparent`, `opaque` or `auto` (default value). When `auto` is used, the model will automatically determine the best background for the image. If `transparent`, the output format needs to support transparency, so it should be set to either `png` (default value) or `webp`.
  - `style` 'vivid' | 'natural', nullable — The style of the generated images. This parameter is only supported for `dall-e-3`. Must be one of `vivid` or `natural`. Vivid causes the model to lean towards generating hyper-real and dramatic images. Natural causes the model to produce more natural, less hyper-real looking images.
  - `user` string — A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices#end-user-ids).

## Response `200`

OK

- ImagesResponse — The response from the image generation endpoint.
  - `created` integer, required — The Unix timestamp (in seconds) of when the image was created.
  - `data` Image[] — The list of generated images.
    - `b64_json` string — The base64-encoded JSON of the generated image. Default value for `gpt-image-1`, and only present if `response_format` is set to `b64_json` for `dall-e-2` and `dall-e-3`.
    - `url` string — When using `dall-e-2` or `dall-e-3`, the URL of the generated image if `response_format` is set to `url` (default value). Unsupported for `gpt-image-1`.
    - `revised_prompt` string — For `dall-e-3` only, the revised prompt that was used to generate the image.
  - `usage` object — For `gpt-image-1` only, the token usage information for the image generation.
    - `total_tokens` integer, required — The total number of tokens (images and text) used for the image generation.
    - `input_tokens` integer, required — The number of tokens (images and text) in the input prompt.
    - `output_tokens` integer, required — The number of image tokens in the output image.
    - `input_tokens_details` object, required — The input tokens detailed information for the image generation.
      - `text_tokens` integer, required — The number of text tokens in the input prompt.
      - `image_tokens` integer, required — The number of image tokens in the input prompt.

## Changes

- **2025-04-29** `6a6c681b1820` — 2 breaking, 16 info
  - the response's body type changed from no type to `object` for status `200`
  - the response property `data` became optional for the status `200`
  - added the new optional request property `background`
  - added the new optional request property `moderation`
  - …14 more
- **2024-08-23** `5856f8b0c850` — 15 breaking, 11 warning, 8 info
  - removed `subschema #1, subschema #2` from the `size` request property `anyOf` list
  - request property `size` was restricted to a list of enum values
  - the request property `quality` became not nullable
  - removed the enum value `auto` of the request property `quality`
  - …30 more

[Change history](https://skmtc.dev/openai/apis/openapi/changes/images/generations/post.md)

---

[API](https://skmtc.dev/openai/apis/openapi.md) · [All operations](https://skmtc.dev/openai/apis/openapi/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/openai/openapi/revisions/6a6c681b1820/schema)
