Skip to content
Main Site News Console

Image Generation (GPT-Image)

Text-to-Image

POST https://api.4allapi.com/v1/images/generations
Terminal window
curl https://api.4allapi.com/v1/images/generations \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $AIPROXY_KEY" \
-d '{
"model": "gpt-image-2",
"prompt": "Cyberpunk-style city night scene, neon lights, streets after rain",
"n": 1,
"size": "1024x1024"
}'
ParameterDescription
modelImage model name, such as the gpt-image-2 series
promptDescription of the image; recommended to include subject, style, composition, and lighting
nNumber of images to generate
sizeResolution, such as 1024x1024, 1536x1024 (landscape), 1024x1536 (portrait)
qualityQuality tier (supported models)

The response returns an image URL or base64 (b64_json); the URL is valid for a limited time, so please transfer it promptly.

Image-to-Image / Edit

POST https://api.4allapi.com/v1/images/edits

Upload a reference image as multipart/form-data:

Terminal window
curl https://api.4allapi.com/v1/images/edits \
-H "Authorization: Bearer $AIPROXY_KEY" \
-F model="gpt-image-2" \
-F image="@input.png" \
-F prompt="Replace the background with a seaside at dusk, keeping the person unchanged"

High-Resolution Variants

Some GPT-Image models provide 2K / 4K and landscape/portrait variants (subject to the models actually listed in the model marketplace, such as suffixes like -2k / -4k). Simply select the corresponding variant model name; no additional parameters are needed, and billing is based on variant pricing.