Using gemini-3.1-flash-image-preview , the image_size parameter works in the sync API but is rejected by the Batch API.
Sync API, works:
config = types.GenerateContentConfig(
response_modalities=["IMAGE"],
image_config=types.ImageConfig(
image_size="512" # Accepts "512", "1K", "2K", "4K"
),
)
response = client.models.generate_content(model="gemini-3.1-flash-image-preview", ...)
Batch API, fails:
JSONL uploaded to GCS:
{
"key": "request-001",
"request": {
"contents": [{"role": "user", "parts": [{"text": "Generate a red circle"}]}],
"generation_config": {
"response_modalities": ["IMAGE"],
"image_config": {"image_size": "512"}
}
}
}
Batch job created via:
client.batches.create(
model="gemini-3.1-flash-image-preview",
src="gs://bucket/request.jsonl",
config=types.CreateBatchJobConfig(dest="gs://bucket/results/"),
)
Job completes but response contains error:
Failed to parse JSON into proto ... @ generation_config.image_config.image_size: string ... unexpected character: '5'; expected '"'
Is image_size supported in the Batch API?