Image Generation
In this section, we will guide you on how to use OpenAI's Image Generation API to create images from text descriptions.
The Image Generation API allows you to generate high-quality images based on textual prompts. This can be useful for various applications, including content creation, design inspiration, and visual aids.
Create image
This endpoint allows you to generate images from text descriptions.
Authentication
To use the Image Generation API, you must authenticate your requests using your API key. See Authentication for more information.
Required attributes
- Name
prompt
- Type
- string
- Description
A text description of the desired image(s). The maximum length is 1000 characters.
Optional attributes
- Name
n
- Type
- integer
- Description
The number of images to generate. Must be between 1 and 10. Defaults to 1.
- Name
size
- Type
- string
- Description
The size of the generated images. Must be one of "256x256", "512x512", or "1024x1024". Defaults to "1024x1024".
- Name
response_format
- Type
- string
- Description
The format in which the generated images are returned. Must be one of "url" or "b64_json". Defaults to "url".
- Name
user
- Type
- string
- Description
A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse.
Request
curl https://api.model.box/v1/images/generations \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"prompt": "A cute baby sea otter",
"n": 2,
"size": "1024x1024"
}'
Response
{
"created": 1589478378,
"data": [
{
"url": "https://..."
},
{
"url": "https://..."
}
]
}