GPT-4o Image Generation API
Use Cases
Pricing
Important Notice
gpt-4o-image
stream
mode. How to handle stream responsegpt-4o-image-preview
model, see below for more detailed examples.Request Examples
Simple Text to Image
curl --location 'https://api.piapi.ai/v1/chat/completions' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {your-api-key}' \
--data '{
"model": "gpt-4o-image",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "draw a cyberpunk city"
}
]
}
],
"stream": true
}'
Simple Image to Image
curl --location 'https://api.piapi.ai/v1/chat/completions' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {your-api-key}' \
--data '{
"model": "gpt-4o-image",
"messages": [
{
"role": "user",
"content": [
{
"type": "image_url",
"image_url": {
"url": "https://images.ctfassets.net/kftzwdyauwt9/21orfxKx8HXXGKH8cTOq60/1eb34535ddce9c9e91fab0fad77bc158/minnias_cat_input.png?w=640&q=90&fm=webp"
}
},
{
"type": "text",
"text": "Give this cat a detective hat and a monocle"
}
]
}
],
"stream": true
}'
Multiple Images Input
curl --location 'https://api.piapi.ai/v1/chat/completions' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {your-api-key}' \
--data '{
"model": "gpt-4o-image",
"messages": [
{
"role": "user",
"content": [
{
"type": "image_url",
"image_url": {
"url": "https://img.moegirl.org.cn/common/thumb/5/53/Rei_Ayanami.jpg/280px-Rei_Ayanami.jpg"
}
},
{
"type": "image_url",
"image_url": {
"url": "https://moegirl.uk/images/e/ef/OP_C057_asuka.jpg"
}
},
{
"type": "text",
"text": "merge two image"
}
]
}
],
"stream": true
}'
Multiple Rounds Conversation
gpt-4o-image-preview
, gpt-4o-image
does not have multi rounds feature. It's a WIP feature for gpt-4o-image
.Legacy gpt-4o-image-preview Model
gpt-4o-image-preview
will be treated as gpt-4o-image
, including inputs, outputs, pricings.Modified at 2025-04-22 14:59:17