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.

Interactive Example

Request & Response Example

curl https://api.a4f.co/v1/images/generations \
-H "Authorization: Bearer YOUR_A4F_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "provider-2/flux.1-schnell",
"prompt": "A cute baby sea otter",
"n": 1,
"size": "1024x1024"
}'

Headers

Authorization

string
Required
Bearer token for authentication. Your A4F API key. Example: Bearer ddc-a4f-xxxxxxxx. See Authentication.

Content-Type

string
Required
The content type of the request body.

Default: application/json

Request Body

model

string
Required
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

string
Required
A text description of the desired image(s). The maximum length is model-dependent.

n

integer
The number of images to generate. Must be between 1 and 10 for most models.

Default: 1

quality

string
The 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

string
The format in which the generated images are returned. Must be one of url or b64_json.

Default: url

size

string
The 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

string
The 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

string
A unique identifier representing your end-user, which can help in monitoring and detecting abuse.

Response Body (200 OK)

created

integer
The Unix timestamp (in seconds) of when the image generation was started.

data

array of objects
An array of image objects.

b64_json

string
The base64-encoded JSON of the generated image, if response_format is b64_json.

url

string
The URL of the generated image, if response_format is url. URLs are temporary and will expire.

revised_prompt

string
Optional. The prompt that was used to generate the image, if there was any revision applied to the original prompt.

Was this page helpful?