Image Generation

Generate images using GPT Image series models (such as gpt-image-1) based on text prompts.

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, e.g., gpt-image-1
promptstringYesText description for image generation
nintegerNoNumber of images to generate, default 1
sizestringNoImage size, options: 1024x1024, 1792x1024, 1024x1792, default 1024x1024
qualitystringNoImage quality, options: standard, hd, default standard
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": "gpt-image-1",
    "prompt": "A cute cat playing in the sunshine",
    "n": 1,
    "size": "1024x1024",
    "quality": "standard"
  }'

Response Example

{
  "created": 1700000000,
  "data": [
    {
      "url": "https://example.com/generated-image.png",
      "revised_prompt": "A cute orange cat happily playing in warm sunshine"
    }
  ]
}

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_promptstringModel’s revised prompt