Skip to main content
Anyone exposes two image endpoints that are compatible with the OpenAI Images API. You can generate new images from a prompt, or supply a source image and a prompt to edit it. Both endpoints route your request to whichever upstream image channel you have configured — for example, DALL·E 3, Stable Diffusion, or other providers. Authenticate with a Bearer token in the Authorization header.

POST /v1/images/generations

Generate one or more images from a text prompt.

Request body

string
required
The model to use for image generation. For example, dall-e-3 or dall-e-2. The available values depend on which channels you have configured.
string
required
A text description of the image you want to generate. For DALL·E 3, the maximum length is 4,000 characters; for DALL·E 2 it is 1,000 characters.
integer
Number of images to generate. Defaults to 1. DALL·E 3 only supports n=1.
string
The dimensions of the generated image. Accepted values vary by model:
  • DALL·E 2: 256x256, 512x512, 1024x1024
  • DALL·E 3: 1024x1024, 1024x1792, 1792x1024
Defaults to 1024x1024.
string
Image quality. Set to hd for higher detail at higher cost (DALL·E 3 only). Defaults to standard.
string
Format for the returned image data. Either url (a temporary hosted URL) or b64_json (base64-encoded image bytes). Defaults to url.
string
Style of the generated image. vivid (hyper-real) or natural (more realistic). DALL·E 3 only.
string
Background style for the generated image, if supported by the upstream provider.
string
Output file format, if supported by the upstream provider (e.g., png, webp).
integer
Compression level for the output image, if supported by the upstream provider. Range is 0100.
boolean
Whether to include a watermark, if supported by the upstream provider.

Response

integer
Unix timestamp for when the request was processed.
object[]
Array of generated image objects.

Example


POST /v1/images/edits

Edit an existing image using a text prompt. You upload the source image as a multipart form, optionally include a mask, and provide a prompt describing the desired change.

Request body

This endpoint uses multipart/form-data encoding.
string
required
The model to use for image editing. For example, dall-e-2. Not all image models support editing.
file
required
The source image to edit. Must be a valid PNG file, less than 4 MB, and square.
string
required
A description of the edits you want to apply.
file
An optional mask image. Transparent areas of the mask indicate where the edit should be applied. Must be the same size as image.
integer
Number of edited images to generate. Defaults to 1.
string
Size of the output image. Accepted values: 256x256, 512x512, 1024x1024. Defaults to 1024x1024.
string
Either url or b64_json. Defaults to url.

Response

Same structure as /v1/images/generations.

Example

curl