Generate images
Creates images from a prompt. Every image is returned inline as base64 in data[].b64_json, never as a link.
size, quality and n go to the model as sent; a value it doesn’t offer is rejected with 400 and isn’t charged.
Authentication
AuthorizationBearer
Your API key, sk-..., from Console → API keys.
Request
This endpoint expects an object.
model
prompt
n
How many images. Each model has its own maximum.
size
Such as 1024x1024, on models that offer it.
quality
Such as low, medium or high, on models that offer it.
style
background
Allowed values:
output_format
Allowed values:
user
metadata
Response
The images, inline as base64 in data[].b64_json.
created
data
usage
Token usage, for models billed by tokens.
Errors
400
Bad Request Error
401
Unauthorized Error
402
Payment Required Error
403
Forbidden Error
404
Not Found Error
422
Unprocessable Entity Error
429
Too Many Requests Error
502
Bad Gateway Error
503
Service Unavailable Error