We provide gpt-image-1 & gpt-image-1.5 & gpt-image-2-preview api
This is a preview version model, each generation costs $0.1
To make it easier, here are the estimated prices for generating new images at common resolutions and quality settings. These costs apply to output images.
| Resolution | Low Quality | Medium Quality | High Quality |
|---|---|---|---|
| 1024×1024 | ~$0.011 | ~$0.042 | ~$0.167 |
| 1024×1536 | ~$0.016 | ~$0.063 | ~$0.25 |
| 1536×1024 | ~$0.016 | ~$0.063 | ~$0.25 |
Higher resolutions and quality settings require more tokens, resulting in a higher cost per image.
Processing an image you provide (as input) is significantly less expensive than generating a new one.
These are estimates; the exact token count for a specific image may vary.
curl --location 'https://api.piapi.ai/v1/images/generations' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {your-api-key}' \
--data '{
"model": "gpt-image-1",
"prompt": "A cute baby sea otter",
"n": 1,
"size": "1024x1024",
"quality": "low",
"output_format": "jpeg"
}'
Use the /v1/images/edits endpoint to transform an existing image with a natural-language prompt. The request must be multipart/form-data — the reference image is uploaded as a file field named image.
gpt-image-2-preview)# 1. Prepare a reference image (either download one or use your own local file)
curl -sS -o /tmp/ref.png \
"https://oss.filenest.top/uploads/1776b813-28cb-4ca7-a82f-6096f4e7c5b7.png"
# 2. Submit the edit request
curl --location 'https://api.piapi.ai/v1/images/edits' \
--header 'Authorization: Bearer {your-api-key}' \
--form 'model=gpt-image-2-preview' \
--form 'prompt=Add a warm sunset background with soft bokeh lights, keep the character unchanged' \
--form 'n=1' \
--form 'size=1024x1024' \
--form 'response_format=url' \
--form 'image=@/tmp/ref.png'
{
"data": [
{
"url": "https://imagefil.scdn.app/assets/codex/d69c5648-f0d0-4cd3-8860-0d7b1733d274.png"
}
],
"created": 1776956146,
"usage": {
"total_tokens": 1889,
"input_tokens": 1124,
"output_tokens": 765,
"input_tokens_details": {
"text_tokens": 19,
"image_tokens": 1105
}
}
}
Verified sample roundtrip (~100 s end-to-end):
response_format is omitted, the response comes back as b64_json. Pass response_format=url when you want a hosted link instead of inline base64.