Run in Apifox
The newest Gemini models support both text-to-image and image-to-image generation. Simply pass an image URL using the image_url parameter. Supported Models# gemini-2.5-flash-image-preview
gemini-2.0-flash-exp-image-generation
gemini-2.0-flash-preview-image-generation
Notes# 1.
The API format has been upgraded for OpenAI compatibility, and all responses are returned in Markdown format. Streaming is not supported for these models.
2.
The models automatically utilize conversation history for contextual image editing.
Request Body Params application/json
{
"model" : "gemini-2.0-flash-exp-image-generation" ,
"stream" : false ,
"messages" : [
{
"role" : "user" ,
"content" : [
{
"type" : "text" ,
"text" : "Turn this picture into a live-action version."
} ,
{
"type" : "image_url" ,
"image_url" : {
"url" : "https://s2.loli.net/2024/02/01/QSWVdw9bX56gj7O.jpg"
}
}
]
}
]
} Request Code Samples
curl --location --request POST 'https://api.302.ai/v1/chat/completions' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer ' \
--header 'Content-Type: application/json' \
--data-raw '{
"model": "gemini-2.0-flash-exp-image-generation",
"stream": false,
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Turn this picture into a live-action version."
},
{
"type": "image_url",
"image_url": {
"url": "https://s2.loli.net/2024/02/01/QSWVdw9bX56gj7O.jpg"
}
}
]
}
]
}' Responses application/json Generate Code
{
"choices" : [
{
"finish_reason" : "stop" ,
"index" : 0 ,
"message" : {
"content" : "" ,
"role" : "assistant"
}
}
] ,
"created" : 1768203150 ,
"id" : "chatcmpl-20260112153214767482089AYbkQ5Am" ,
"model" : "gemini-3-pro-image-preview" ,
"object" : "chat.completion" ,
"usage" : {
"completion_tokens" : 1494 ,
"completion_tokens_details" : {
"accepted_prediction_tokens" : 0 ,
"audio_tokens" : 0 ,
"reasoning_tokens" : 214 ,
"rejected_prediction_tokens" : 0
} ,
"prompt_tokens" : 265 ,
"prompt_tokens_details" : {
"audio_tokens" : 0 ,
"cached_tokens" : 0
} ,
"total_tokens" : 1759
}
} Modified at 2026-01-12 07:34:07