OpenAI image generations
Creates images from text prompts with OpenAI-compatible image generation models.
Body·
required
application/json
- Type: stringpromptrequired
Text prompt for the desired image.
- Type: string enumbackground
Only supported by gpt-image-1.
values- transparent
- opaque
- auto
- Type: string enummodel
Image generation model.
values- gpt
-image -1 - dall
-e -3 - dall
-e -2
- Type: string enummoderation
Only supported by gpt-image-1.
values- auto
- low
- Type: integernmin:1max:10
Number of images to generate. dall-e-3 only supports 1.
- Type: integeroutput
_compression min:0max:100Compression level for gpt-image-1 jpeg/webp output.
- Type: string enumoutput
_format Only supported by gpt-image-1.
values- png
- jpeg
- webp
- Type: integerpartial
_images min:0max:3Number of partial images for streaming previews.
- Type: string enumquality
Supported values vary by model.
values- auto
- high
- medium
- low
- hd
- standard
- Type: string enumresponse
_format Only applies to dall-e-2 and dall-e-3.
values- url
- b64
_json
- Type: string enumsize
Allowed values depend on the selected model.
values- 1024x1024
- 1536x1024
- 1024x1536
- auto
- 256x256
- 512x512
- 1792x1024
- 1024x1792
- Type: booleanstream
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
}
}