I am trying to do a batch image generation using the Gemini 2.5 flash image (nano banana), and I keep getting errors for the request:
{'error': {'code': 3, 'message': 'Request contains an invalid argument.'}, 'key': *"Modified by Moderator"*
The batch api accepts the data that I send, it shows me that the generation has succeeded, but it then throws this error given above.
The format that I’m using to send the image references in the prompt is:
{
"key": ".....",
"request": {
"contents": [
{
"parts": [
{
"text": "Generate an image of this pet sitting still in front of the camera. With the head and shoulders of the pet within the frame. The pet should look happy with a party hat on its head. Keep the background colour a uniform colour with colour code #00B140. Only keep the head and the shoulder of the pet in the image. Make sure that the pet fills in the frame as much as possible"
},
{
"file_data": {
"file_uri": "files/t85xlkojz2x4",
"mime_type": "image/png"
}
}
]
}
]
}
}
I cannot find the official documentation on Google for passing images in the prompt for batch endpoints.
I’m using Python 3.10 on Linux.