Skip to content

Create image

POST
/images/generations
curl --request POST \
--url https://example.com/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "model": "gpt-image-1", "prompt": "a red cat", "size": "1024x1024" }'

OpenAI-compatible text-to-image. Returns base64 images (b64_json); url is not supported. Models: see GET /models (image), or dall-e-3/gpt-image-1. Charged per image.

Media typeapplication/json
ImageGenRequest
object
model
required
Model

Image model id from GET /models, or dall-e-3 / gpt-image-1.

string
prompt
required
Prompt
string
n
N

Number of images (1-4).

integer
default: 1 >= 1 <= 4
size
Any of:
string
aspect_ratio
Any of:
string
resolution
Any of:
string
quality
Any of:
string
response_format
Any of:
string
Example
{
"model": "gpt-image-1",
"prompt": "a red cat",
"size": "1024x1024"
}

Successful Response

Media typeapplication/json
Examplegenerated
example

Validation Error

Media typeapplication/json
HTTPValidationError
object
detail
Detail
Array<object>
ValidationError
object
loc
required
Location
Array
msg
required
Message
string
type
required
Error Type
string
input
Input
ctx
Context
object
Examplegenerated
{
"detail": [
{
"loc": [
"example"
],
"msg": "example",
"type": "example",
"input": "example",
"ctx": {}
}
]
}