OpenAI image generations

​

Creates images from text prompts with OpenAI-compatible image generation models.

Body·
required
application/json
  • prompt
    Type: string
    required

    Text prompt for the desired image.

  • background
    Type: string enum

    Only supported by gpt-image-1.

    values
    • transparent
    • opaque
    • auto
  • model
    Type: string enum

    Image generation model.

    values
    • gpt-image-1
    • dall-e-3
    • dall-e-2
  • moderation
    Type: string enum

    Only supported by gpt-image-1.

    values
    • auto
    • low
  • n
    Type: integer
    min:  
    1
    max:  
    10

    Number of images to generate. dall-e-3 only supports 1.

  • output_compression
    Type: integer
    min:  
    0
    max:  
    100

    Compression level for gpt-image-1 jpeg/webp output.

  • output_format
    Type: string enum

    Only supported by gpt-image-1.

    values
    • png
    • jpeg
    • webp
  • partial_images
    Type: integer
    min:  
    0
    max:  
    3

    Number of partial images for streaming previews.

  • quality
    Type: string enum

    Supported values vary by model.

    values
    • auto
    • high
    • medium
    • low
    • hd
    • standard
  • response_format
    Type: string enum

    Only applies to dall-e-2 and dall-e-3.

    values
    • url
    • b64_json
  • size
    Type: string enum

    Allowed values depend on the selected model.

    values
    • 1024x1024
    • 1536x1024
    • 1024x1536
    • auto
    • 256x256
    • 512x512
    • 1792x1024
    • 1024x1792
  • stream
    Type: boolean

    Only supported by gpt-image-1.

Responses
  • application/json
  • application/json
Request Example for post/v1/images/generations
curl https://api.apigo.ai/v1/images/generations \
  --request POST \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer YOUR_SECRET_TOKEN' \
  --data '{
  "prompt": "一只可爱的小猫在花园里玩耍,阳光明媚,油画风格",
  "model": "gpt-image-1",
  "size": "1024x1024",
  "quality": "high"
}'
{
  "created": 1589478378,
  "background": "auto",
  "output_format": "png",
  "quality": "high",
  "size": "1024x1024",
  "data": [
    {
      "url": "https://example.com/generated-image.png"
    }
  ],
  "usage": {
    "input_tokens": 15,
    "input_tokens_details": {
      "image_tokens": 0,
      "text_tokens": 15
    },
    "output_tokens": 1,
    "total_tokens": 16
  }
}