Generate
Creates an image given a prompt
Creates a high-quality image from a text prompt using GPT-IMAGE-1, the latest image generation model with automatic prompt optimization and enhanced visual capabilities.
Body Parameters
A text description of the desired image(s). GPT-IMAGE-1 supports up to 32,000 characters and provides automatic prompt optimization for best results.
The background setting for the image generation. GPT-IMAGE-1 supports: transparent, opaque, auto.
The model to use for image generation. GPT-IMAGE-1 is the latest model offering the best quality with automatic optimization and enhanced capabilities.
The moderation setting for the image generation. GPT-IMAGE-1 supports: low, auto.
The number of images to generate. GPT-IMAGE-1 only supports n=1.
The output compression for the image generation. GPT-IMAGE-1 supports: 0-100.
The output format for the image generation. GPT-IMAGE-1 supports: png, webp, jpeg.
The number of partial image chunks to return during streaming generation. This parameter is optional with a default of 0. When stream=true, this must be greater than 0 to receive progressive updates of the image as it's being generated. Higher values provide more frequent updates but may increase response overhead.
The quality of the image that will be generated. GPT-IMAGE-1 supports: auto (automatically select best quality), high, medium, low.
The size of the generated images. GPT-IMAGE-1 supports: auto (automatically select best size), 1536x1024 (landscape), 1024x1536 (portrait).
If set to true, partial image data will be streamed as the image is being generated. When streaming, the response will be sent as server-sent events with partial image chunks. When stream is true, partial_images must be greater than 0.
A unique identifier representing your end-user, which can help DigitalOcean to monitor and detect abuse.
Returns
The Unix timestamp (in seconds) of when the images were created
The background setting used for the image generation
The output format of the generated image
The quality setting used for the image generation
The size of the generated image
Creates an image given a prompt
curl $GRADIENT_INFERENCE_ENDPOINT/v1/images/generations \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $DIGITALOCEAN_ACCESS_TOKEN" \
-d '{
"prompt": "A cute baby sea otter floating on its back in calm blue water",
"background": "auto",
"model": "openai-gpt-image-1",
"moderation": "auto",
"n": 1,
"output_compression": 100,
"output_format": "png",
"partial_images": 1,
"quality": "auto",
"size": "auto",
"user": "user-1234"
}'
{
"created": 1677649456,
"data": [
{
"b64_json": "iVBORw0KGgoAAAANSUhEUgAAAQAAAAEAAQMAAABmvDolAAAAA1BMVEX...",
"revised_prompt": "A cute baby sea otter floating on its back in calm blue water, captured with professional photography lighting and composition"
}
],
"background": "opaque",
"output_format": "png",
"quality": "high",
"size": "1024x1024",
"usage": {
"input_tokens": 12,
"total_tokens": 4172,
"input_tokens_details": {
"text_tokens": 12
},
"output_tokens": 4160
}
}Returns Examples
{
"created": 1677649456,
"data": [
{
"b64_json": "iVBORw0KGgoAAAANSUhEUgAAAQAAAAEAAQMAAABmvDolAAAAA1BMVEX...",
"revised_prompt": "A cute baby sea otter floating on its back in calm blue water, captured with professional photography lighting and composition"
}
],
"background": "opaque",
"output_format": "png",
"quality": "high",
"size": "1024x1024",
"usage": {
"input_tokens": 12,
"total_tokens": 4172,
"input_tokens_details": {
"text_tokens": 12
},
"output_tokens": 4160
}
}