Skip to content

OpenAI Image Format (DALL·E)

Page Overview

Official Documentation

OpenAI Images

Given a text prompt and/or input images, the model will generate new images. OpenAI provides a range of powerful image generation models that can create, edit, and modify images from natural language descriptions. The currently supported models include:

ModelDescription
DALL·E seriesIncludes DALL·E 2 and DALL·E 3, which differ significantly in image quality, creative expression, and precision
GPT-Image-1OpenAI’s latest image model, which supports multi-image editing and can create new composite images based on multiple input images
# Basic image generation
curl https://4All API地址/v1/images/generations \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $4All API_API_KEY" \
-d '{
"model": "dall-e-3",
"prompt": "A cute sea otter",
"n": 1,
"size": "1024x1024"
}'
# High-quality image generation
curl https://4All API地址/v1/images/generations \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $4All API_API_KEY" \
-d '{
"model": "dall-e-3",
"prompt": "A cute sea otter",
"quality": "hd",
"style": "vivid",
"size": "1024x1024"
}'
# Use base64 response format
curl https://4All API地址/v1/images/generations \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $4All API_API_KEY" \
-d '{
"model": "dall-e-3",
"prompt": "A cute sea otter",
"response_format": "b64_json"
}'

Response example:

{
"created": 1589478378,
"data": [
{
"url": "https://...",
"revised_prompt": "A cute sea otter playing in the water, with round eyes and fluffy fur"
}
]
}
curl https://4All API地址/v1/images/edits \
-H "Authorization: Bearer $4All API_API_KEY" \
-F image="@otter.png" \
-F mask="@mask.png" \
-F prompt="A cute sea otter wearing a beret" \
-F n=2 \
-F size="1024x1024"

Response example:

{
"created": 1589478378,
"data": [
{
"url": "https://..."
},
{
"url": "https://..."
}
]
}
curl https://4All API地址/v1/images/variations \
-H "Authorization: Bearer $4All API_API_KEY" \
-F image="@otter.png" \
-F n=2 \
-F size="1024x1024"

Response example:

{
"created": 1589478378,
"data": [
{
"url": "https://..."
},
{
"url": "https://..."
}
]
}
POST /v1/images/generations

Create images from a text prompt.

POST /v1/images/edits

Create edited or extended images based on an original image and a prompt.

POST /v1/images/variations

Create variations of a given image.

Include the following header to authenticate with your API key:

Authorization: Bearer $4All API_API_KEY

Where $OPENAI_API_KEY is your API key.

  • Type: string
  • Required: yes
  • Description: A text description of the image you want to generate.
  • dall-e-2 maximum length: 1000 characters
  • dall-e-3 maximum length: 4000 characters
  • Tips:
  • Use specific and detailed descriptions
  • Include key visual elements
  • Specify the desired artistic style
  • Describe composition and perspective
  • Type: string
  • Required: no
  • Default: dall-e-2
  • Description: The model used for image generation.
  • Type: integer or null
  • Required: no
  • Default: 1
  • Description: The number of images to generate. Must be between 1 and 10. dall-e-3 supports only n=1.
  • Type: string
  • Required: no
  • Default: standard
  • Description: The quality of the generated image. The hd option produces more detailed and consistent images. This parameter is supported only by dall-e-3.
  • Type: string or null
  • Required: no
  • Default: url
  • Description: The format used to return the generated image. Must be either url or b64_json. URLs are valid for 60 minutes after generation.
  • Type: string or null
  • Required: no
  • Default: 1024x1024
  • Description: The size of the generated image. dall-e-2 must be one of 256x256, 512x512, or 1024x1024. dall-e-3 must be one of 1024x1024, 1792x1024, or 1024x1792.
  • Type: string or null
  • Required: no
  • Default: vivid
  • Description: The style of the generated image. Must be either vivid or natural. vivid tends to produce surreal and dramatic images, while natural tends to produce more natural, less surreal images. This parameter is supported only by dall-e-3.
  • Type: string
  • Required: no
  • Description: A unique identifier representing the end user, which can help OpenAI monitor and detect abuse.
  • Type: file
  • Required: yes
  • Description: The image to edit. Must be a valid PNG file, smaller than 4MB, and square. If no mask is provided, the image must include transparency, which will be used as the mask.
  • Type: string
  • Required: yes
  • Description: A text description of the image you want to generate. Maximum length: 1000 characters.
  • Type: file
  • Required: no
  • Description: An additional image whose fully transparent regions (for example, regions with alpha equal to zero) indicate where edits should be applied. Must be a valid PNG file, smaller than 4MB, and the same dimensions as image.

Other parameters are the same as the Create Images endpoint.

  • Type: file
  • Required: yes
  • Description: The image used as the basis for variations. Must be a valid PNG file, smaller than 4MB, and square.

Other parameters are the same as the Create Images endpoint.

All three endpoints return a response containing a list of image objects.

  • Type: integer
  • Description: The timestamp when the response was created
  • Type: array
  • Description: A list of generated image objects
  • Type: string
  • Description: Contains the generated image as base64-encoded JSON if response_format is b64_json
  • Type: string
  • Description: Contains the URL of the generated image if response_format is url (default)
  • Type: string
  • Description: Contains the revised prompt used to generate the image if the prompt was modified in any way

Example image object:

{
"url": "https://...",
"revised_prompt": "A cute sea otter playing in the water, with round eyes and fluffy fur"
}
  • Use clear, specific descriptions
  • Specify important visual details
  • Describe the desired artistic style and mood
  • Pay attention to composition and perspective
  • Model selection
  • dall-e-3: Suitable for scenarios that require high quality and precise details
  • dall-e-2: Suitable for rapid prototyping or simple image generation
  • Size selection
  • 1024x1024: The best choice for general-purpose use cases
  • 1792x1024/1024x1792: Suitable for landscape/portrait scenarios
  • Smaller sizes: Suitable for thumbnails or quick previews
  • Quality and style
  • quality=hd: For images that need fine detail
  • style=vivid: Suitable for creative and artistic effects
  • style=natural: Suitable for realistic scene rendering
  • Image generation failed
  • Check whether the prompt complies with content policies
  • Confirm file format and size limitations
  • Verify API key permissions
  • Results do not match expectations
  • Improve the prompt description
  • Adjust the quality and style parameters
  • Consider using image editing or variation features