Image Generation

Generate high-quality images using DALL-E 3 model based on text prompts. DALL-E 3 is OpenAI’s advanced image generation model capable of understanding complex prompts and generating detailed images.

Endpoint

POST /v1/images/generations

Authentication

All requests require a Bearer token in the Authorization header:
Authorization: Bearer YOUR_API_KEY

Request Parameters

ParameterTypeRequiredDescription
modelstringYesModel ID, use dall-e-3
promptstringYesText description for image generation, max 4000 characters
nintegerNoNumber of images to generate, DALL-E 3 only supports 1
sizestringNoImage size, options: 1024x1024, 1792x1024, 1024x1792, default 1024x1024
qualitystringNoImage quality, options: standard, hd, default standard
stylestringNoImage style, options: vivid, natural, default vivid
response_formatstringNoResponse format, options: url, b64_json, default url

Request Example

curl -X POST "https://api.example.com/v1/images/generations" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "dall-e-3",
    "prompt": "A cat wearing a spacesuit walking on the moon with Earth in the background",
    "n": 1,
    "size": "1024x1024",
    "quality": "hd",
    "style": "vivid"
  }'

Response Example

{
  "created": 1700000000,
  "data": [
    {
      "url": "https://example.com/generated-image.png",
      "revised_prompt": "A cute orange cat wearing a white spacesuit walking on the gray lunar surface with the blue Earth hanging in the black space background"
    }
  ]
}

Response Fields

FieldTypeDescription
createdintegerCreation timestamp
dataarrayList of generated images
data[].urlstringImage URL (when response_format is url)
data[].b64_jsonstringBase64 encoded image (when response_format is b64_json)
data[].revised_promptstringDALL-E 3’s revised prompt

Notes

  • DALL-E 3 automatically optimizes your prompt to generate better images
  • The revised_prompt field contains the prompt actually used by the model
  • hd quality generates more detailed images but consumes more resources
  • vivid style generates more dramatic images, natural style is more realistic