我们302对这个接口做了2个优化: 1.支持返回url或原始bs64 data 2.支持传入image_url对图片进行编辑
curl --location --request POST 'https://api.302.ai/google/v1/models/gemini-2.5-flash-image?response_format' \
--header 'Authorization: Bearer ' \
--header 'Content-Type: application/json' \
--data-raw '{
"contents": [
{
"parts": [
{
"text": "Hi, can you create a 3d rendered image of a pig with wings and a top hat flying over a happy futuristic scifi city with lots of greenery?"
}
]
}
],
"generationConfig": {
"responseModalities": [
"TEXT",
"IMAGE"
],
"imageConfig": {
"aspectRatio": "4:3"
}
}
}'{
"candidates": [
{
"content": {
"parts": [
{
"text": "Certainly! Here is your 3D rendered image of a pig with wings and a top hat, soaring over a vibrant, futuristic sci-fi city with abundant greenery.\n"
},
{
"inlineData": {
"data": "iVBORw0KGg...省略",
"mimeType": "image/png"
}
},
{
"url": "https://file.302.ai/gpt/imgs/20260112/1cc6d6606add49c7b47b584f413e15a8.png"
}
],
"role": "model"
},
"finishReason": "STOP",
"index": 0
}
],
"modelVersion": "gemini-2.5-flash-image",
"responseId": "DrZkaeGZJdeez7IP_Om04A8",
"usageMetadata": {
"candidatesTokenCount": 1325,
"candidatesTokensDetails": [
{
"modality": "IMAGE",
"tokenCount": 1290
}
],
"promptTokenCount": 34,
"promptTokensDetails": [
{
"modality": "TEXT",
"tokenCount": 34
}
],
"totalTokenCount": 1359
}
}