Documentation
API Reference
POST
Image Generation
/v1/images/generations
Generate images from text prompts using various models available through A4F. This endpoint is designed to be compatible with the OpenAI Images API.
Model Availability
Support for image generation varies by provider and model. Always check the Models page to confirm which models (e.g., DALL·E variants, Stable Diffusion, etc.) are available for image generation via A4F and their specific provider prefixes.
Interactive Example
Request & Response Example
Headers
Authorization
stringRequired
Bearer token for authentication. Your A4F API key. Example:
Bearer ddc-a4f-xxxxxxxx
. See Authentication.Content-Type
stringRequired
The content type of the request body.
Default: application/json
Request Body
model
stringRequired
ID of the image generation model to use. Must include provider prefix, e.g.,
provider-X/dall-e-3
. Check the Models page for supported image models.prompt
stringRequired
A text description of the desired image(s). The maximum length is model-dependent.
n
integerThe number of images to generate. Must be between 1 and 10 for most models.
Default: 1
quality
stringThe quality of the image that will be generated.
hd
creates images with finer details and greater consistency across the image. This parameter is only supported for dall-e-3
through certain providers.Default: standard
response_format
stringThe format in which the generated images are returned. Must be one of
url
or b64_json
.Default: url
size
stringThe size of the generated images. For DALL·E 3, must be one of
1024x1024
, 1792x1024
, or 1024x1792
. Other models may support different sizes (e.g., 256x256
, 512x512
).Default: 1024x1024
style
stringThe style of the generated images. Must be one of
vivid
or natural
. Vivid causes the model to lean towards generating hyper-real and dramatic images. Natural causes the model to produce more natural, less hyper-real looking images. This parameter is only supported for dall-e-3
through certain providers.Default: vivid
user
stringA unique identifier representing your end-user, which can help in monitoring and detecting abuse.
Response Body (200 OK)
created
integerThe Unix timestamp (in seconds) of when the image generation was started.
data
array of objectsAn array of image objects.
b64_json
stringThe base64-encoded JSON of the generated image, if response_format is b64_json.
url
stringThe URL of the generated image, if response_format is url. URLs are temporary and will expire.
revised_prompt
stringOptional. The prompt that was used to generate the image, if there was any revision applied to the original prompt.
Was this page helpful?